From eea082ffd1a3ecf73b7c464cc28da5ef74d3a30f Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:15 +0200 Subject: Add grid<> template class for representing 2D grids --- tests/grid.cc | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/grid.cc (limited to 'tests/grid.cc') 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 +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 g; + // Exercise + g.width(w0); + // Verify + AssertThat(g.width(), Equals(w0)); + }); + + it("height(...) properly sets returned height", [&](){ + // Setup + grid g; + // Exercise + g.height(h0); + // Verify + AssertThat(g.height(), Equals(h0)); + }); + + it("resize(w, h) properly sets returned width and height", [&](){ + // Setup + grid 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 g; + g.resize(w0 + 1, h0 + 1); + // Exercise + auto x = g(w0, h0); + // Verify + AssertThat(x.magic, Equals(1001)); + }); + + }); +}); -- cgit v1.2.3