-
Notifications
You must be signed in to change notification settings - Fork 0
/
bdh874-TestLife.c++
374 lines (313 loc) · 56.6 KB
/
bdh874-TestLife.c++
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
#include <cassert>
#include <istream>
#include <sstream>
#include "gtest/gtest.h"
#include "AbstractCell.h"
#include "Cell.h"
#include "ConwayCell.h"
#include "FredkinCell.h"
#include "Life.h"
Neighborhood n0(false, false, false, false, false, false, false, false);
Neighborhood n4(true, true, true, true, false, false, false, false);
Neighborhood n3(true, true, true, false, false, false, false, false);
Neighborhood n2(true, true, false, false, false, false, false, false);
Neighborhood fn0 = n0;
Neighborhood fn1(false, true, false, false, false, false, false, false);
Neighborhood fn2(false, true, false, true, false, false, false, false);
Neighborhood fn3(false, true, false, true, true, false, false, false);
Neighborhood fn4(false, true, false, true, true, false, true, false);
TEST(ConwayCell, print)
{
ConwayCell d;
ConwayCell l(true);
EXPECT_EQ('.', d.print());
EXPECT_EQ('*', l.print());
}
TEST(ConwayCell, update)
{
ConwayCell d;
ConwayCell l(true);
EXPECT_FALSE(d.update(n0));
EXPECT_FALSE(d.update(n4));
EXPECT_TRUE(d.update(n3));
EXPECT_TRUE(l.update(n3));
EXPECT_TRUE(l.update(n2));
EXPECT_FALSE(l.update(n0));
EXPECT_FALSE(l.update(n2));
}
TEST(ConwayCell, clone)
{
ConwayCell c;
ConwayCell* d = c.clone();
EXPECT_FALSE(c.update(n2));
EXPECT_TRUE(d->update(n3));
EXPECT_FALSE(c.update(n2));
delete d;
}
TEST(FredkinCell, update)
{
FredkinCell d;
FredkinCell l(true);
EXPECT_FALSE(d.update(fn0));
EXPECT_FALSE(d.update(fn2));
EXPECT_FALSE(d.update(fn4));
EXPECT_TRUE(d.update(fn1));
EXPECT_FALSE(d.update(fn0));
EXPECT_TRUE(d.update(fn3));
EXPECT_TRUE(l.update(fn1));
EXPECT_TRUE(l.update(fn3));
EXPECT_FALSE(l.update(fn2));
EXPECT_FALSE(l.update(fn4));
EXPECT_TRUE(l.update(fn1));
}
TEST(FredkinCell, print_and_age)
{
FredkinCell d;
FredkinCell l(true);
for (int i = 0; i < 10; ++i) {
EXPECT_EQ('0' + i, l.print());
l.update(fn1);
}
EXPECT_EQ('+', l.print());
EXPECT_EQ(10, l.age());
l.update(fn4);
EXPECT_EQ('-', l.print());
l.update(fn3);
EXPECT_EQ('+', l.print());
EXPECT_EQ(10, l.age());
EXPECT_EQ('-', d.print());
d.update(fn1);
EXPECT_EQ('0', d.print());
d.update(fn2);
d.update(fn3);
EXPECT_EQ('0', d.print());
d.update(fn1);
EXPECT_EQ('1', d.print());
}
TEST(FredkinCell, clone)
{
FredkinCell l(true);
FredkinCell* fp = l.clone();
l.update(fn0);
EXPECT_EQ('-', l.print());
EXPECT_EQ('0', fp->print());
delete fp;
}
TEST(Cell, is)
{
Cell cc(new ConwayCell());
Cell fc(new FredkinCell());
const ConwayCell* ccp;
const FredkinCell* fcp;
EXPECT_TRUE(nullptr == cc.is<FredkinCell>());
EXPECT_TRUE(nullptr == fc.is<ConwayCell>());
EXPECT_FALSE(nullptr == (ccp = cc.is<ConwayCell>()));
EXPECT_FALSE(nullptr == (fcp = fc.is<FredkinCell>()));
EXPECT_EQ(0, fcp->age());
ccp = nullptr;
fcp = nullptr;
}
TEST(Cell, mutate_and_update)
{
Cell fc(new FredkinCell(true));
const FredkinCell* fcp;
const ConwayCell* ccp;
EXPECT_FALSE(nullptr == (fcp = fc.is<FredkinCell>()));
fc.update(fn1);
fc.update(fn1);
EXPECT_EQ(2, fcp->age());
fc.mutate(new ConwayCell(true));
EXPECT_TRUE(nullptr == (fcp = fc.is<FredkinCell>()));
EXPECT_FALSE(nullptr == (ccp = fc.is<ConwayCell>()));
}
TEST(Life, init)
{
Life<ConwayCell> L(20, 20);
ConwayCell cc(true);
L(0, 0) = cc;
EXPECT_EQ('*', L(0, 0).print());
std::ostringstream o;
o << L(0, 0) << L(0, 1);
EXPECT_EQ("*.", o.str());
}
TEST(Life, insertion_operator)
{
std::string expected {"Generation = 0, Population = 0.\n.....\n.....\n.....\n.....\n.....\n\n"};
std::ostringstream os;
Life<ConwayCell> lc(5, 5);
ConwayCell live(true);
os << lc;
EXPECT_EQ(expected, os.str()) << os.str();
lc(1, 1) = live;
lc(1, 2) = live;
lc(1, 3) = live;
expected = "Generation = 0, Population = 3.\n.....\n.***.\n.....\n.....\n.....\n\n";
os.str("");
os << lc;
EXPECT_EQ(expected, os.str()) << os.str();
}
TEST(Life, neighborhood)
{
Life<ConwayCell> lc(5, 5);
lc.board[1][1] = true;
lc.board[1][2] = true;
lc.board[1][3] = true;
Neighborhood n1 = lc.neighborhood(1, 1);
EXPECT_FALSE(n1.NW);
EXPECT_FALSE(n1.N);
EXPECT_FALSE(n1.NE);
EXPECT_FALSE(n1.W);
EXPECT_TRUE (n1.E);
EXPECT_FALSE(n1.SW);
EXPECT_FALSE(n1.S);
EXPECT_FALSE(n1.SE);
}
TEST(Life_Conway, test1)
{
std::string expected{"Generation = 1, Population = 3.\n..*..\n..*..\n..*..\n.....\n\n"};
std::istringstream i(".....\n.***.\n.....\n.....\n");
Life<ConwayCell> L(4, 5);
loader<ConwayCell>(i, 4, 5, '.', '*', L);
L.run(1);
std::ostringstream o;
o << L;
EXPECT_EQ(expected, o.str()) << o.str();
}
TEST(Life_Conway, test2)
{
std::string expected{"Generation = 30, Population = 26.\n....................\n.*..................\n.***...****.........\n...*..**...*........\n..**..*...**........\n..*....**...........\n.*..................\n.......***..........\n......**............\n....................\n....................\n....................\n....................\n....................\n\n"};
std::istringstream is("....................\n....................\n....................\n....................\n....................\n..........**........\n.........**.........\n..........*.........\n....................\n....................\n....................\n....................\n....................\n....................\n");
Life<ConwayCell> L(14, 20);
loader<ConwayCell>(is, 14, 20, '.', '*', L);
L.run(30);
std::ostringstream o;
o << L;
EXPECT_EQ(expected, o.str()) << o.str();
}
TEST(Life_Fredkin, test1)
{
std::string expected{"Generation = 1, Population = 10.\n--00-\n---10\n011--\n--10-\n--0--\n\n"};
std::istringstream is("-----\n--00-\n-00--\n--0--\n-----\n");
Life<FredkinCell> L(5, 5);
loader<FredkinCell>(is, 5, 5, '-', '0', L);
L.run(1);
std::ostringstream os;
os << L;
EXPECT_EQ(expected, os.str()) << os.str();
}
TEST(Life_Fredkin, test2)
{
std::string expected{"Generation = 2, Population = 15.\n-01--\n000-1\n1--00\n0-210\n-01--\n\n"};
std::istringstream is("-----\n--00-\n-00--\n--0--\n-----\n");
Life<FredkinCell> L(5, 5);
loader<FredkinCell>(is, 5, 5, '-', '0', L);
L.run(2);
std::ostringstream os;
os << L;
EXPECT_EQ(expected, os.str()) << os.str();
}
TEST(Life_Cell, test1)
{
Life<Cell> lCell(5, 5);
lCell(0, 0).mutate(new ConwayCell(true));
EXPECT_EQ('*', lCell(0, 0).print());
}
TEST(Life_Cell, test2)
{
std::string expected{"Generation = 4, Population = 4.\n**--**\n\n"};
std::istringstream is("--00--\n");
Life<Cell> L(1, 6);
loader<FredkinCell>(is, 1, 6, '-', '0', L);
L.run(4);
std::ostringstream os;
os << L;
EXPECT_EQ(expected, os.str()) << os.str();
}
TEST(Life_Acceptance, r_pentomino)
{
std::string expected{"Generation = 500, Population = 227.\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n.............................................................................**\n.............................................................................**\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n............**.................................................................\n..***.......**.................................................................\n...............................................................................\n...............................................................................\n........................*......................................................\n.......................*.*.....................................................\n.......................*..*....................................................\n........................**.....................................................\n.....*.........................................................................\n....*.*........................................................................\n....*.*.......**...............................................................\n.....*........**....................*..........................................\n...................................**..........................................\n..................................***..........................................\n.......................................**...................*..................\n..............................*........*....................*..................\n............................*..*............*...............*..................\n............................*.*.............*..................................\n........................................................***...***....*.....*...\n...........................**.......***..............................*.....*...\n...........................*.........**...****..............*........*.....*...\n..........................................*.***.............*..................\n...................................*.........**.............*..........***.....\n.................................**............................................\n.................................**.*.*........................................\n.................................**.*.**...........**..........................\n......................................**...*.......****.*......................\n..............................**...........*.......**.**.......................\n..............................**...............................................\n..**...........................**......*.............*.....*.*.................\n.*..*.................................*..**...........*******..................\n.*..*..................................****..........**..*.....................\n..**..........................**..**....*............**.*......................\n.................................**.*.................*........................\n..............................*.....*..........................................\n...............................***.**..........................................\n.................................***...........*.....*.........*...............\n...............................................*.....*........*.*..............\n...............................................*.....*........*.*..............\n.............................................................***.***....*......\n.................................................***.........**.......***......\n...............................................................*...***.*.......\n.............................................................***..***..........\n.............................................................**...*............\n...............................................................*.*.............\n...............................................................*.*.............\n...............................................................................\n...............................................................................\n................................................................**.*...........\n................................................................*..*...........\n.................................................................***...........\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n.............................................................................**\n.............................................................................**\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n.............................................................................**\n.............................................................................**\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n\n"};
std::istringstream is("...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n.......................................**......................................\n......................................**.......................................\n.......................................*.......................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n...............................................................................\n\n");
Life<ConwayCell> L(201, 79);
loader<ConwayCell>(is, 201, 79, '.', '*', L);
L.runTo(500);
std::ostringstream os;
os << L;
EXPECT_EQ(expected, os.str()) << os.str();
}
TEST(Life_Acceptance, wev79_1)
{
std::string expected{"Generation = 5, Population = 747.\n................************......*.*........***..\n...***.........**************....*..*.......**.*..\n..............*.************.*..*.......*....**...\n.*.....*..*........................*..**.*****....\n.........*.*.....**********....*...*........**....\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n*...........*....**********....*...*.*......*****.\n*...........*..................*...*.*......*****.\n.........*.*.....**********....*...*........**....\n.*.....*..*........................*..**.*****....\n.................**********.....*.......*.....*...\n...***...........................*..*.......***...\n.................************.....*.*........*....\n\n"};
std::istringstream is(".*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n.*.*.*.*........................**.*..*.*.*...*...\n*.*.*.*.*.*.**********************.*.*.*.*.*.*.**.\n");
Life<ConwayCell> L(50, 50);
loader<ConwayCell>(is, 50, 50, '.', '*', L);
L.runTo(5);
std::ostringstream os;
os << L;
EXPECT_EQ(expected, os.str()) << os.str();
}
TEST(Life_Acceptance, wev79_2)
{
std::string expected{"Generation = 5, Population = 621.\n-------------0----0-------------------------------\n-------00--01----0---0-----0----------------------\n------01----0-200-----0-----0---------------------\n---------10---00-0--------------------------------\n--------10-00----0-1--00--------------------------\n---00-20--1--1-011--001--------0------------------\n--012343---22---1--0----10------0-----------------\n-------1--2--3----00---10-------------------------\n-----------31--2--01010---00----------------------\n--0-21-01-333-3--0014-51-11-----------------------\n-0121----0--00-----3-----0--10--------------------\n--00--1-30-330----0-------200----0----------------\n---00--401---21----00-22-2000-----0---------------\n--01212-210--2-3-2--1-222211100-------------------\n-----002-1-005-22---2--2--1-00-10-----------------\n--012-1---12-3-2-1----1-0--0---------0------------\n------11-2-13320-------0--1--0320-00--0-----------\n----00--20-2-03-3-1--0-12---324--00-1---0---------\n--00--0-0102---1---00-0----0----1--20----0-----0--\n-01212-------1-20-202----1--------1-------------0-\n--00--00--01--00----1-1--1----1--02-0-10----------\n--------0--3-00-02---3203-2224-----1----0-000-----\n--------00-011----2--400221-----1----11--01--0---0\n-------01--20-021--0--1-210231--0--301------10--0-\n------001000-01--253-02-12-2-02-0-01---00--10-----\n-------10----02--100-1-132----2-0-25-0---000--00--\n--00-20---00001-0-022-11---13-2-----00131--2011---\n-0123431-11-------01-0-22-1-31-1-11-----111-----10\n------0-------21-1323-1---4---22-12-1--00------00-\n---00------0000------10-1-01--201--321002-22-100--\n-00---01-20-----01-------02---1-0---201-4-2323210-\n0121-1321210---01--431-11---1-0-----0-300-----1---\n-00-------0-----00010-----1--110-----20---1-0-----\n-------00----------------00--00------431----------\n-----00--------00---01-20---------01--0-011010----\n----0110------0121-1321210---------00----0200-----\n-----00--------00-------0--------00---01-20-------\n---------------------00---------0121-1321210------\n-------------------00------------00-------0-------\n------------------0110-----------------00---------\n-------------------00----------------00-----------\n------------------------------------0110----------\n-------------------------------------00-----------\n--------------------------------------------------\n--------------------------------------------------\n--------------------------------------------------\n--------------------------------------------------\n--------------------------------------------------\n--------------------------------------------------\n--------------------------------------------------\n\n"};
std::istringstream is("--------------------------------------------------\n--------------------------------------------------\n-----------------0--------------------------------\n------------0---0---------------------------------\n-----------0---0----------------------------------\n----------0-000-----------------------------------\n-------000---00------------0----------------------\n--------00--0-------------0-----------------------\n-----------0---0---------0------------------------\n--------00000-0----0--000-------------------------\n------00-00--0---00----00-------------------------\n----------000---00--------------------------------\n-----------00-000---------------------------------\n-------00--000000----000--------------------------\n----------0--00-------0---------------------------\n-------0000000-----0-0---0------------------------\n--------00--000---000---0--------0----------------\n-----------00----0-00--0----0---0-----------------\n--------------000---000----0--00------------------\n------00--00---00----00---0-000-0-----------------\n-----------------00----000--0000-0----------------\n-----------------------00000--0-0--0--------------\n-------------00----00-0---0000-0--0-----0---------\n---------------------0-----0000--0-----0-------0--\n-----------0------000-00-----0000-----0-------0---\n----------0--------00---00-----00--000-------0----\n---------0----------------00--------00----000-----\n------000------------------00--------------00-----\n-------00--------00------0---00-------------------\n------------------------0---------00--------------\n-----------------------0-----------------000------\n-----00-------------000-------------------0-------\n---------------------00------------------0--------\n--------------------------------------000---------\n---------------------------------------00---------\n-------------------00-----------------------------\n--------------------------------------------------\n-------------------------------------00-----------\n--------------------------------------------------\n--------------------------------------------------\n--------------------------------------------------\n--------------------------------------------------\n--------------------------------------------------\n--------------------------------------------------\n--------------------------------------------------\n--------------------------------------------------\n--------------------------------------------------\n--------------------------------------------------\n--------------------------------------------------\n--------------------------------------------------\n");
Life<FredkinCell> L(50, 50);
loader<FredkinCell>(is, 50, 50, '-', '0', L);
L.runTo(5);
std::ostringstream os;
os << L;
EXPECT_EQ(expected, os.str()) << os.str();
}
TEST(Life_Acceptance, wev79_3)
{
std::string expected{"Generation = 5, Population = 52.\n-------0------------\n--------------------\n---0----------------\n----------00--------\n---0-----0----------\n---------0*---0-----\n---------0-1--1-----\n------00--*..-01----\n-----0---.-*-0.-----\n-----01-..*--0*---0-\n-----01-..*--0*---0-\n-----0---.-*-0.-----\n------00--*..-01----\n---------0-1--1-----\n---------0*---0-----\n---0-----0----------\n----------00--------\n---0----------------\n--------------------\n-------0------------\n\n"};
std::istringstream is("----0---------------\n-----0--------------\n------0-------------\n-------0------------\n--------0-----------\n---------0----------\n----------0---------\n-----------0--------\n----------000-------\n----------0000------\n----------0000------\n----------000-------\n-----------0--------\n----------0---------\n---------0----------\n--------0-----------\n-------0------------\n------0-------------\n-----0--------------\n----0---------------\n");
Life<Cell> L(20, 20);
loader<FredkinCell>(is, 20, 20, '-', '0', L);
L.runTo(5);
std::ostringstream os;
os << L;
EXPECT_EQ(expected, os.str()) << os.str();
}
TEST(Life_Acceptance, vaa292)
{
std::string expected{"Generation = 100, Population = 4.\n......\n......\n..**..\n..**..\n......\n\n"};
std::istringstream is("**..**\n*.**.*\n......\n*....*\n**..**\n");
Life<ConwayCell> L(5, 6);
loader<ConwayCell>(is, 5, 6, '.', '*', L);
L.runTo(100);
std::ostringstream os;
os << L;
EXPECT_EQ(expected, os.str()) << os.str();
}
TEST(Life_Acceptance, twpixley)
{
std::string expected{"Generation = 5, Population = 200.\n12---1-1-1-1-1-----1\n132012-2-2-2-2-212-1\n---2------------2---\n--040-0-0-0-0-04120-\n1-----4-4-4-4-4---20\n-24-444444444444-42-\n02---4-4-4-4-4-----1\n1-----4-4-4-4-4---20\n-24-444444444444-42-\n02---4-4-4-4-4-----1\n1-----4-4-4-4-4---20\n-24-444444444444-42-\n02---4-4-4-4-4-----1\n1-----4-4-4-4-4---20\n-24-444444444444-42-\n02---4-4-4-4-4-----1\n-02140-0-0-0-0-040--\n---2------------2---\n1-212-2-2-2-2-210231\n1-----1-1-1-1-1---21\n\n"};
std::istringstream is("0-0-0-0-0-0-0-0-0-0-\n-0-0-0-0-0-0-0-0-0-0\n--------------------\n0-0-0-0-0-0-0-0-0-0-\n-0-0-0-0-0-0-0-0-0-0\n--------------------\n0-0-0-0-0-0-0-0-0-0-\n-0-0-0-0-0-0-0-0-0-0\n--------------------\n0-0-0-0-0-0-0-0-0-0-\n-0-0-0-0-0-0-0-0-0-0\n--------------------\n0-0-0-0-0-0-0-0-0-0-\n-0-0-0-0-0-0-0-0-0-0\n--------------------\n0-0-0-0-0-0-0-0-0-0-\n-0-0-0-0-0-0-0-0-0-0\n--------------------\n0-0-0-0-0-0-0-0-0-0-\n-0-0-0-0-0-0-0-0-0-0\n");
Life<FredkinCell> L(20, 20);
loader<FredkinCell>(is, 20, 20, '-', '0', L);
L.runTo(5);
std::ostringstream os;
os << L;
EXPECT_EQ(expected, os.str()) << os.str();
}
TEST(Life_Acceptance, psteiner)
{
std::string expected{"Generation = 8, Population = 124.\n---------------------------------------------\n---------------------------------------------\n------------------0-----0--------------------\n------------------1-----1--------------------\n----------------01210001210------------------\n------------------1--1--1--------------------\n------------------2--2--2--------------------\n------------------3111113--------------------\n---------------------2-----------------------\n---------------------3-----------------------\n----------0-----0----3----0-----0------------\n----------1-----2---------2-----1------------\n--------01212321342-----24312321210----------\n----------1--1--3---------3--1--1------------\n----------0--1--0---------0--1--0------------\n----------0121134---------4311210------------\n-------------1---------------1---------------\n-------------1---------------1---------------\n-------------0----2-----2----0---------------\n------------------1-----1--------------------\n----------------02310301320------------------\n------------------2--3--2--------------------\n------------------0--2--0--------------------\n------------------0111110--------------------\n---------------------2-----------------------\n---------------------1-----------------------\n---------------------0-----------------------\n---------------------------------------------\n---------------------------------------------\n\n"};
std::istringstream is("---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n------------------0-----0--------------------\n------------------0-----0--------------------\n----------------00000000000------------------\n------------------0--0--0--------------------\n------------------0--0--0--------------------\n------------------0000000--------------------\n---------------------0-----------------------\n---------------------0-----------------------\n---------------------0-----------------------\n---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n---------------------------------------------\n");
Life<FredkinCell> L(29, 45);
loader<FredkinCell>(is, 29, 45, '-', '0', L);
L.runTo(8);
std::ostringstream os;
os << L;
EXPECT_EQ(expected, os.str()) << os.str();
}
TEST(Life_Acceptance, tayoung)
{
std::string expected{"Generation = 5, Population = 175.\n-000.-.--000000----00000000---.-00\n-1-0-----*1--.1**001-------1---*-*\n-0-0--*0-0--000----000000000---01-\n00-0-01*-0-0---1------------------\n-0-0--1--0-0---0000000000000000---\n-0-1-----0-0--01---------------1--\n-0-0-----0-0---00000000000000000--\n-01*-----0-0----------------------\n-0-------0-0----------------------\n--1-00-00-1-----------------------\n0--*-*0*-*--0----0----------------\n--*-1-1-1-*-------0---------------\n---1-1*1-1------------------------\n-1--10101---0001------------------\n*.-*-*.*-*1*-.-*0----0------------\n-1----------00-0--0---0-----------\n0*---1-1---*0----0----------------\n\n"};
std::istringstream is("----------------------------------\n-----00--------0000000000000000---\n----0-0-----------------------0---\n---0--0----------------------0----\n------0---------------------0-----\n------0--------------------0------\n------0-------------------0-------\n------0------------------0--------\n------0-----------------0---------\n------0----------------0----------\n------0---------------0-----------\n------0--------------0------------\n------0-------------0-------------\n------0------------0--------------\n-00000000000------0---------------\n----------------------------------\n----------------------------------\n");
Life<Cell> L(17, 34);
loader<FredkinCell>(is, 17, 34, '-', '0', L);
L.runTo(5);
std::ostringstream os;
os << L;
EXPECT_EQ(expected, os.str()) << os.str();
}