2015-09-24 16:35:17 +00:00
|
|
|
#include "catch.hpp"
|
|
|
|
|
2016-08-02 14:34:59 +00:00
|
|
|
#include <mapnik/value/types.hpp>
|
2015-09-24 16:35:17 +00:00
|
|
|
#include <mapnik/value.hpp>
|
|
|
|
|
|
|
|
TEST_CASE("comparison")
|
|
|
|
{
|
|
|
|
SECTION("operator==()")
|
|
|
|
{
|
2022-01-26 22:25:53 +00:00
|
|
|
mapnik::value v0 = 1; // mapnik::value_integer
|
2015-09-24 16:35:17 +00:00
|
|
|
mapnik::value v1 = 1.001; // mapnik::value_double
|
2022-01-26 22:25:53 +00:00
|
|
|
mapnik::value v2 = true; // mapnik::value_boolean
|
2015-09-24 16:35:17 +00:00
|
|
|
|
2015-11-03 15:17:43 +00:00
|
|
|
CHECK(v0.is<mapnik::value_integer>());
|
|
|
|
CHECK(v1.is<mapnik::value_double>());
|
|
|
|
CHECK(v2.is<mapnik::value_bool>());
|
|
|
|
|
2015-09-24 16:35:17 +00:00
|
|
|
REQUIRE(!(v0 == v1));
|
|
|
|
REQUIRE(!(v1 == v0));
|
|
|
|
|
|
|
|
REQUIRE(!(v1 == v2));
|
|
|
|
REQUIRE(!(v2 == v1));
|
|
|
|
|
|
|
|
REQUIRE(v2 == v0);
|
|
|
|
REQUIRE(v0 == v2);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("operator!=()")
|
|
|
|
{
|
2022-01-26 22:25:53 +00:00
|
|
|
mapnik::value v0 = 1; // mapnik::value_integer
|
|
|
|
mapnik::value v1 = 1.001; // mapnik::value_double
|
|
|
|
mapnik::value v2 = true; // mapnik::value_boolean
|
2015-09-24 16:35:17 +00:00
|
|
|
mapnik::value v3 = mapnik::value_null(); //
|
|
|
|
|
2015-11-03 15:17:43 +00:00
|
|
|
CHECK(v0.is<mapnik::value_integer>());
|
|
|
|
CHECK(v1.is<mapnik::value_double>());
|
|
|
|
CHECK(v2.is<mapnik::value_bool>());
|
|
|
|
CHECK(v3.is<mapnik::value_null>());
|
|
|
|
|
2015-09-24 16:35:17 +00:00
|
|
|
REQUIRE(v0 != v1);
|
|
|
|
REQUIRE(v1 != v0);
|
|
|
|
|
|
|
|
REQUIRE(v1 != v2);
|
|
|
|
REQUIRE(v2 != v1);
|
|
|
|
|
|
|
|
REQUIRE(!(v2 != v0));
|
|
|
|
REQUIRE(!(v0 != v2));
|
|
|
|
|
|
|
|
REQUIRE(v3 != v0);
|
|
|
|
REQUIRE(v3 != v1);
|
|
|
|
REQUIRE(v3 != v2);
|
|
|
|
REQUIRE(v0 != v3);
|
|
|
|
REQUIRE(v1 != v3);
|
|
|
|
REQUIRE(v2 != v3);
|
|
|
|
}
|
2015-11-03 10:10:24 +00:00
|
|
|
SECTION("operator<,<=,>,>=")
|
|
|
|
{
|
|
|
|
mapnik::value v0 = 1;
|
|
|
|
mapnik::value v1 = 1.01;
|
|
|
|
mapnik::value v2 = true;
|
|
|
|
mapnik::value v3 = 2;
|
2015-11-03 15:17:43 +00:00
|
|
|
|
|
|
|
CHECK(v0.is<mapnik::value_integer>());
|
|
|
|
CHECK(v1.is<mapnik::value_double>());
|
|
|
|
CHECK(v2.is<mapnik::value_bool>());
|
|
|
|
CHECK(v3.is<mapnik::value_integer>());
|
2015-11-03 10:10:24 +00:00
|
|
|
// value_integer | value_double
|
|
|
|
// 1 < 1.01 => true
|
|
|
|
// 1.01 > 1 => true
|
|
|
|
REQUIRE(v0 < v1);
|
|
|
|
REQUIRE(v1 > v0);
|
|
|
|
// 1 <= 1.01 => true
|
|
|
|
// 1.01 >= 1 => true
|
|
|
|
REQUIRE(v0 <= v1);
|
|
|
|
REQUIRE(v1 >= v0);
|
|
|
|
|
|
|
|
// value_bool | value_integer
|
|
|
|
// true < 1 => false
|
|
|
|
// true > 1 => false
|
|
|
|
REQUIRE(!(v2 < v0));
|
|
|
|
REQUIRE(!(v2 > v0));
|
|
|
|
// true <= 1 => true
|
|
|
|
// true >= 1 => true
|
|
|
|
REQUIRE(v2 <= v0);
|
|
|
|
REQUIRE(v2 >= v0);
|
|
|
|
// 1 > true => false
|
|
|
|
// 1 < true => false
|
|
|
|
REQUIRE(!(v0 > v2));
|
|
|
|
REQUIRE(!(v0 < v2));
|
|
|
|
// 1 >= true => true
|
|
|
|
// 1 <= true => true
|
|
|
|
REQUIRE(v0 >= v2);
|
|
|
|
REQUIRE(v0 <= v2);
|
|
|
|
|
|
|
|
// value_bool | value_doble
|
|
|
|
// true < 1.01 => true
|
|
|
|
// 1.01 > true => true
|
|
|
|
REQUIRE(v2 < v1);
|
|
|
|
REQUIRE(v1 > v2);
|
|
|
|
// true <= 1.01 => true
|
|
|
|
// 1.01 >= true => true
|
|
|
|
REQUIRE(v2 <= v1);
|
|
|
|
REQUIRE(v1 >= v2);
|
|
|
|
|
|
|
|
// value_integer | value_integer
|
|
|
|
// 1 < 2 => true
|
|
|
|
// 2 > 1 => true
|
|
|
|
REQUIRE(v0 < v3);
|
|
|
|
REQUIRE(v3 > v0);
|
|
|
|
// 1 <= 2 => true
|
|
|
|
// 2 >= 1 => true
|
|
|
|
REQUIRE(v0 <= v3);
|
|
|
|
REQUIRE(v3 >= v0);
|
|
|
|
}
|
2015-09-24 16:35:17 +00:00
|
|
|
}
|