diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-04-22 10:57:39 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-04-22 05:51:35 +0200 |
commit | 60de1cb01986ff6c9aba58dc05dec6b3dc2402d4 (patch) | |
tree | e720f4709b235404e85bf39c5ef95bcc006725d6 /tools | |
parent | bb6906b66d7ceac8465b43d7e2b1f05976d43600 (diff) |
Replace compile time test with a static_assert
There is no need to check this in a test when we can do it
directly in the header. static_assert will complain when compiling
something that uses the header file instead of waiting that it
finds a piece of code, where it is actually needed. The purpose of
the test was the same (fail early).
The main problem was that Color can be created and converted to
sal_uInt32 string completely in compile time, so it can be used for
"case" in a "switch" statement, which requires that in "case" it
uses a constant. Normally this isn't possible unless we resolve
and convert a Color to sal_uInt32 in compile time.
This use-case is used somewhere in the code, but it takes a lot
of (re)compiling to get to that piece of code, where it would
eventually fail.
Change-Id: I1f1f9b77c19a0e61f78ce703b380d98a569da833
Reviewed-on: https://gerrit.libreoffice.org/71060
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qa/cppunit/test_color.cxx | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/tools/qa/cppunit/test_color.cxx b/tools/qa/cppunit/test_color.cxx index 571a1f37291d..8ecf03572295 100644 --- a/tools/qa/cppunit/test_color.cxx +++ b/tools/qa/cppunit/test_color.cxx @@ -21,7 +21,6 @@ namespace class Test: public CppUnit::TestFixture { public: - void testConstruction(); void testVariables(); void test_asRGBColor(); void test_readAndWriteStream(); @@ -31,7 +30,6 @@ public: void testBColor(); CPPUNIT_TEST_SUITE(Test); - CPPUNIT_TEST(testConstruction); CPPUNIT_TEST(testVariables); CPPUNIT_TEST(test_asRGBColor); CPPUNIT_TEST(test_readAndWriteStream); @@ -42,24 +40,6 @@ public: CPPUNIT_TEST_SUITE_END(); }; -void Test::testConstruction() -{ - // Compile time construction of the Color and representation as a sal_uInt32 - - Color aColor = Color(0xFF, 0xFF, 0x00); - - switch (sal_uInt32(aColor)) - { - case sal_uInt32(Color(0xFF, 0xFF, 0x00)): - break; - case sal_uInt32(Color(0x00, 0x00, 0xFF, 0xFF)): - break; - default: - CPPUNIT_ASSERT(false); - break; - } -} - void Test::testVariables() { Color aColor(0x44, 0x88, 0xAA); |