Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/main/java/com/string/Upper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.string;

public class Upper {

/**
* Converts all of the characters in this {@code String} to upper case
*
* @param s the string to convert
* @return the {@code String}, converted to uppercase.
*/
public static String toUpperCase(String s) {
char[] values = s.toCharArray();
for (int i = 0; i < values.length; ++i) {
if (Character.isLetter(values[i]) && Character.isLowerCase(values[i])) {
values[i] = Character.toUpperCase(values[i]);
}
}
return new String(values);
}
}
15 changes: 15 additions & 0 deletions src/test/java/com/string/UpperTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.string;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

class UpperTest extends Upper {

@Test
void testUpper() {
Assertions.assertEquals(toUpperCase("abc"), ("abc").toUpperCase(), "The strings are equals");
//Assertions fail for functional reasons
Assertions.assertEquals(toUpperCase("abc"), "abc", "The strings are not equals");
}

}