-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestWesternCipher.java
More file actions
116 lines (74 loc) · 2.3 KB
/
TestWesternCipher.java
File metadata and controls
116 lines (74 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
public class TestWesternCipher {
public static void main (String[] args) {
// --------------- Test 1 --------------- [Encode AB & Test Constructor]
boolean test1Success = false;
WesternCipher wc = new WesternCipher(200);
WesternCipher wc2 = new WesternCipher();
String input = "AB";
String output = wc.encode(input);
if(output.equals("1G")) {
test1Success=true;
}
if(test1Success) {
System.out.println("Test 1 Passed");
}
else {
System.out.println("Received " + output + " and expected 1G");
}
// --------------- Test 2 --------------- [Encode BBBBBBBBBB]
boolean test2Success = false;
input = "BBBBBBBBBB";
output = wc.encode(input);
if(output.equals("GIKMOQSUWY")) {
test2Success=true;
}
if(test2Success) {
System.out.println("Test 2 Passed");
}
else {
System.out.println("Received " + output + " and expected GIKMOQSUWY");
}
// --------------- Test 3 --------------- [Decode 1G]
boolean test3Success = false;
input = "1G";
output = wc.decode(input);
if(output.equals("AB")) {
test3Success=true;
}
if(test3Success) {
System.out.println("Test 2 Passed");
}
else {
System.out.println("Received " + output + " and expected AB");
}
// --------------- Test 4 --------------- [Decode B24N2YU]
boolean test4Success = false;
input = "B24N2YU";
output = wc.decode(input);
if(output.equals("WEEKEND")) {
test4Success=true;
}
if(test4Success) {
System.out.println("Test 4 Passed");
}
else {
System.out.println("Received " + output + " and expected WEEKEND");
}
// --------------- Test 5 --------------- [Encode and Decode APPLES AND ORANGES]
boolean test5Success = false;
input = "APPLES AND ORANGES";
output = wc.encode(input);
if(output.equals("1UYW2D 1GA 4M1SP2B")) {
if(wc.decode(output).equals("APPLES AND ORANGES")) {
test5Success=true;
}
}
if(test5Success) {
System.out.println("Test 5 Passed");
}
else {
System.out.println("Received " + output + " and expected 1UYW2D 1GA 4M1SP2B");
System.out.println("OR, Received " + wc.decode(output) + " and expected APPLES AND ORANGES");
}
}
}