From 8f88e0ea02fd2e7f07ae509e31fd9e3f4a105746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 16 Dec 2016 09:30:21 +0100 Subject: [PATCH] Math: improve Color::red() etc. test. Testing both floats and integer colors. --- src/Magnum/Math/Test/ColorTest.cpp | 55 ++++++++++++++++++------------ 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/src/Magnum/Math/Test/ColorTest.cpp b/src/Magnum/Math/Test/ColorTest.cpp index af3473fb7..82a779060 100644 --- a/src/Magnum/Math/Test/ColorTest.cpp +++ b/src/Magnum/Math/Test/ColorTest.cpp @@ -328,34 +328,47 @@ void ColorTest::literals() { } void ColorTest::colors() { - CORRADE_COMPARE(Color3ub::red(75), Color3ub(75, 0, 0)); - CORRADE_COMPARE(Color3ub::green(75), Color3ub(0, 75, 0)); - CORRADE_COMPARE(Color3ub::blue(75), Color3ub(0, 0, 75)); + CORRADE_COMPARE(Color3::red(0.289f), (Color3{0.289f, 0.0f, 0.0f})); + CORRADE_COMPARE(Color3::green(0.289f), (Color3{0.0f, 0.289f, 0.0f})); + CORRADE_COMPARE(Color3::blue(0.289f), (Color3{0.0f, 0.0f, 0.289f})); - CORRADE_COMPARE(Color3ub::cyan(75), Color3ub(75, 255, 255)); - CORRADE_COMPARE(Color3ub::magenta(75), Color3ub(255, 75, 255)); - CORRADE_COMPARE(Color3ub::yellow(75), Color3ub(255, 255, 75)); + CORRADE_COMPARE(Color3::cyan(0.289f), (Color3{0.289f, 1.0f, 1.0f})); + CORRADE_COMPARE(Color3::magenta(0.289f), (Color3{1.0f, 0.289f, 1.0f})); + CORRADE_COMPARE(Color3::yellow(0.289f), (Color3{1.0f, 1.0f, 0.289f})); - CORRADE_COMPARE(Color4ub::red(75, 138), Color4ub(75, 0, 0, 138)); - CORRADE_COMPARE(Color4ub::green(75, 138), Color4ub(0, 75, 0, 138)); - CORRADE_COMPARE(Color4ub::blue(75, 138), Color4ub(0, 0, 75, 138)); + CORRADE_COMPARE(Color4::red(0.289f, 0.47f), (Color4{0.289f, 0.0f, 0.0f, 0.47f})); + CORRADE_COMPARE(Color4::green(0.289f, 0.47f), (Color4{0.0f, 0.289f, 0.0f, 0.47f})); + CORRADE_COMPARE(Color4::blue(0.289f, 0.47f), (Color4{0.0f, 0.0f, 0.289f, 0.47f})); - CORRADE_COMPARE(Color4ub::cyan(75, 138), Color4ub(75, 255, 255, 138)); - CORRADE_COMPARE(Color4ub::magenta(75, 138), Color4ub(255, 75, 255, 138)); - CORRADE_COMPARE(Color4ub::yellow(75, 138), Color4ub(255, 255, 75, 138)); + CORRADE_COMPARE(Color4::cyan(0.289f, 0.47f), (Color4{0.289f, 1.0f, 1.0f, 0.47f})); + CORRADE_COMPARE(Color4::magenta(0.289f, 0.47f), (Color4{1.0f, 0.289f, 1.0f, 0.47f})); + CORRADE_COMPARE(Color4::yellow(0.289f, 0.47f), (Color4{1.0f, 1.0f, 0.289f, 0.47f})); /* Default values */ - CORRADE_COMPARE(Color3ub::red(), Color3ub(255, 0, 0)); - CORRADE_COMPARE(Color3ub::green(), Color3ub(0, 255, 0)); - CORRADE_COMPARE(Color3ub::blue(), Color3ub(0, 0, 255)); + CORRADE_COMPARE(Color3::red(), (Color3{1.0f, 0.0f, 0.0f})); + CORRADE_COMPARE(Color3::green(), (Color3{0.0f, 1.0f, 0.0f})); + CORRADE_COMPARE(Color3::blue(), (Color3{0.0f, 0.0f, 1.0f})); - CORRADE_COMPARE(Color4ub::red(), Color4ub(255, 0, 0, 255)); - CORRADE_COMPARE(Color4ub::green(), Color4ub(0, 255, 0, 255)); - CORRADE_COMPARE(Color4ub::blue(), Color4ub(0, 0, 255, 255)); + CORRADE_COMPARE(Color4::red(), (Color4{1.0f, 0.0f, 0.0f, 1.0f})); + CORRADE_COMPARE(Color4::green(), (Color4{0.0f, 1.0f, 0.0f, 1.0f})); + CORRADE_COMPARE(Color4::blue(), (Color4{0.0f, 0.0f, 1.0f, 1.0f})); - CORRADE_COMPARE(Color4ub::cyan(), Color4ub(0, 255, 255, 255)); - CORRADE_COMPARE(Color4ub::magenta(), Color4ub(255, 0, 255, 255)); - CORRADE_COMPARE(Color4ub::yellow(), Color4ub(255, 255, 0, 255)); + CORRADE_COMPARE(Color4::cyan(), (Color4{0.0f, 1.0f, 1.0f, 1.0f})); + CORRADE_COMPARE(Color4::magenta(), (Color4{1.0f, 0.0f, 1.0f, 1.0f})); + CORRADE_COMPARE(Color4::yellow(), (Color4{1.0f, 1.0f, 0.0f, 1.0f})); + + /* Integral */ + CORRADE_COMPARE(Math::Color3::red(), (Math::Color3{65535, 0, 0})); + CORRADE_COMPARE(Math::Color3::green(), (Math::Color3{0, 65535, 0})); + CORRADE_COMPARE(Math::Color3::blue(), (Math::Color3{0, 0, 65535})); + + CORRADE_COMPARE(Math::Color4::red(), (Math::Color4{65535, 0, 0, 65535})); + CORRADE_COMPARE(Math::Color4::green(), (Math::Color4{0, 65535, 0, 65535})); + CORRADE_COMPARE(Math::Color4::blue(), (Math::Color4{0, 0, 65535, 65535})); + + CORRADE_COMPARE(Math::Color4::cyan(), (Math::Color4{0, 65535, 65535, 65535})); + CORRADE_COMPARE(Math::Color4::magenta(), (Math::Color4{65535, 0, 65535, 65535})); + CORRADE_COMPARE(Math::Color4::yellow(), (Math::Color4{65535, 65535, 0, 65535})); } void ColorTest::hue() {