diff --git a/Tests/Source/UnitTests/Animation.cpp b/Tests/Source/UnitTests/Animation.cpp index 07da8862d..37b77f6ef 100644 --- a/Tests/Source/UnitTests/Animation.cpp +++ b/Tests/Source/UnitTests/Animation.cpp @@ -88,7 +88,7 @@ TEST_CASE("animation.decorator") "gradient(horizontal transparent transparent)", "gradient(horizontal white white)", - "gradient(horizontal rgba(255,255,255,63) rgba(255,255,255,63))", + "gradient(horizontal rgba(127,127,127,63) rgba(127,127,127,63))", }, { "", "", @@ -96,7 +96,7 @@ TEST_CASE("animation.decorator") "none", "gradient(horizontal transparent transparent)", - "gradient(horizontal rgba(255,255,255,191) rgba(255,255,255,191))", + "gradient(horizontal rgba(220,220,220,191) rgba(220,220,220,191))", }, { "", "", @@ -104,7 +104,7 @@ TEST_CASE("animation.decorator") "none", "gradient(horizontal transparent transparent), gradient(vertical transparent transparent)", - "gradient(horizontal rgba(255,255,255,191) rgba(255,255,255,191)), gradient(horizontal rgba(255,255,255,191) rgba(255,255,255,191))", + "gradient(horizontal rgba(220,220,220,191) rgba(220,220,220,191)), gradient(horizontal rgba(220,220,220,191) rgba(220,220,220,191))", }, { "", "", @@ -112,7 +112,7 @@ TEST_CASE("animation.decorator") "gradient(horizontal transparent transparent), gradient(vertical transparent transparent)", "none", - "gradient(horizontal rgba(255,255,255,63) rgba(255,255,255,63)), gradient(vertical rgba(255,255,255,63) rgba(255,255,255,63))", + "gradient(horizontal rgba(127,127,127,63) rgba(127,127,127,63)), gradient(vertical rgba(127,127,127,63) rgba(127,127,127,63))", }, /// Only rule declaration @@ -123,7 +123,7 @@ TEST_CASE("animation.decorator") "from_rule", "to_rule", - "gradient(horizontal rgba(255,255,255,63) rgba(255,255,255,63))", + "gradient(horizontal rgba(127,127,127,63) rgba(127,127,127,63))", }, { "", @@ -132,7 +132,7 @@ TEST_CASE("animation.decorator") "from_rule", "to_rule", - "gradient(horizontal rgba(255,255,255,191) rgba(255,255,255,191))", + "gradient(horizontal rgba(220,220,220,191) rgba(220,220,220,191))", }, { "direction: vertical; start-color: transparent; stop-color: transparent;", @@ -141,7 +141,7 @@ TEST_CASE("animation.decorator") "from_rule", "to_rule", - "gradient(vertical rgba(255,255,255,63) rgba(255,255,255,63))", + "gradient(vertical rgba(127,127,127,63) rgba(127,127,127,63))", }, /// Mix rule and standard declaration @@ -152,7 +152,7 @@ TEST_CASE("animation.decorator") "from_rule", "gradient(horizontal white white)", - "gradient(horizontal rgba(255,255,255,63) rgba(255,255,255,63))", + "gradient(horizontal rgba(127,127,127,63) rgba(127,127,127,63))", }, { "", @@ -161,7 +161,7 @@ TEST_CASE("animation.decorator") "none", "to_rule", - "gradient(horizontal rgba(255,255,255,191) rgba(255,255,255,191))", + "gradient(horizontal rgba(220,220,220,191) rgba(220,220,220,191))", }, { "direction: vertical; start-color: transparent; stop-color: transparent;", @@ -170,7 +170,7 @@ TEST_CASE("animation.decorator") "from_rule", "none", - "gradient(vertical rgba(255,255,255,63) rgba(255,255,255,63))", + "gradient(vertical rgba(127,127,127,63) rgba(127,127,127,63))", }, { "", "", @@ -178,7 +178,7 @@ TEST_CASE("animation.decorator") "from_rule, to_rule", "gradient(horizontal transparent transparent), gradient(vertical transparent transparent)", - "gradient(horizontal rgba(255,255,255,191) rgba(255,255,255,191)), gradient(horizontal rgba(255,255,255,191) rgba(255,255,255,191))", + "gradient(horizontal rgba(220,220,220,191) rgba(220,220,220,191)), gradient(horizontal rgba(220,220,220,191) rgba(220,220,220,191))", }, { "", "", @@ -186,7 +186,7 @@ TEST_CASE("animation.decorator") "gradient(horizontal transparent transparent), gradient(vertical transparent transparent)", "from_rule, to_rule", - "gradient(horizontal rgba(255,255,255,63) rgba(255,255,255,63)), gradient(vertical rgba(255,255,255,63) rgba(255,255,255,63))", + "gradient(horizontal rgba(127,127,127,63) rgba(127,127,127,63)), gradient(vertical rgba(127,127,127,63) rgba(127,127,127,63))", }, }; diff --git a/Tests/Source/UnitTests/Math.cpp b/Tests/Source/UnitTests/Math.cpp index 377ec8483..f7e644c40 100644 --- a/Tests/Source/UnitTests/Math.cpp +++ b/Tests/Source/UnitTests/Math.cpp @@ -32,7 +32,7 @@ using namespace Rml; -TEST_CASE("Math") +TEST_CASE("Math.RoundedLerp") { const Colourb c0(0, 0, 0, 255); const Colourb c1(255, 0, 0, 255); @@ -103,3 +103,54 @@ TEST_CASE("Math") REQUIRE(r2 == c2.red); } } + +TEST_CASE("Math.Clamp") +{ + // Clamp(Value, Min, Max) + CHECK(Math::Clamp(1, 1, 2) == 1); + CHECK(Math::Clamp(0, 1, 2) == 1); + CHECK(Math::Clamp(3, 1, 2) == 2); + + CHECK(Math::Clamp(0, 2, 1) == 2); + CHECK(Math::Clamp(3, 2, 1) == 1); + + CHECK(Math::Clamp({1, 1}, {1, 1}, {2, 2}) == Vector2i(1, 1)); + CHECK(Math::Clamp({0, 0}, {1, 1}, {2, 2}) == Vector2i(1, 1)); + CHECK(Math::Clamp({3, 3}, {1, 1}, {2, 2}) == Vector2i(2, 2)); + CHECK(Math::Clamp({1, 3}, {1, 1}, {2, 2}) == Vector2i(1, 2)); + CHECK(Math::Clamp({1, 1}, {2, 0}, {2, 0}) == Vector2i(2, 0)); + + CHECK(Math::Clamp({1, 1}, {1, 1}, {2, 2}) == Vector2f(1, 1)); + CHECK(Math::Clamp({0, 0}, {1, 1}, {2, 2}) == Vector2f(1, 1)); + CHECK(Math::Clamp({3, 3}, {1, 1}, {2, 2}) == Vector2f(2, 2)); + CHECK(Math::Clamp({1, 3}, {1, 1}, {2, 2}) == Vector2f(1, 2)); + CHECK(Math::Clamp({1, 1}, {2, 0}, {2, 0}) == Vector2f(2, 0)); +} + +TEST_CASE("Math.Min") +{ + CHECK(Math::Min(1, 2) == 1); + CHECK(Math::Min(2, 1) == 1); + + CHECK(Math::Min({1, 1}, {2, 2}) == Vector2i(1, 1)); + CHECK(Math::Min({2, 2}, {1, 1}) == Vector2i(1, 1)); + CHECK(Math::Min({2, 1}, {1, 2}) == Vector2i(1, 1)); + + CHECK(Math::Min({1, 1}, {2, 2}) == Vector2f(1, 1)); + CHECK(Math::Min({2, 2}, {1, 1}) == Vector2f(1, 1)); + CHECK(Math::Min({2, 1}, {1, 2}) == Vector2f(1, 1)); +} + +TEST_CASE("Math.Max") +{ + CHECK(Math::Max(1, 2) == 2); + CHECK(Math::Max(2, 1) == 2); + + CHECK(Math::Max({1, 1}, {2, 2}) == Vector2i(2, 2)); + CHECK(Math::Max({2, 2}, {1, 1}) == Vector2i(2, 2)); + CHECK(Math::Max({2, 1}, {1, 2}) == Vector2i(2, 2)); + + CHECK(Math::Max({1, 1}, {2, 2}) == Vector2f(2, 2)); + CHECK(Math::Max({2, 2}, {1, 1}) == Vector2f(2, 2)); + CHECK(Math::Max({2, 1}, {1, 2}) == Vector2f(2, 2)); +}