[Libreoffice-commits] core.git: tools/qa

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Wed Sep 2 17:39:29 PDT 2015


 tools/qa/cppunit/test_color.cxx |   51 +++++++++++++++-------------------------
 1 file changed, 20 insertions(+), 31 deletions(-)

New commits:
commit 1249262e97c1c3b1c91720f7acebb29abeb77b67
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Sep 3 09:38:51 2015 +0900

    Change color test to report expected values when assert fails
    
    Change-Id: I8383dd317a4f8af5f057d81d8e90172b1f78edde

diff --git a/tools/qa/cppunit/test_color.cxx b/tools/qa/cppunit/test_color.cxx
index a1847df..116ae5b 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));
 
 }
 


More information about the Libreoffice-commits mailing list