diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-09-03 09:38:51 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-09-03 09:38:51 +0900 |
commit | 1249262e97c1c3b1c91720f7acebb29abeb77b67 (patch) | |
tree | ffad409b7df3213a0d40734eefd832b2f701f492 /tools/qa | |
parent | eb2e1ab4651350bffc53f618961a910bd3bbcfd9 (diff) |
Change color test to report expected values when assert fails
Change-Id: I8383dd317a4f8af5f057d81d8e90172b1f78edde
Diffstat (limited to 'tools/qa')
-rw-r--r-- | tools/qa/cppunit/test_color.cxx | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/tools/qa/cppunit/test_color.cxx b/tools/qa/cppunit/test_color.cxx index a1847df716db..116ae5bb4942 100644 --- a/tools/qa/cppunit/test_color.cxx +++ b/tools/qa/cppunit/test_color.cxx @@ -78,24 +78,13 @@ void Test::test_readAndWriteStream() } } -bool checkTintShade(sal_uInt8 nR, sal_uInt8 nG, sal_uInt8 nB, OUString const & sReference, sal_Int16 nTintShade, OUString const & sExpected) +OUString createTintShade(sal_uInt8 nR, sal_uInt8 nG, sal_uInt8 nB, OUString const & sReference, sal_Int16 nTintShade) { Color aColor(nR, nG, nB); if (sReference != aColor.AsRGBHexString()) - { - fprintf(stderr, "FAILED: Input and reference color mismatch %s\n", - sReference.toUtf8().getStr()); - return false; - } + return OUString(""); aColor.ApplyTintOrShade(nTintShade); - if (sExpected != aColor.AsRGBHexString()) - { - fprintf(stderr, "FAILED: Reference color is %s which differs from expect %s\n", - sReference.toUtf8().getStr(), - sExpected.toUtf8().getStr()); - return false; - } - return true; + return aColor.AsRGBHexString(); } void Test::test_ApplyTintOrShade() @@ -103,47 +92,47 @@ void Test::test_ApplyTintOrShade() // BLACK reference // 5% tint - CPPUNIT_ASSERT(checkTintShade(0x00, 0x00, 0x00, "000000", 500, "0d0d0d")); + CPPUNIT_ASSERT_EQUAL(OUString("0d0d0d"), createTintShade(0x00, 0x00, 0x00, "000000", 500)); // 15% tint - CPPUNIT_ASSERT(checkTintShade(0x00, 0x00, 0x00, "000000", 1500, "262626")); + CPPUNIT_ASSERT_EQUAL(OUString("262626"), createTintShade(0x00, 0x00, 0x00, "000000", 1500)); // 25% tint - CPPUNIT_ASSERT(checkTintShade(0x00, 0x00, 0x00, "000000", 2500, "404040")); + CPPUNIT_ASSERT_EQUAL(OUString("404040"), createTintShade(0x00, 0x00, 0x00, "000000", 2500)); // 50% tint - CPPUNIT_ASSERT(checkTintShade(0x00, 0x00, 0x00, "000000", 5000, "808080")); + CPPUNIT_ASSERT_EQUAL(OUString("808080"), createTintShade(0x00, 0x00, 0x00, "000000", 5000)); // 100% tint - CPPUNIT_ASSERT(checkTintShade(0x00, 0x00, 0x00, "000000", 10000, "ffffff")); + CPPUNIT_ASSERT_EQUAL(OUString("ffffff"), createTintShade(0x00, 0x00, 0x00, "000000", 10000)); // WHITE reference // 5% shade - CPPUNIT_ASSERT(checkTintShade(0xff, 0xff, 0xff, "ffffff", -500, "f2f2f2")); + CPPUNIT_ASSERT_EQUAL(OUString("f2f2f2"), createTintShade(0xff, 0xff, 0xff, "ffffff", -500)); // 15% shade - CPPUNIT_ASSERT(checkTintShade(0xff, 0xff, 0xff, "ffffff", -1500, "d9d9d9")); + CPPUNIT_ASSERT_EQUAL(OUString("d9d9d9"), createTintShade(0xff, 0xff, 0xff, "ffffff", -1500)); // 25% shade - CPPUNIT_ASSERT(checkTintShade(0xff, 0xff, 0xff, "ffffff", -2500, "bfbfbf")); + CPPUNIT_ASSERT_EQUAL(OUString("bfbfbf"), createTintShade(0xff, 0xff, 0xff, "ffffff", -2500)); // 50% shade - CPPUNIT_ASSERT(checkTintShade(0xff, 0xff, 0xff, "ffffff", -5000, "808080")); + CPPUNIT_ASSERT_EQUAL(OUString("808080"), createTintShade(0xff, 0xff, 0xff, "ffffff", -5000)); // 100% shade - CPPUNIT_ASSERT(checkTintShade(0xff, 0xff, 0xff, "ffffff", -10000, "000000")); + CPPUNIT_ASSERT_EQUAL(OUString("000000"), createTintShade(0xff, 0xff, 0xff, "ffffff", -10000)); // GREY reference // 0% - no change - CPPUNIT_ASSERT(checkTintShade(0x80, 0x80, 0x80, "808080", 0, "808080")); + CPPUNIT_ASSERT_EQUAL(OUString("808080"), createTintShade(0x80, 0x80, 0x80, "808080", 0)); // 25% tint - CPPUNIT_ASSERT(checkTintShade(0x80, 0x80, 0x80, "808080", 2500, "a0a0a0")); + CPPUNIT_ASSERT_EQUAL(OUString("a0a0a0"), createTintShade(0x80, 0x80, 0x80, "808080", 2500)); // 50% tint - CPPUNIT_ASSERT(checkTintShade(0x80, 0x80, 0x80, "808080", 5000, "c0c0c0")); + CPPUNIT_ASSERT_EQUAL(OUString("c0c0c0"), createTintShade(0x80, 0x80, 0x80, "808080", 5000)); // 100% tint - CPPUNIT_ASSERT(checkTintShade(0x80, 0x80, 0x80, "808080", 10000, "ffffff")); + CPPUNIT_ASSERT_EQUAL(OUString("ffffff"), createTintShade(0x80, 0x80, 0x80, "808080", 10000)); // 25% shade - CPPUNIT_ASSERT(checkTintShade(0x80, 0x80, 0x80, "808080", -2500, "606060")); + CPPUNIT_ASSERT_EQUAL(OUString("606060"), createTintShade(0x80, 0x80, 0x80, "808080", -2500)); // 50% shade - CPPUNIT_ASSERT(checkTintShade(0x80, 0x80, 0x80, "808080", -5000, "404040")); + CPPUNIT_ASSERT_EQUAL(OUString("404040"), createTintShade(0x80, 0x80, 0x80, "808080", -5000)); // 100% shade - CPPUNIT_ASSERT(checkTintShade(0x80, 0x80, 0x80, "808080", -10000, "000000")); + CPPUNIT_ASSERT_EQUAL(OUString("000000"), createTintShade(0x80, 0x80, 0x80, "808080", -10000)); } |