diff options
author | Manoj Srivastava <srivasta@debian.org> | 2020-05-22 19:57:41 -0700 |
---|---|---|
committer | Manoj Srivastava <srivasta@debian.org> | 2020-05-22 20:02:19 -0700 |
commit | c3d2579ad8d7eb33059aa8fdbaf5b564411a57f2 (patch) | |
tree | 1570cda0676fdcf4171a69a7fe313c1b89a52b0c /tests/grid.cc | |
parent | 986b7742bf244b4073ecca0723615f70be8a1ab6 (diff) | |
parent | 4e9b9c402ed95bf9a17fd6d795bc49bb4128a6fa (diff) |
Merge branch 'upstream' into debian-cmake-fixes
Diffstat (limited to 'tests/grid.cc')
-rw-r--r-- | tests/grid.cc | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/grid.cc b/tests/grid.cc new file mode 100644 index 00000000..ff618088 --- /dev/null +++ b/tests/grid.cc @@ -0,0 +1,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)); + }); + + }); +}); |