-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathGameOfLifeTests.cpp
80 lines (72 loc) · 2.11 KB
/
GameOfLifeTests.cpp
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
#include "doctest/doctest.h"
#include "ApprovalTests/Approvals.h"
#include "GameOfLife.h"
#include "Storyboard.h"
#include <ostream>
#include <vector>
using namespace ApprovalTests;
TEST_CASE("Demo 15-step blinker")
{
int width = 11;
int height = 18;
{
int x = 3;
int y = 4;
std::vector<Point> alive = {
Point(x + 1, y + 1),
Point(x + 2, y + 1),
Point(x + 3, y + 1),
Point(x + 1, y + 2),
// Point(x + 2,y + 2),
Point(x + 3, y + 2),
Point(x + 1, y + 3),
Point(x + 2, y + 3),
Point(x + 3, y + 3),
Point(x + 1, y + 4),
Point(x + 2, y + 4),
Point(x + 3, y + 4),
Point(x + 1, y + 5),
Point(x + 2, y + 5),
Point(x + 3, y + 5),
Point(x + 1, y + 6),
Point(x + 2, y + 6),
Point(x + 3, y + 6),
Point(x + 1, y + 7),
// Point(x + 2,y + 7),
Point(x + 3, y + 7),
Point(x + 1, y + 8),
Point(x + 2, y + 8),
Point(x + 3, y + 8),
};
GameOfLife game(alive);
Approvals::verify(Storyboard()
.addFrame(game.print(width, height))
.addFrames(15, [&](int /*frame*/) {
game = game.advance();
return game.print(width, height);
}));
}
{
auto alive = R"(
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . X X X .
. . . . X . X .
. . . . X X X .
. . . . X X X .
. . . . X X X .
. . . . X X X .
. . . . X . X .
. . . . X X X . )";
GameOfLife game(alive);
Approvals::verify(Storyboard()
.addFrame(game.print(width, height))
.addFrames(15, [&](int /*frame*/) {
game = game.advance();
return game.print(width, height);
}));
}
}