|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+import org.junit.Before;
|
|
|
2
|
+import org.junit.Test;
|
|
|
3
|
+import org.junit.Ignore;
|
|
|
4
|
+
|
|
|
5
|
+import static org.junit.Assert.assertEquals;
|
|
|
6
|
+
|
|
|
7
|
+public class FoodChainTest {
|
|
|
8
|
+ private FoodChain foodChain;
|
|
|
9
|
+
|
|
|
10
|
+ @Before
|
|
|
11
|
+ public void setup() {
|
|
|
12
|
+ foodChain = new FoodChain();
|
|
|
13
|
+ }
|
|
|
14
|
+
|
|
|
15
|
+ @Test
|
|
|
16
|
+ public void fly() {
|
|
|
17
|
+ int verse = 1;
|
|
|
18
|
+ String expected = "I know an old lady who swallowed a fly.\n" +
|
|
|
19
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
|
|
|
20
|
+
|
|
|
21
|
+ assertEquals(expected, foodChain.verse(verse));
|
|
|
22
|
+ }
|
|
|
23
|
+
|
|
|
24
|
+ @Test
|
|
|
25
|
+ @Ignore("Remove to run test.")
|
|
|
26
|
+ public void spider() {
|
|
|
27
|
+ int verse = 2;
|
|
|
28
|
+ String expected = "I know an old lady who swallowed a spider.\n" +
|
|
|
29
|
+ "It wriggled and jiggled and tickled inside her.\n" +
|
|
|
30
|
+ "She swallowed the spider to catch the fly.\n" +
|
|
|
31
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
|
|
|
32
|
+
|
|
|
33
|
+ assertEquals(expected, foodChain.verse(verse));
|
|
|
34
|
+ }
|
|
|
35
|
+
|
|
|
36
|
+ @Test
|
|
|
37
|
+ @Ignore("Remove to run test.")
|
|
|
38
|
+ public void bird() {
|
|
|
39
|
+ int verse = 3;
|
|
|
40
|
+ String expected = "I know an old lady who swallowed a bird.\n" +
|
|
|
41
|
+ "How absurd to swallow a bird!\n" +
|
|
|
42
|
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
|
|
|
43
|
+ "She swallowed the spider to catch the fly.\n" +
|
|
|
44
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
|
|
|
45
|
+
|
|
|
46
|
+ assertEquals(expected, foodChain.verse(verse));
|
|
|
47
|
+ }
|
|
|
48
|
+
|
|
|
49
|
+ @Test
|
|
|
50
|
+ @Ignore("Remove to run test.")
|
|
|
51
|
+ public void cat() {
|
|
|
52
|
+ int verse = 4;
|
|
|
53
|
+ String expected = "I know an old lady who swallowed a cat.\n" +
|
|
|
54
|
+ "Imagine that, to swallow a cat!\n" +
|
|
|
55
|
+ "She swallowed the cat to catch the bird.\n" +
|
|
|
56
|
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
|
|
|
57
|
+ "She swallowed the spider to catch the fly.\n" +
|
|
|
58
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
|
|
|
59
|
+
|
|
|
60
|
+ assertEquals(expected, foodChain.verse(verse));
|
|
|
61
|
+ }
|
|
|
62
|
+
|
|
|
63
|
+
|
|
|
64
|
+ @Test
|
|
|
65
|
+ @Ignore("Remove to run test.")
|
|
|
66
|
+ public void dog() {
|
|
|
67
|
+ int verse = 5;
|
|
|
68
|
+ String expected = "I know an old lady who swallowed a dog.\n" +
|
|
|
69
|
+ "What a hog, to swallow a dog!\n" +
|
|
|
70
|
+ "She swallowed the dog to catch the cat.\n" +
|
|
|
71
|
+ "She swallowed the cat to catch the bird.\n" +
|
|
|
72
|
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
|
|
|
73
|
+ "She swallowed the spider to catch the fly.\n" +
|
|
|
74
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
|
|
|
75
|
+
|
|
|
76
|
+ assertEquals(expected, foodChain.verse(verse));
|
|
|
77
|
+ }
|
|
|
78
|
+
|
|
|
79
|
+ @Test
|
|
|
80
|
+ @Ignore("Remove to run test.")
|
|
|
81
|
+ public void goat() {
|
|
|
82
|
+ int verse = 6;
|
|
|
83
|
+ String expected = "I know an old lady who swallowed a goat.\n" +
|
|
|
84
|
+ "Just opened her throat and swallowed a goat!\n" +
|
|
|
85
|
+ "She swallowed the goat to catch the dog.\n" +
|
|
|
86
|
+ "She swallowed the dog to catch the cat.\n" +
|
|
|
87
|
+ "She swallowed the cat to catch the bird.\n" +
|
|
|
88
|
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
|
|
|
89
|
+ "She swallowed the spider to catch the fly.\n" +
|
|
|
90
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
|
|
|
91
|
+
|
|
|
92
|
+ assertEquals(expected, foodChain.verse(verse));
|
|
|
93
|
+ }
|
|
|
94
|
+
|
|
|
95
|
+ @Test
|
|
|
96
|
+ @Ignore("Remove to run test.")
|
|
|
97
|
+ public void cow() {
|
|
|
98
|
+ int verse = 7;
|
|
|
99
|
+ String expected = "I know an old lady who swallowed a cow.\n" +
|
|
|
100
|
+ "I don't know how she swallowed a cow!\n" +
|
|
|
101
|
+ "She swallowed the cow to catch the goat.\n" +
|
|
|
102
|
+ "She swallowed the goat to catch the dog.\n" +
|
|
|
103
|
+ "She swallowed the dog to catch the cat.\n" +
|
|
|
104
|
+ "She swallowed the cat to catch the bird.\n" +
|
|
|
105
|
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
|
|
|
106
|
+ "She swallowed the spider to catch the fly.\n" +
|
|
|
107
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
|
|
|
108
|
+
|
|
|
109
|
+ assertEquals(expected, foodChain.verse(verse));
|
|
|
110
|
+ }
|
|
|
111
|
+
|
|
|
112
|
+ @Test
|
|
|
113
|
+ @Ignore("Remove to run test.")
|
|
|
114
|
+ public void horse() {
|
|
|
115
|
+ int verse = 8;
|
|
|
116
|
+ String expected = "I know an old lady who swallowed a horse.\n" +
|
|
|
117
|
+ "She's dead, of course!";
|
|
|
118
|
+
|
|
|
119
|
+ assertEquals(expected, foodChain.verse(verse));
|
|
|
120
|
+ }
|
|
|
121
|
+
|
|
|
122
|
+
|
|
|
123
|
+ @Test
|
|
|
124
|
+ @Ignore("Remove to run test.")
|
|
|
125
|
+ public void multipleVerses() {
|
|
|
126
|
+ int startVerse = 1;
|
|
|
127
|
+ int endVerse = 3;
|
|
|
128
|
+ String expected = "I know an old lady who swallowed a fly.\n" +
|
|
|
129
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
|
|
|
130
|
+ "\n" +
|
|
|
131
|
+ "I know an old lady who swallowed a spider.\n" +
|
|
|
132
|
+ "It wriggled and jiggled and tickled inside her.\n" +
|
|
|
133
|
+ "She swallowed the spider to catch the fly.\n" +
|
|
|
134
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
|
|
|
135
|
+ "\n" +
|
|
|
136
|
+ "I know an old lady who swallowed a bird.\n" +
|
|
|
137
|
+ "How absurd to swallow a bird!\n" +
|
|
|
138
|
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
|
|
|
139
|
+ "She swallowed the spider to catch the fly.\n" +
|
|
|
140
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.";
|
|
|
141
|
+
|
|
|
142
|
+ assertEquals(expected, foodChain.verse(startVerse, endVerse));
|
|
|
143
|
+ }
|
|
|
144
|
+
|
|
|
145
|
+
|
|
|
146
|
+ @Test
|
|
|
147
|
+ @Ignore("Remove to run test.")
|
|
|
148
|
+ public void wholeSong() {
|
|
|
149
|
+ int startVerse = 1;
|
|
|
150
|
+ int endVerse = 8;
|
|
|
151
|
+ String expected = "I know an old lady who swallowed a fly.\n" +
|
|
|
152
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
|
|
|
153
|
+ "\n" +
|
|
|
154
|
+ "I know an old lady who swallowed a spider.\n" +
|
|
|
155
|
+ "It wriggled and jiggled and tickled inside her.\n" +
|
|
|
156
|
+ "She swallowed the spider to catch the fly.\n" +
|
|
|
157
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
|
|
|
158
|
+ "\n" +
|
|
|
159
|
+ "I know an old lady who swallowed a bird.\n" +
|
|
|
160
|
+ "How absurd to swallow a bird!\n" +
|
|
|
161
|
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
|
|
|
162
|
+ "She swallowed the spider to catch the fly.\n" +
|
|
|
163
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
|
|
|
164
|
+ "\n" +
|
|
|
165
|
+ "I know an old lady who swallowed a cat.\n" +
|
|
|
166
|
+ "Imagine that, to swallow a cat!\n" +
|
|
|
167
|
+ "She swallowed the cat to catch the bird.\n" +
|
|
|
168
|
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
|
|
|
169
|
+ "She swallowed the spider to catch the fly.\n" +
|
|
|
170
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
|
|
|
171
|
+ "\n" +
|
|
|
172
|
+ "I know an old lady who swallowed a dog.\n" +
|
|
|
173
|
+ "What a hog, to swallow a dog!\n" +
|
|
|
174
|
+ "She swallowed the dog to catch the cat.\n" +
|
|
|
175
|
+ "She swallowed the cat to catch the bird.\n" +
|
|
|
176
|
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
|
|
|
177
|
+ "She swallowed the spider to catch the fly.\n" +
|
|
|
178
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
|
|
|
179
|
+ "\n" +
|
|
|
180
|
+ "I know an old lady who swallowed a goat.\n" +
|
|
|
181
|
+ "Just opened her throat and swallowed a goat!\n" +
|
|
|
182
|
+ "She swallowed the goat to catch the dog.\n" +
|
|
|
183
|
+ "She swallowed the dog to catch the cat.\n" +
|
|
|
184
|
+ "She swallowed the cat to catch the bird.\n" +
|
|
|
185
|
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
|
|
|
186
|
+ "She swallowed the spider to catch the fly.\n" +
|
|
|
187
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
|
|
|
188
|
+ "\n" +
|
|
|
189
|
+ "I know an old lady who swallowed a cow.\n" +
|
|
|
190
|
+ "I don't know how she swallowed a cow!\n" +
|
|
|
191
|
+ "She swallowed the cow to catch the goat.\n" +
|
|
|
192
|
+ "She swallowed the goat to catch the dog.\n" +
|
|
|
193
|
+ "She swallowed the dog to catch the cat.\n" +
|
|
|
194
|
+ "She swallowed the cat to catch the bird.\n" +
|
|
|
195
|
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
|
|
|
196
|
+ "She swallowed the spider to catch the fly.\n" +
|
|
|
197
|
+ "I don't know why she swallowed the fly. Perhaps she'll die.\n" +
|
|
|
198
|
+ "\n" +
|
|
|
199
|
+ "I know an old lady who swallowed a horse.\n" +
|
|
|
200
|
+ "She's dead, of course!";
|
|
|
201
|
+
|
|
|
202
|
+ assertEquals(expected, foodChain.verse(startVerse, endVerse));
|
|
|
203
|
+ }
|
|
|
204
|
+}
|