Made tests for 6 rgb to hsb conversions

This commit is contained in:
Bob Polis 2021-08-18 12:26:53 +02:00
parent 4154624aa3
commit d961c280ed

View File

@ -1,8 +1,91 @@
#define BOOST_TEST_MODULE My Test #define BOOST_TEST_MODULE LibScreensaverTest
#define BOOST_TEST_DYN_LINK #define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "../../src/Color.hpp"
BOOST_AUTO_TEST_CASE(first_test) BOOST_AUTO_TEST_CASE(hsb2rgb_red_test) {
{ HSB hsb;
BOOST_TEST(1 == 1); 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);
} }