File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .string ;
2
+
3
+ public class Upper {
4
+
5
+ /**
6
+ * Converts all of the characters in this {@code String} to upper case
7
+ *
8
+ * @param s the string to convert
9
+ * @return the {@code String}, converted to uppercase.
10
+ */
11
+ public static String toUpperCase (String s ) {
12
+ char [] values = s .toCharArray ();
13
+ for (int i = 0 ; i < values .length ; ++i ) {
14
+ if (Character .isLetter (values [i ]) && Character .isLowerCase (values [i ])) {
15
+ values [i ] = Character .toUpperCase (values [i ]);
16
+ }
17
+ }
18
+ return new String (values );
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ package com .string ;
2
+
3
+ import org .junit .jupiter .api .Assertions ;
4
+ import org .junit .jupiter .api .Test ;
5
+
6
+ class UpperTest extends Upper {
7
+
8
+ @ Test
9
+ void testUpper () {
10
+ Assertions .assertEquals (toUpperCase ("abc" ), ("abc" ).toUpperCase (), "The strings are equals" );
11
+ //Assertions fail for functional reasons
12
+ Assertions .assertEquals (toUpperCase ("abc" ), "abc" , "The strings are not equals" );
13
+ }
14
+
15
+ }
You can’t perform that action at this time.
0 commit comments