diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-02-07 15:50:44 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-02-07 15:50:44 +0100 |
commit | c5049234211816dbaa731f5a7a2c3eefcb35a374 (patch) | |
tree | a30813f89515e341c375e6fe9a05942751c39299 | |
parent | e5b062758950b0d6c5cea0a1914998433ef19774 (diff) |
Replace macro with function
Change-Id: Icb4488ea38b99a329a071063292db4001799ecc8
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport2.cxx | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx index 80b5bba9ad9f..a0bd7e490320 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx @@ -222,14 +222,13 @@ DECLARE_OOXMLEXPORT_TEST(testFdo51034, "fdo51034.odt") CPPUNIT_ASSERT_EQUAL(OUString("http://Www.google.com/#a"), getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkURL")); } -// Construct the expected formula from UTF8, as there may be such characters. // Remove all spaces, as LO export/import may change that. // Replace symbol - (i.e. U+2212) with ASCII - , LO does this change and it shouldn't matter. -#define CHECK_FORMULA( expected, actual ) \ - CPPUNIT_ASSERT_EQUAL( \ - OUString( expected, strlen( expected ), RTL_TEXTENCODING_UTF8 ) \ - .replaceAll( " ", "" ).replaceAll( OUString( "\xe2\x88\x92", strlen( "\xe2\x88\x92" ), RTL_TEXTENCODING_UTF8 ), "-" ), \ - OUString( actual ).replaceAll( " ", "" ).replaceAll( OUString( "\xe2\x88\x92", strlen( "\xe2\x88\x92" ), RTL_TEXTENCODING_UTF8 ), "-" )) +void CHECK_FORMULA(OUString const & expected, OUString const & actual) { + CPPUNIT_ASSERT_EQUAL( + expected.replaceAll( " ", "" ).replaceAll( OUString( "\xe2\x88\x92", strlen( "\xe2\x88\x92" ), RTL_TEXTENCODING_UTF8 ), "-" ), + actual.replaceAll( " ", "" ).replaceAll( OUString( "\xe2\x88\x92", strlen( "\xe2\x88\x92" ), RTL_TEXTENCODING_UTF8 ), "-" )); +} DECLARE_OOXMLEXPORT_TEST(testMathAccents, "math-accents.docx") { @@ -254,12 +253,12 @@ DECLARE_OOXMLEXPORT_TEST(testMathD, "math-d.docx") DECLARE_OOXMLEXPORT_TEST(testMathEscaping, "math-escaping.docx") { - CHECK_FORMULA( "\xe2\x88\x92 \xe2\x88\x9e < x < \xe2\x88\x9e", getFormula( getRun( getParagraph( 1 ), 1 ))); + CHECK_FORMULA( OUString::fromUtf8("\xe2\x88\x92 \xe2\x88\x9e < x < \xe2\x88\x9e"), getFormula( getRun( getParagraph( 1 ), 1 ))); } DECLARE_OOXMLEXPORT_TEST(testMathLim, "math-lim.docx") { - CHECK_FORMULA( "lim from {x \xe2\x86\x92 1} {x}", getFormula( getRun( getParagraph( 1 ), 1 ))); + CHECK_FORMULA( OUString::fromUtf8("lim from {x \xe2\x86\x92 1} {x}"), getFormula( getRun( getParagraph( 1 ), 1 ))); } DECLARE_OOXMLEXPORT_TEST(testMathMatrix, "math-matrix.docx") @@ -269,32 +268,32 @@ DECLARE_OOXMLEXPORT_TEST(testMathMatrix, "math-matrix.docx") DECLARE_OOXMLEXPORT_TEST(testMathMso2k7, "math-mso2k7.docx") { - CHECK_FORMULA( "A = \xcf\x80 {r} ^ {2}", getFormula( getRun( getParagraph( 1 ), 1 ))); + CHECK_FORMULA( OUString::fromUtf8("A = \xcf\x80 {r} ^ {2}"), getFormula( getRun( getParagraph( 1 ), 1 ))); // TODO check the stack/binom difference // CHECK_FORMULA( "{left (x+a right )} ^ {n} = sum from {k=0} to {n} {left (binom {n} {k} right ) {x} ^ {k} {a} ^ {n-k}}", CHECK_FORMULA( "{left (x+a right )} ^ {n} = sum from {k=0} to {n} {left (stack {n # k} right ) {x} ^ {k} {a} ^ {n-k}}", getFormula( getRun( getParagraph( 2 ), 1 ))); - CHECK_FORMULA( "{left (1+x right )} ^ {n} =1+ {nx} over {1!} + {n left (n-1 right ) {x} ^ {2}} over {2!} +\xe2\x80\xa6", + CHECK_FORMULA( OUString::fromUtf8("{left (1+x right )} ^ {n} =1+ {nx} over {1!} + {n left (n-1 right ) {x} ^ {2}} over {2!} +\xe2\x80\xa6"), getFormula( getRun( getParagraph( 3 ), 1 ))); // TODO check (cos/sin miss {}) // CHECK_FORMULA( "f left (x right ) = {a} rsub {0} + sum from {n=1} to {\xe2\x88\x9e} {left ({a} rsub {n} cos {{n\xcf\x80x} over {L}} + {b} rsub {n} sin {{n\xcf\x80x} over {L}} right )}", - CHECK_FORMULA( "f left (x right ) = {a} rsub {0} + sum from {n=1} to {\xe2\x88\x9e} {left ({a} rsub {n} cos {n\xcf\x80x} over {L} + {b} rsub {n} sin {n\xcf\x80x} over {L} right )}", + CHECK_FORMULA( OUString::fromUtf8("f left (x right ) = {a} rsub {0} + sum from {n=1} to {\xe2\x88\x9e} {left ({a} rsub {n} cos {n\xcf\x80x} over {L} + {b} rsub {n} sin {n\xcf\x80x} over {L} right )}"), getFormula( getRun( getParagraph( 4 ), 1 ))); CHECK_FORMULA( "{a} ^ {2} + {b} ^ {2} = {c} ^ {2}", getFormula( getRun( getParagraph( 5 ), 1 ))); - CHECK_FORMULA( "x = {- b \xc2\xb1 sqrt {{b} ^ {2} -4 ac}} over {2 a}", + CHECK_FORMULA( OUString::fromUtf8("x = {- b \xc2\xb1 sqrt {{b} ^ {2} -4 ac}} over {2 a}"), getFormula( getRun( getParagraph( 6 ), 1 ))); CHECK_FORMULA( - "{e} ^ {x} =1+ {x} over {1!} + {{x} ^ {2}} over {2!} + {{x} ^ {3}} over {3!} +\xe2\x80\xa6, -\xe2\x88\x9e<x<\xe2\x88\x9e", + OUString::fromUtf8("{e} ^ {x} =1+ {x} over {1!} + {{x} ^ {2}} over {2!} + {{x} ^ {3}} over {3!} +\xe2\x80\xa6, -\xe2\x88\x9e<x<\xe2\x88\x9e"), getFormula( getRun( getParagraph( 7 ), 1 ))); CHECK_FORMULA( // "sin {\xce\xb1} \xc2\xb1 sin {\xce\xb2} =2 sin {{1} over {2} left (\xce\xb1\xc2\xb1\xce\xb2 right )} cos {{1} over {2} left (\xce\xb1\xe2\x88\x93\xce\xb2 right )}", // TODO check (cos/in miss {}) - "sin \xce\xb1 \xc2\xb1 sin \xce\xb2 =2 sin {1} over {2} left (\xce\xb1\xc2\xb1\xce\xb2 right ) cos {1} over {2} left (\xce\xb1\xe2\x88\x93\xce\xb2 right )", + OUString::fromUtf8("sin \xce\xb1 \xc2\xb1 sin \xce\xb2 =2 sin {1} over {2} left (\xce\xb1\xc2\xb1\xce\xb2 right ) cos {1} over {2} left (\xce\xb1\xe2\x88\x93\xce\xb2 right )"), getFormula( getRun( getParagraph( 8 ), 1 ))); CHECK_FORMULA( // "cos {\xce\xb1} + cos {\xce\xb2} =2 cos {{1} over {2} left (\xce\xb1+\xce\xb2 right )} cos {{1} over {2} left (\xce\xb1-\xce\xb2 right )}", // TODO check (cos/sin miss {}) - "cos \xce\xb1 + cos \xce\xb2 =2 cos {1} over {2} left (\xce\xb1+\xce\xb2 right ) cos {1} over {2} left (\xce\xb1-\xce\xb2 right )", + OUString::fromUtf8("cos \xce\xb1 + cos \xce\xb2 =2 cos {1} over {2} left (\xce\xb1+\xce\xb2 right ) cos {1} over {2} left (\xce\xb1-\xce\xb2 right )"), getFormula( getRun( getParagraph( 9 ), 1 ))); } @@ -617,7 +616,7 @@ DECLARE_OOXMLEXPORT_TEST(testTableStylerPrSz, "table-style-rPr-sz.docx") DECLARE_OOXMLEXPORT_TEST(testMathLiteral, "math-literal.docx") { - CHECK_FORMULA( "iiint from {V} to <?> {\"div\" \"F\"} dV= llint from {S} to <?> {\"F\" \xe2\x88\x99 \"n \" dS}", + CHECK_FORMULA( OUString::fromUtf8("iiint from {V} to <?> {\"div\" \"F\"} dV= llint from {S} to <?> {\"F\" \xe2\x88\x99 \"n \" dS}"), getFormula( getRun( getParagraph( 1 ), 1 ))); } |