diff --git a/tests/src/main.cpp b/tests/src/main.cpp index 533ab2a..3ad669c 100644 --- a/tests/src/main.cpp +++ b/tests/src/main.cpp @@ -1,8 +1,91 @@ -#define BOOST_TEST_MODULE My Test +#define BOOST_TEST_MODULE LibScreensaverTest #define BOOST_TEST_DYN_LINK #include +#include "../../src/Color.hpp" -BOOST_AUTO_TEST_CASE(first_test) -{ - BOOST_TEST(1 == 1); +BOOST_AUTO_TEST_CASE(hsb2rgb_red_test) { + HSB hsb; + hsb.h = 0.0; // red + hsb.s = 1.0; + hsb.b = 1.0; + + Color col {hsb}; + RGB rgb {RGB(col)}; + + BOOST_TEST(rgb.r == 1.0); + BOOST_TEST(rgb.g == 0.0); + BOOST_TEST(rgb.b == 0.0); +} + +BOOST_AUTO_TEST_CASE(hsb2rgb_yellow_test) { + HSB hsb; + hsb.h = 60.0; // yellow + hsb.s = 1.0; + hsb.b = 1.0; + + Color col {hsb}; + RGB rgb {RGB(col)}; + + // yellow = red + green + BOOST_TEST(rgb.r == 1.0); + BOOST_TEST(rgb.g == 1.0); + BOOST_TEST(rgb.b == 0.0); +} + +BOOST_AUTO_TEST_CASE(hsb2rgb_green_test) { + HSB hsb; + hsb.h = 120.0; // green + hsb.s = 1.0; + hsb.b = 1.0; + + Color col {hsb}; + RGB rgb {RGB(col)}; + + BOOST_TEST(rgb.r == 0.0); + BOOST_TEST(rgb.g == 1.0); + BOOST_TEST(rgb.b == 0.0); +} + +BOOST_AUTO_TEST_CASE(hsb2rgb_cyan_test) { + HSB hsb; + hsb.h = 180.0; // + hsb.s = 1.0; + hsb.b = 1.0; + + Color col {hsb}; + RGB rgb {RGB(col)}; + + // cyan = green + blue + BOOST_TEST(rgb.r == 0.0); + BOOST_TEST(rgb.g == 1.0); + BOOST_TEST(rgb.b == 1.0); +} + +BOOST_AUTO_TEST_CASE(hsb2rgb_blue_test) { + HSB hsb; + hsb.h = 240.0; // blue + hsb.s = 1.0; + hsb.b = 1.0; + + Color col {hsb}; + RGB rgb {RGB(col)}; + + BOOST_TEST(rgb.r == 0.0); + BOOST_TEST(rgb.g == 0.0); + BOOST_TEST(rgb.b == 1.0); +} + +BOOST_AUTO_TEST_CASE(hsb2rgb_magenta_test) { + HSB hsb; + hsb.h = 300.0; // magenta + hsb.s = 1.0; + hsb.b = 1.0; + + Color col {hsb}; + RGB rgb {RGB(col)}; + + // magenta = red + blue + BOOST_TEST(rgb.r == 1.0); + BOOST_TEST(rgb.g == 0.0); + BOOST_TEST(rgb.b == 1.0); }