File tree Expand file tree Collapse file tree 2 files changed +11
-21
lines changed Expand file tree Collapse file tree 2 files changed +11
-21
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ public class CaesarShift {
55 private static int key = 25 ; //Initialize and encapsulate the shift key
66 private static String encryptedMsg ; //Create and encapsulate the message container
77
8- public String encrypt (String encryptMsg ){
9- String upCased = encryptMsg .toUpperCase ();
8+ public String encrypt (String msg ){
9+ String upCased = msg .toUpperCase ();
1010 char [] upCasedArrs = upCased .toCharArray ();//split the string to a character array
1111 ArrayList <Character > encryptedChars = new ArrayList <Character >();
1212
@@ -20,8 +20,4 @@ public String encrypt(String encryptMsg){
2020 return encryptedMsg ;
2121 }
2222
23- public String decrypt (String decryptMsg ){
24- return decryptMsg .toUpperCase ();
25- }
26-
2723}
Original file line number Diff line number Diff line change 44
55class CaesarShiftTest {
66 @ Test
7- public void caesarShift_encryptCheckCase_Boolean () {
8- CaesarShift checkCase = new CaesarShift ();
9- assertEquals (true , Character . isUpperCase ( checkCase . encrypt ("a" ). charAt ( 0 ) ));
7+ public void caesarShift_convertCase_String () {
8+ CaesarShift testCase = new CaesarShift ();
9+ assertEquals ("Z" , testCase . encrypt ("a" ));
1010 }
1111
1212 @ Test
13- void caesarShift_encryptString_String () {
14- CaesarShift encryptString = new CaesarShift ();
15- assertEquals ("GDKKN " , encryptString .encrypt ("hello " ));
13+ public void caesarShift_encryptSingleChar_String () {
14+ CaesarShift encryptChar = new CaesarShift ();
15+ assertEquals ("Y " , encryptChar .encrypt ("Z " ));
1616 }
1717
1818 @ Test
19- void caesarShift_decryptCheckCase_Boolean () {
20- CaesarShift checkCase = new CaesarShift ();
21- assertEquals (true , Character .isUpperCase (checkCase .decrypt ("z" ).charAt (0 )));
22- }
23-
24- @ Test
25- public void caesarShift_decryptString_String (){
26- CaesarShift decryptStr = new CaesarShift ();
27- assertEquals ("HELLO" , decryptStr .decrypt ("GDKKN" ));
19+ void caesarShift_encryptString_String () {
20+ CaesarShift encryptString = new CaesarShift ();
21+ assertEquals ("GDKKN" , encryptString .encrypt ("hello" ));
2822 }
2923}
You can’t perform that action at this time.
0 commit comments