forked from UMM-CSci/Coding-dojos
/
FunWithStringsTest.java
executable file
·178 lines (139 loc) · 4.14 KB
/
FunWithStringsTest.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import static org.junit.Assert.*;
import org.junit.Test;
public class FunWithStringsTest {
@Test
public void testIsCharacterInString_a() {
assertTrue(StringyThingies.isCharacterInString('a', "apple"));
}
@Test
public void testIsCharacterInString_Empty() {
assertFalse(StringyThingies.isCharacterInString('a', ""));
}
@Test
public void testIsCharacterInString_b() {
assertFalse(StringyThingies.isCharacterInString('b', "apple"));
}
@Test
public void testIsCharacterInString_F() {
assertFalse(StringyThingies.isCharacterInString('F', "fffff"));
}
@Test
public void testIsCharacterInString_WeirdCharacter() {
assertTrue(StringyThingies.isCharacterInString('$', "ke$ha"));
}
// Next Block!
@Test
public void testCountCharacterOccurrencesInString_a() {
assertEquals(2, StringyThingies.countCharacterOccurrencesInString('a', "animal"));
}
@Test
public void testCountCharacterOccurrencesInString_Q() {
assertEquals(1, StringyThingies.countCharacterOccurrencesInString('Q', "Quill quarters"));
}
// // Next Block!
@Test
public void testHasEveryLetterOfAlphabet_Fox() {
assertTrue(StringyThingies.hasEveryLetterOfAlphabet("the quick brown fox jumps over the lazy dog"));
}
@Test
public void testHasEveryLetterOfAlphabet_Burger() {
assertFalse(StringyThingies.hasEveryLetterOfAlphabet("burger"));
}
// // Next Block!
//
@Test
public void testIsPalindrome_OddLetters() {
assertTrue(StringyThingies.isPalindrome("level"));
}
@Test
public void testIsPalindrome_EvenLetters() {
assertTrue(StringyThingies.isPalindrome("noon"));
}
@Test
public void testIsPalindrome_NotPalindrome() {
assertFalse(StringyThingies.isPalindrome("batman"));
}
// Next Block!
@Test
public void testAreAnagrams_True() {
assertTrue(StringyThingies.areAnagrams("silent", "listen"));
}
@Test
public void testAreAnagrams_False() {
assertFalse(StringyThingies.areAnagrams("dinner", "breakfast"));
}
@Test
public void testAreAnagrams_True2() {
assertTrue(StringyThingies.areAnagrams("silentt", "listent"));
}
@Test
public void testAreAnagrams_False2() {
assertFalse(StringyThingies.areAnagrams("silentt", "listenn"));
}
// Next Block!
@Test
public void testFullHouse1() {
assertTrue(StringyThingies.hasFullHouse("TT333"));
}
@Test
public void testFullHouse2() {
assertTrue(StringyThingies.hasFullHouse("24242"));
}
@Test
public void testFullHouse3() {
assertFalse(StringyThingies.hasFullHouse("YYZZZ"));
}
@Test
public void testFullHouse4() {
assertFalse(StringyThingies.hasFullHouse("23456"));
}
@Test
public void testAllAreCards() {
assertTrue(StringyThingies.allAreCards("23456789TJQKA"));
assertFalse(StringyThingies.allAreCards("Nope"));
}
// Next Block!
@Test
public void testSwitcharoo1() {
assertEquals("tsa fsnur esro hehT", StringyThingies.switcharoo("The horse runs fast"));
}
@Test
public void testSwitcharoo2() {
assertEquals(" s emiT ojo dehtevolI ", StringyThingies.switcharoo(" I love the dojoTimes "));
}
@Test
public void testSwitcharoo3() {
assertEquals("K oo rKat onm'Idn are lge iZk c aJmaI", StringyThingies.switcharoo("I am Jack Ziegler and I'm not a KrooK"));
}
@Test
public void testSwitcharoo4() {
assertEquals("YOLO SWAGGING", StringyThingies.switcharoo("GNIG GAWSOLOY"));
}
@Test
public void testSwitcharoo5() {
assertEquals(" YD DUBIH ", StringyThingies.switcharoo(" HI BUDDY "));
}
@Test
public void testSwitcharoo6() {
assertEquals("B Q", StringyThingies.switcharoo("Q B"));
}
@Test
public void testSwitcharoo7() {
assertEquals("B Q", StringyThingies.switcharoo("Q B"));
}
@Test
public void testSwitcharoo8() {
assertEquals("BQ A Q", StringyThingies.switcharoo("QA Q B"));
}
@Test
public void testExclusiveOr() {
assertTrue(true ^ false);
assertTrue(false ^ true);
assertFalse(true ^ true);
assertFalse(false ^ false);
}
@Test
public void testExclusiveOrBitwise() {
assertEquals(0x11111111, 0x10101010 ^ 0x01010101);
}
}