Skip to content

Commit 1942376

Browse files
committed
Color saturation tests
1 parent e3460ab commit 1942376

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if(PROJECT_IS_TOP_LEVEL OR NOT LANGULUS)
1010
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
1111
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
1212
include(LangulusUtilities.cmake)
13-
fetch_langulus_module(Flow GIT_TAG d2167a978c03f8673e2172154cf85e8d327718b3)
13+
fetch_langulus_module(Flow GIT_TAG 6da2f1a3c8b5cc32e9291cfefdd69b4b71ffce2e)
1414
endif()
1515

1616
file(GLOB_RECURSE

test/TestColors.cpp

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@
1212
TEMPLATE_TEST_CASE("Colors", "[color]",
1313
RGB24,
1414
RGBA32,
15-
RGBA,
16-
RGB,
1715
RGB96,
18-
RGBA128,
19-
RGBAf,
20-
RGBf
16+
RGBA128
2117
) {
2218
using Anyness::Text;
2319
using Flow::Code;
@@ -434,3 +430,30 @@ TEMPLATE_TEST_CASE("Colors", "[color]",
434430
}
435431
}
436432
}
433+
434+
TEMPLATE_TEST_CASE("Testing color saturation arithmetic", "[color]",
435+
RGB24,
436+
RGBA32
437+
) {
438+
using T = TestType;
439+
440+
GIVEN("Two colors") {
441+
T x {255, 0, 0, 255};
442+
T y {255, 0, 0, 255};
443+
444+
WHEN("Adding the colors (commutative, saturated)") {
445+
REQUIRE((x + y) == T {255, 0, 0, 255});
446+
REQUIRE((y + x) == T {255, 0, 0, 255});
447+
}
448+
449+
WHEN("Subtracting the colors (saturated)") {
450+
REQUIRE((x - y) == T {0, 0, 0, 0});
451+
REQUIRE((y - x) == T {0, 0, 0, 0});
452+
}
453+
454+
WHEN("Multiplying the colors (commutative, saturated)") {
455+
REQUIRE((x * y) == T {255, 0, 0, 255});
456+
REQUIRE((y * x) == T {255, 0, 0, 255});
457+
}
458+
}
459+
}

0 commit comments

Comments
 (0)