From a3ed9ad07e43fa5bb699597f4fab28ae697ddd3f Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 21 Jan 2016 18:36:41 +0100 Subject: [PATCH] value test - improve coverage --- test/unit/core/value_test.cpp | 57 +++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/test/unit/core/value_test.cpp b/test/unit/core/value_test.cpp index d188ab2c8..048015460 100644 --- a/test/unit/core/value_test.cpp +++ b/test/unit/core/value_test.cpp @@ -22,6 +22,7 @@ TEST_CASE("mapnik::value") auto add3 = v2 + v1; auto add4 = v0 + v2; // result value_integer auto add5 = v2 + v0; + auto add6 = v2 + v2; // result_integer // check type promotion CHECK(add0.is()); CHECK(add1.is()); @@ -29,30 +30,80 @@ TEST_CASE("mapnik::value") CHECK(add3.is()); CHECK(add4.is()); CHECK(add5.is()); + CHECK(add6.is()); + // + CHECK(add6 == v0 + v0); // check commutative rules CHECK(add0 == add1); CHECK(add2 == add3); CHECK(add4 == add5); // sub - auto sub0 = v0 - v1; + auto sub0 = v0 - v1; // result value_double auto sub1 = v1 - v0; + auto sub2 = v1 - v2; // result value_double + auto sub3 = v2 - v1; + auto sub4 = v0 - v2; // result value_integer + auto sub5 = v2 - v0; + auto sub6 = v2 - v2; // result value_integer + CHECK(sub0.is()); CHECK(sub1.is()); + CHECK(sub2.is()); + CHECK(sub3.is()); + CHECK(sub4.is()); + CHECK(sub5.is()); + CHECK(sub6.is()); + + // check commutative rules CHECK(sub0 == -sub1); + CHECK(sub2 == -sub3); + CHECK(sub4 == -sub5); + CHECK(sub6 == v0 - v0); // multl - auto mult0 = v0 * v1; + auto mult0 = v0 * v1; // result value_double auto mult1 = v1 * v0; + auto mult2 = v1 * v2; // result value_double + auto mult3 = v2 * v1; + auto mult4 = v0 * v2; // result value_integer + auto mult5 = v2 * v0; + auto mult6 = v2 * v2; // result value_integer + CHECK(mult0.is()); CHECK(mult1.is()); + CHECK(mult2.is()); + CHECK(mult3.is()); + CHECK(mult4.is()); + CHECK(mult5.is()); + CHECK(mult6.is()); + // check commutative rules CHECK(mult0 == mult1); + CHECK(mult2 == mult3); + CHECK(mult4 == mult5); + // + CHECK(mult6 == v0 * v0); // div - auto div0 = v0 / v1; + auto div0 = v0 / v1; // result value_double auto div1 = v1 / v0; + auto div2 = v1 / v2; // result value_double + auto div3 = v2 / v1; + auto div4 = v0 / v2; // result value_integer + auto div5 = v2 / v0; + auto div6 = v2 / v2; // result value_interger + CHECK(div0.is()); CHECK(div1.is()); + CHECK(div2.is()); + CHECK(div3.is()); + CHECK(div4.is()); + CHECK(div5.is()); + CHECK(div6.is()); + CHECK(div0 == 1.0/div1); + CHECK(div2 == 1.0/div3); + CHECK(div4 == 1.0/div5); + CHECK(div6 == v0/v0); } }