-
-
Notifications
You must be signed in to change notification settings - Fork 314
/
Copy pathTestCheckPermutation.java
102 lines (72 loc) · 3.3 KB
/
TestCheckPermutation.java
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
package com.ctci.arraysandstrings;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
class TestCheckPermutation {
@Test
void testPermutationStringWithEmpty() {
String a1 = "";
String a2 = "";
String b1 = "1234567890 qwertyuiopasdfghjklzxcvbnm !@#$%^&*()-=";
String b2 = "";
String c1 = "";
String c2 = "1234567890 qwertyuiopasdfghjklzxcvbnm !@#$%^&*()-=";
boolean resultA = CheckPermutation.isOnePermutationOfOther(a1, a2);
boolean resultB = CheckPermutation.isOnePermutationOfOther(b1, b2);
boolean resultC = CheckPermutation.isOnePermutationOfOther(c1, c2);
assertTrue(resultA);
assertFalse(resultB);
assertFalse(resultC);
}
@Test
void testPermutationStringAllCharacter() {
String a1 = "1234567890 qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM !@#$%^&*()-=";
String a2 = "!@#$%^&*()-= 1234567890 qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM";
String b1 = "~!@#$%^&*([{<>}])+-=:;'\\\",./? ";
String b2 = " ?/.,\"\\';:=-+)}]><[{(*&^%$#@!~";
String c1 = "Â Ă Ơ Ô Ư Ê â ă ơ ô ư ê";
String c2 = "ê ư ô ơ ă â Ê Ư Ô Ơ Ă Â";
String d1 = "ÂÂ ĂĂ ƠƠ ÔÔ ƯƯ ÊÊ ââ ăă ơơ ôô ưư êê";
String d2 = "ê ư ô ơ ă â Ê Ư Ô Ơ Ă Â";
boolean resultA = CheckPermutation.isOnePermutationOfOther(a1, a2);
boolean resultB = CheckPermutation.isOnePermutationOfOther(b1, b2);
boolean resultC = CheckPermutation.isOnePermutationOfOther(c1, c2);
boolean resultD = CheckPermutation.isOnePermutationOfOther(d1, d2);
assertTrue(resultA);
assertTrue(resultB);
assertTrue(resultC);
assertFalse(resultD);
}
@Test
void testPermutationWithAsciiAndStringEmpty() {
String a1 = "";
String a2 = "";
String b1 = "1234567890 qwertyuiopasdfghjklzxcvbnm !@#$%^&*()-=";
String b2 = "";
String c1 = "";
String c2 = "1234567890 qwertyuiopasdfghjklzxcvbnm !@#$%^&*()-=";
boolean resultA = CheckPermutation.isOnePermutationOfOtherGivenThatStringsContainOnlyAscii(a1, a2);
boolean resultB = CheckPermutation.isOnePermutationOfOtherGivenThatStringsContainOnlyAscii(b1, b2);
boolean resultC = CheckPermutation.isOnePermutationOfOtherGivenThatStringsContainOnlyAscii(c1, c2);
assertTrue(resultA);
assertFalse(resultB);
assertFalse(resultC);
}
@Test
void testPermutationWithAsciiAndStringAllCharacter() {
String a1 = "1234567890 qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM !@#$%^&*()-=";
String a2 = "!@#$%^&*()-= 1234567890 qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM";
String b1 = "~!@#$%^&*([{<>}])+-=:;'\\\",./? ";
String b2 = " ?/.,\"\\';:=-+)}]><[{(*&^%$#@!~";
String c1 = "Â Ă Ơ Ô Ư Ê â ă ơ ô ư ê";
String c2 = "ê ư ô ơ ă â Ê Ư Ô Ơ Ă Â";
String d1 = "Â Ă Ơ Ô Ư Ê â ă ơ ô ư ê";
String e2 = "ê ư ô ơ ă â Ê Ư Ô Ơ Ă Â";
boolean resultA = CheckPermutation.isOnePermutationOfOtherGivenThatStringsContainOnlyAscii(a1, a2);
boolean resultB = CheckPermutation.isOnePermutationOfOtherGivenThatStringsContainOnlyAscii(b1, b2);
boolean resultC = CheckPermutation.isOnePermutationOfOtherGivenThatStringsContainOnlyAscii(c1, c2);
assertTrue(resultA);
assertTrue(resultB);
assertFalse(resultC);
}
}