1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is part of the libqxp project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10 #include <cppunit/TestFixture.h>
11 #include <cppunit/extensions/HelperMacros.h>
12
13 #include <string>
14
15 #include "QXPTypes.h"
16
17 namespace test
18 {
19
20 using libqxp::Color;
21
22 using std::string;
23
24 class QXPTypesTest : public CPPUNIT_NS::TestFixture
25 {
26 public:
27 virtual void setUp() override;
28 virtual void tearDown() override;
29
30 private:
31 CPPUNIT_TEST_SUITE(QXPTypesTest);
32 CPPUNIT_TEST(testColorShade);
33 CPPUNIT_TEST_SUITE_END();
34
35 private:
36 void testColorShade();
37 };
38
setUp()39 void QXPTypesTest::setUp()
40 {
41 }
42
tearDown()43 void QXPTypesTest::tearDown()
44 {
45 }
46
testColorShade()47 void QXPTypesTest::testColorShade()
48 {
49 CPPUNIT_ASSERT_EQUAL(string(Color(1, 160, 198).toString().cstr()), string(Color(1, 160, 198).applyShade(1.0).toString().cstr()));
50 CPPUNIT_ASSERT_EQUAL(string(Color(255, 255, 255).toString().cstr()), string(Color(1, 160, 198).applyShade(0.0).toString().cstr()));
51 CPPUNIT_ASSERT_EQUAL(string(Color(179, 227, 238).toString().cstr()), string(Color(1, 160, 198).applyShade(0.3).toString().cstr()));
52 CPPUNIT_ASSERT_EQUAL(string(Color(1, 160, 198).toString().cstr()), string(Color(1, 160, 198).applyShade(99.8).toString().cstr()));
53 CPPUNIT_ASSERT_EQUAL(string(Color(1, 160, 198).toString().cstr()), string(Color(1, 160, 198).applyShade(-99.8).toString().cstr()));
54 }
55
56 CPPUNIT_TEST_SUITE_REGISTRATION(QXPTypesTest);
57
58 }
59
60 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
61