summaryrefslogtreecommitdiff
path: root/tests/grid.cc
blob: ff6180886e4317b0118117ceef7a911d875df3b7 (plain)
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
#include "grid.hpp"
#include <bandit/bandit.h>
using namespace bandit;

go_bandit([]() {
	describe("grid<>", []() {

		auto w0 = size_t { 123 };
		auto h0 = size_t { 42 };

		it("width(...) properly sets returned width", [&](){
			// Setup
			grid<int> g;
			// Exercise
			g.width(w0);
			// Verify
			AssertThat(g.width(), Equals(w0));
		});

		it("height(...) properly sets returned height", [&](){
			// Setup
			grid<int> g;
			// Exercise
			g.height(h0);
			// Verify
			AssertThat(g.height(), Equals(h0));
		});

		it("resize(w, h) properly sets returned width and height", [&](){
			// Setup
			grid<int> g;
			// Exercise
			g.resize(w0, h0);
			// Verify
			AssertThat(g.width(), Equals(w0));
			AssertThat(g.height(), Equals(h0));
		});

		it("operator () can access ((w-1), (h-1)) element", [&](){
			// Class with 'magic' default value
			struct X { int magic = 1001; };
			// Setup
			grid<X> g;
			g.resize(w0 + 1, h0 + 1);
			// Exercise
			auto x = g(w0, h0);
			// Verify
			AssertThat(x.magic, Equals(1001));
		});

	});
});