[Libreoffice-commits] .: Branch 'feature/gsoc_test_improvements3' - 4 commits - sax/qa
Artur Dorda
adorda at kemper.freedesktop.org
Thu Aug 9 13:42:51 PDT 2012
sax/qa/cppunit/test_converter.cxx | 61 ++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
New commits:
commit cc77be47187d9cb624b527933caedbfc4c35ec2c
Author: Artur Dorda <artur.dorda+libo at gmail.com>
Date: Thu Aug 9 22:42:09 2012 +0200
'measure to string' test covered in test_converter.cxx
Change-Id: If764eb4d87db93dc2907bc21fb1b9f10687a7ee4
diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx
index a95d1be..ad146e2 100644
--- a/sax/qa/cppunit/test_converter.cxx
+++ b/sax/qa/cppunit/test_converter.cxx
@@ -333,6 +333,7 @@ void doTestMeasureToString(char const*const pis, sal_Int32 nMeasure, sal_Int16 c
void ConverterTest::testMeasure()
{
+ //check all the measure units
doTestStringToMeasure(1000, "10mm", MeasureUnit::MM_100TH, -1, 4321);
doTestStringToMeasure(200, "20mm", MeasureUnit::MM_10TH, 12, 4567);
doTestStringToMeasure(300, "300", MeasureUnit::MM, 31, 555);
@@ -353,7 +354,22 @@ void ConverterTest::testMeasure()
doTestStringToMeasure(600, "600px", MeasureUnit::PIXEL, 10, 4321);
doTestStringToMeasure(777, "777", MeasureUnit::APPFONT, 10, 4321);
doTestStringToMeasure(80000, "80000", MeasureUnit::SYSFONT, 10, 432100);
- doTestMeasureToString("60mm", 6000, MeasureUnit::MM_100TH, MeasureUnit::MM_10TH);
+ //strange values (negative, too large etc.)
+ doTestStringToMeasure(-539222987, "1234567890mm", MeasureUnit::MM_10TH, 12, 12345678901);
+ doTestStringToMeasure(-300, "-300", MeasureUnit::MM, -1000, 555);
+ doTestStringToMeasure(1305424328, "-999999999999999px", MeasureUnit::PIXEL, -88888888888, 555); //really crazy numbers...
+
+ doTestMeasureToString("6mm", 600, MeasureUnit::MM_100TH, MeasureUnit::MM);
+ doTestMeasureToString("0.005cm", 000000005, MeasureUnit::MM_100TH, MeasureUnit::CM); // zeros in the front doesn't count
+ doTestMeasureToString("3mm", 30, MeasureUnit::MM_10TH, MeasureUnit::MM);
+ doTestMeasureToString("6.66cm", 666, MeasureUnit::MM_10TH, MeasureUnit::CM);
+ doTestMeasureToString("-157.3pt", -555, MeasureUnit::MM_10TH, MeasureUnit::POINT);
+ doTestMeasureToString("174976.378in", 44444000, MeasureUnit::MM_10TH, MeasureUnit::INCH); //let's check accuracy
+ doTestMeasureToString("40%", 40, MeasureUnit::PERCENT, MeasureUnit::PERCENT);
+ doTestMeasureToString("70.56mm", 4000, MeasureUnit::TWIP, MeasureUnit::MM);
+ doTestMeasureToString("979.928cm", 555550, MeasureUnit::TWIP, MeasureUnit::CM);
+ doTestMeasureToString("111.1pt", 2222, MeasureUnit::TWIP, MeasureUnit::POINT);
+ doTestMeasureToString("385.7986in", 555550, MeasureUnit::TWIP, MeasureUnit::INCH);
}
CPPUNIT_TEST_SUITE_REGISTRATION(ConverterTest);
commit ad5a002cb882cb57ee13722df078a22666ccf9fa
Author: Artur Dorda <artur.dorda+libo at gmail.com>
Date: Thu Aug 9 13:12:44 2012 +0200
Added testing 'measure to string' function
Change-Id: I36de98025ec72230cd960191ab47ab39ce965cc5
diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx
index 55d3749..a95d1be 100644
--- a/sax/qa/cppunit/test_converter.cxx
+++ b/sax/qa/cppunit/test_converter.cxx
@@ -322,6 +322,15 @@ void doTestStringToMeasure(sal_Int32 rValue, char const*const pis, sal_Int16 nTa
CPPUNIT_ASSERT_EQUAL(rValue, nVal);
}
+void doTestMeasureToString(char const*const pis, sal_Int32 nMeasure, sal_Int16 const nSourceUnit, sal_Int16 const nTargetUnit)
+{
+ ::rtl::OUString const is(::rtl::OUString::createFromAscii(pis));
+ ::rtl::OUStringBuffer buf;
+ Converter::convertMeasure(buf, nMeasure, nSourceUnit, nTargetUnit);
+ OSL_TRACE("%s", ::rtl::OUStringToOString(buf.getStr(), RTL_TEXTENCODING_UTF8).getStr());
+ CPPUNIT_ASSERT_EQUAL(is, buf.makeStringAndClear());
+}
+
void ConverterTest::testMeasure()
{
doTestStringToMeasure(1000, "10mm", MeasureUnit::MM_100TH, -1, 4321);
@@ -344,6 +353,7 @@ void ConverterTest::testMeasure()
doTestStringToMeasure(600, "600px", MeasureUnit::PIXEL, 10, 4321);
doTestStringToMeasure(777, "777", MeasureUnit::APPFONT, 10, 4321);
doTestStringToMeasure(80000, "80000", MeasureUnit::SYSFONT, 10, 432100);
+ doTestMeasureToString("60mm", 6000, MeasureUnit::MM_100TH, MeasureUnit::MM_10TH);
}
CPPUNIT_TEST_SUITE_REGISTRATION(ConverterTest);
commit dab32b53652ab3a4c5108a7e3bf5df1590dd810e
Author: Artur Dorda <artur.dorda+libo at gmail.com>
Date: Thu Aug 9 01:41:22 2012 +0200
All the MeasureUnit values are covered in converter test
Change-Id: I6c447bb3948566ad10d9935397089ed1fceac1da
diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx
index aca9976..55d3749 100644
--- a/sax/qa/cppunit/test_converter.cxx
+++ b/sax/qa/cppunit/test_converter.cxx
@@ -324,7 +324,26 @@ void doTestStringToMeasure(sal_Int32 rValue, char const*const pis, sal_Int16 nTa
void ConverterTest::testMeasure()
{
- doTestStringToMeasure(1000, "10mm", MeasureUnit::MM_100TH, 1, 4321);
+ doTestStringToMeasure(1000, "10mm", MeasureUnit::MM_100TH, -1, 4321);
+ doTestStringToMeasure(200, "20mm", MeasureUnit::MM_10TH, 12, 4567);
+ doTestStringToMeasure(300, "300", MeasureUnit::MM, 31, 555);
+ doTestStringToMeasure(400, "400", MeasureUnit::CM, 10, 4321);
+ doTestStringToMeasure(120, "120", MeasureUnit::INCH_1000TH, 10, 4321);
+ doTestStringToMeasure(111, "111", MeasureUnit::INCH_100TH, 10, 4321);
+ doTestStringToMeasure(22, "22", MeasureUnit::INCH_10TH, 10, 4321);
+ doTestStringToMeasure(27, "27", MeasureUnit::INCH, 10, 4321);
+ doTestStringToMeasure(52, "52", MeasureUnit::POINT, 10, 4321);
+ doTestStringToMeasure(120, "120", MeasureUnit::TWIP, 10, 4321);
+ doTestStringToMeasure(666, "666", MeasureUnit::M, 10, 4321);
+ doTestStringToMeasure(42, "42", MeasureUnit::KM, 10, 4321);
+ doTestStringToMeasure(30, "30", MeasureUnit::PICA, 10, 4321);
+ doTestStringToMeasure(20, "20", MeasureUnit::FOOT, 10, 4321);
+ doTestStringToMeasure(40, "40", MeasureUnit::MILE, 10, 4321);
+ doTestStringToMeasure(40, "40%", MeasureUnit::PERCENT, 10, 4321);
+ doTestStringToMeasure(800, "800", MeasureUnit::PIXEL, 10, 4321);
+ doTestStringToMeasure(600, "600px", MeasureUnit::PIXEL, 10, 4321);
+ doTestStringToMeasure(777, "777", MeasureUnit::APPFONT, 10, 4321);
+ doTestStringToMeasure(80000, "80000", MeasureUnit::SYSFONT, 10, 432100);
}
CPPUNIT_TEST_SUITE_REGISTRATION(ConverterTest);
commit 64d258b35a7bcde98c8637e6e222653649b6633e
Author: Artur Dorda <artur.dorda+libo at gmail.com>
Date: Thu Aug 9 01:09:25 2012 +0200
Started testing measures in converter test, first: string to measure
Change-Id: I96296b75d7c1f131a96add9dd17dfbffa079e343
diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx
index 1a33915..aca9976 100644
--- a/sax/qa/cppunit/test_converter.cxx
+++ b/sax/qa/cppunit/test_converter.cxx
@@ -50,11 +50,13 @@ public:
void testDuration();
void testDateTime();
void testDouble();
+ void testMeasure();
CPPUNIT_TEST_SUITE(ConverterTest);
CPPUNIT_TEST(testDuration);
CPPUNIT_TEST(testDateTime);
CPPUNIT_TEST(testDouble);
+ CPPUNIT_TEST(testMeasure);
CPPUNIT_TEST_SUITE_END();
private:
@@ -310,6 +312,20 @@ void ConverterTest::testDouble()
doTestDouble("700", 70.0, MeasureUnit::MM_100TH, MeasureUnit::MM_10TH);
}
+void doTestStringToMeasure(sal_Int32 rValue, char const*const pis, sal_Int16 nTargetUnit, sal_Int32 nMin, sal_Int32 nMax)
+{
+ ::rtl::OUString const is(::rtl::OUString::createFromAscii(pis));
+ sal_Int32 nVal;
+ bool bSuccess(Converter::convertMeasure(nVal, is, nTargetUnit, nMin, nMax));
+ OSL_TRACE("%i", nVal);
+ CPPUNIT_ASSERT(bSuccess);
+ CPPUNIT_ASSERT_EQUAL(rValue, nVal);
+}
+
+void ConverterTest::testMeasure()
+{
+ doTestStringToMeasure(1000, "10mm", MeasureUnit::MM_100TH, 1, 4321);
+}
CPPUNIT_TEST_SUITE_REGISTRATION(ConverterTest);
}
More information about the Libreoffice-commits
mailing list