diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-02-08 07:48:59 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-02-08 09:15:01 +0100 |
commit | 6b00d0576a310796590631d14c54d7d5ea6814ac (patch) | |
tree | 2e11a4454592be39cfeaa68458cae964d8cdef5e /i18npool/qa/cppunit | |
parent | 17149f65f03a34e88bb4a10abcd20e6891f5d7ca (diff) |
Improve loplugin:cppunitassertequal for CPPUNIT_ASSERT(a && b)
...by re-enabling the code temporarily #if'ed-out in
a528392e71bc70136021be4e3d83732fccbb885e "Fixed/improved
loplugin:cppunitassertequals" (and which then triggers lots of other
lopglugin:cppunitassertequal CPPUNIT_ASSERT -> CPPUNIT_ASSERT_EQUAL warnings).
For two css::uno::Reference equality comparisons in cppu/qa/test_any.cxx, it
was more straightforward to rewrite them with an explicit call to operator ==
(which silences loplugin:cppunitassertequal) than to adapt them to
CPPUNIT_ASSERT_EQUAL's requirement for arguments of identical types.
In sc/qa/unit/ucalc_pivottable.cxx, ScDPItemData needs toString, which has been
implemented trivially for now, but might want to combine that with the
DEBUG_PIVOT_TABLE-only ScDPItemData::Dump.
Change-Id: Iae6d09cf69bd4e52fe4411bba9e50c48e696291c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110546
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'i18npool/qa/cppunit')
-rw-r--r-- | i18npool/qa/cppunit/test_breakiterator.cxx | 93 | ||||
-rw-r--r-- | i18npool/qa/cppunit/test_characterclassification.cxx | 10 | ||||
-rw-r--r-- | i18npool/qa/cppunit/test_textsearch.cxx | 69 |
3 files changed, 115 insertions, 57 deletions
diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx index 2e7dde17e937..91b9a0acbe03 100644 --- a/i18npool/qa/cppunit/test_breakiterator.cxx +++ b/i18npool/qa/cppunit/test_breakiterator.cxx @@ -181,28 +181,33 @@ void TestBreakIterator::testWordBoundaries() CPPUNIT_ASSERT(!m_xBreak->isBeginWord(aTest, 4, aLocale, i18n::WordType::DICTIONARY_WORD)); CPPUNIT_ASSERT(m_xBreak->isEndWord(aTest, 4, aLocale, i18n::WordType::DICTIONARY_WORD)); aBounds = m_xBreak->getWordBoundary(aTest, 4, aLocale, i18n::WordType::DICTIONARY_WORD, true); - CPPUNIT_ASSERT(aBounds.startPos == 0 && aBounds.endPos == 4); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aBounds.endPos); CPPUNIT_ASSERT(!m_xBreak->isBeginWord(aTest, 8, aLocale, i18n::WordType::DICTIONARY_WORD)); CPPUNIT_ASSERT(!m_xBreak->isEndWord(aTest, 8, aLocale, i18n::WordType::DICTIONARY_WORD)); //next word aBounds = m_xBreak->getWordBoundary(aTest, 8, aLocale, i18n::WordType::DICTIONARY_WORD, true); - CPPUNIT_ASSERT(aBounds.startPos == 9 && aBounds.endPos == 12); + CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(12), aBounds.endPos); //previous word aBounds = m_xBreak->getWordBoundary(aTest, 8, aLocale, i18n::WordType::DICTIONARY_WORD, false); - CPPUNIT_ASSERT(aBounds.startPos == 5 && aBounds.endPos == 7); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7), aBounds.endPos); CPPUNIT_ASSERT(!m_xBreak->isBeginWord(aTest, 12, aLocale, i18n::WordType::DICTIONARY_WORD)); CPPUNIT_ASSERT(m_xBreak->isEndWord(aTest, 12, aLocale, i18n::WordType::DICTIONARY_WORD)); aBounds = m_xBreak->getWordBoundary(aTest, 12, aLocale, i18n::WordType::DICTIONARY_WORD, true); - CPPUNIT_ASSERT(aBounds.startPos == 9 && aBounds.endPos == 12); + CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(12), aBounds.endPos); CPPUNIT_ASSERT(m_xBreak->isBeginWord(aTest, 16, aLocale, i18n::WordType::DICTIONARY_WORD)); CPPUNIT_ASSERT(!m_xBreak->isEndWord(aTest, 16, aLocale, i18n::WordType::DICTIONARY_WORD)); aBounds = m_xBreak->getWordBoundary(aTest, 16, aLocale, i18n::WordType::DICTIONARY_WORD, true); - CPPUNIT_ASSERT(aBounds.startPos == 16 && aBounds.endPos == 19); + CPPUNIT_ASSERT_EQUAL(sal_Int32(16), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(19), aBounds.endPos); } //See https://bz.apache.org/ooo/show_bug.cgi?id=21907 @@ -235,25 +240,32 @@ void TestBreakIterator::testWordBoundaries() "Spanish"; aBounds = m_xBreak->getWordBoundary(aTest, 4, aLocale, i18n::WordType::DICTIONARY_WORD, false); - CPPUNIT_ASSERT(aBounds.startPos == 0 && aBounds.endPos == 7); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7), aBounds.endPos); aBounds = m_xBreak->getWordBoundary(aTest, 12, aLocale, i18n::WordType::DICTIONARY_WORD, false); - CPPUNIT_ASSERT(aBounds.startPos == 9 && aBounds.endPos == 14); + CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(14), aBounds.endPos); aBounds = m_xBreak->getWordBoundary(aTest, 40, aLocale, i18n::WordType::DICTIONARY_WORD, false); - CPPUNIT_ASSERT(aBounds.startPos == 37 && aBounds.endPos == 44); + CPPUNIT_ASSERT_EQUAL(sal_Int32(37), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(44), aBounds.endPos); aBounds = m_xBreak->getWordBoundary(aTest, 49, aLocale, i18n::WordType::DICTIONARY_WORD, false); - CPPUNIT_ASSERT(aBounds.startPos == 46 && aBounds.endPos == 52); + CPPUNIT_ASSERT_EQUAL(sal_Int32(46), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(52), aBounds.endPos); aBounds = m_xBreak->getWordBoundary(aTest, 58, aLocale, i18n::WordType::DICTIONARY_WORD, false); - CPPUNIT_ASSERT(aBounds.startPos == 55 && aBounds.endPos == 62); + CPPUNIT_ASSERT_EQUAL(sal_Int32(55), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(62), aBounds.endPos); aBounds = m_xBreak->getWordBoundary(aTest, 67, aLocale, i18n::WordType::DICTIONARY_WORD, false); - CPPUNIT_ASSERT(aBounds.startPos == 64 && aBounds.endPos == 71); + CPPUNIT_ASSERT_EQUAL(sal_Int32(64), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(71), aBounds.endPos); aBounds = m_xBreak->getWordBoundary(aTest, 90, aLocale, i18n::WordType::DICTIONARY_WORD, false); - CPPUNIT_ASSERT(aBounds.startPos == 88 && aBounds.endPos == 92); + CPPUNIT_ASSERT_EQUAL(sal_Int32(88), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(92), aBounds.endPos); } //See https://bugs.libreoffice.org/show_bug.cgi?id=49629 @@ -274,16 +286,20 @@ void TestBreakIterator::testWordBoundaries() switch (mode) { case i18n::WordType::ANY_WORD: - CPPUNIT_ASSERT(aBounds.startPos == 0 && aBounds.endPos == 4); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aBounds.endPos); break; case i18n::WordType::ANYWORD_IGNOREWHITESPACES: - CPPUNIT_ASSERT(aBounds.startPos == 0 && aBounds.endPos == 4); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aBounds.endPos); break; case i18n::WordType::DICTIONARY_WORD: - CPPUNIT_ASSERT(aBounds.startPos == 0 && aBounds.endPos == 4); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aBounds.endPos); break; case i18n::WordType::WORD_COUNT: - CPPUNIT_ASSERT(aBounds.startPos == 0 && aBounds.endPos == 4); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aBounds.endPos); break; } @@ -303,16 +319,20 @@ void TestBreakIterator::testWordBoundaries() switch (mode) { case i18n::WordType::ANY_WORD: - CPPUNIT_ASSERT(aBounds.startPos == 0 && aBounds.endPos == 9); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aBounds.endPos); break; case i18n::WordType::ANYWORD_IGNOREWHITESPACES: - CPPUNIT_ASSERT(aBounds.startPos == 0 && aBounds.endPos == 9); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aBounds.endPos); break; case i18n::WordType::DICTIONARY_WORD: - CPPUNIT_ASSERT(aBounds.startPos == 0 && aBounds.endPos == 9); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aBounds.endPos); break; case i18n::WordType::WORD_COUNT: - CPPUNIT_ASSERT(aBounds.startPos == 0 && aBounds.endPos == 9); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aBounds.endPos); break; } @@ -562,10 +582,12 @@ void TestBreakIterator::testWordBoundaries() u"ru\uFB00le \uFB01sh"; aBounds = m_xBreak->getWordBoundary(aTest, 1, aLocale, i18n::WordType::DICTIONARY_WORD, false); - CPPUNIT_ASSERT(aBounds.startPos == 0 && aBounds.endPos == 5); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aBounds.endPos); aBounds = m_xBreak->getWordBoundary(aTest, 7, aLocale, i18n::WordType::DICTIONARY_WORD, false); - CPPUNIT_ASSERT(aBounds.startPos == 6 && aBounds.endPos == 9); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aBounds.endPos); } //See https://bz.apache.org/ooo/show_bug.cgi?id=113785 @@ -577,13 +599,16 @@ void TestBreakIterator::testWordBoundaries() u"a\u2013b\u2014c"; aBounds = m_xBreak->getWordBoundary(aTest, 0, aLocale, i18n::WordType::DICTIONARY_WORD, true); - CPPUNIT_ASSERT(aBounds.startPos == 0 && aBounds.endPos == 1); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aBounds.endPos); aBounds = m_xBreak->nextWord(aTest, 0, aLocale, i18n::WordType::DICTIONARY_WORD); - CPPUNIT_ASSERT(aBounds.startPos == 2 && aBounds.endPos == 3); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aBounds.endPos); aBounds = m_xBreak->nextWord(aTest, aBounds.endPos, aLocale, i18n::WordType::DICTIONARY_WORD); - CPPUNIT_ASSERT(aBounds.startPos == 4 && aBounds.endPos == 5); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aBounds.endPos); } } @@ -852,8 +877,10 @@ void TestBreakIterator::testThai() static constexpr OUStringLiteral aTest = u"\u0E01\u0E38\u0E2B\u0E25\u0E32\u0E1A"; i18n::Boundary aBounds = m_xBreak->getWordBoundary(aTest, 0, aLocale, i18n::WordType::DICTIONARY_WORD, true); - CPPUNIT_ASSERT_MESSAGE("Should skip full word", - aBounds.startPos == 0 && aBounds.endPos == aTest.getLength()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full word", + sal_Int32(0), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full word", + aTest.getLength(), aBounds.endPos); } //See https://bz.apache.org/ooo/show_bug.cgi?id=29548 @@ -968,7 +995,8 @@ void TestBreakIterator::doTestJapanese(uno::Reference< i18n::XBreakIterator > co aBounds = xBreak->getWordBoundary(aTest, 5, aLocale, i18n::WordType::DICTIONARY_WORD, true); - CPPUNIT_ASSERT(aBounds.startPos == 0 && aBounds.endPos == 7); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7), aBounds.endPos); } { @@ -977,12 +1005,14 @@ void TestBreakIterator::doTestJapanese(uno::Reference< i18n::XBreakIterator > co aBounds = xBreak->getWordBoundary(aTest, 1, aLocale, i18n::WordType::DICTIONARY_WORD, true); - CPPUNIT_ASSERT(aBounds.startPos == 0 && aBounds.endPos == 3); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aBounds.endPos); aBounds = xBreak->getWordBoundary(aTest, 5, aLocale, i18n::WordType::DICTIONARY_WORD, true); - CPPUNIT_ASSERT(aBounds.startPos == 3 && aBounds.endPos == 6); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), aBounds.endPos); } } @@ -1008,7 +1038,8 @@ void TestBreakIterator::testChinese() i18n::Boundary aBounds = m_xBreak->getWordBoundary(aTest, 4, aLocale, i18n::WordType::DICTIONARY_WORD, true); - CPPUNIT_ASSERT(aBounds.startPos == 4 && aBounds.endPos == 6); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), aBounds.endPos); } } void TestBreakIterator::setUp() diff --git a/i18npool/qa/cppunit/test_characterclassification.cxx b/i18npool/qa/cppunit/test_characterclassification.cxx index e2ea659eaccb..846477d615f1 100644 --- a/i18npool/qa/cppunit/test_characterclassification.cxx +++ b/i18npool/qa/cppunit/test_characterclassification.cxx @@ -8,6 +8,7 @@ */ #include <com/sun/star/i18n/XCharacterClassification.hpp> +#include <o3tl/cppunittraitshelper.hxx> #include <unotest/bootstrapfixturebase.hxx> using namespace ::com::sun::star; @@ -53,11 +54,14 @@ void TestCharacterClassification::testTitleCase() //tricky one static constexpr OUStringLiteral aTest = u"\u01F3"; // LATIN SMALL LETTER DZ OUString sTitleCase = m_xCC->toTitle(aTest, 0, aTest.getLength(), aLocale); - CPPUNIT_ASSERT_MESSAGE("Should be title", sTitleCase.getLength() == 1 && sTitleCase[0] == 0x01F2); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be title", sal_Int32(1), sTitleCase.getLength()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be title", u'\u01F2', sTitleCase[0]); OUString sUpperCase = m_xCC->toUpper(aTest, 0, aTest.getLength(), aLocale); - CPPUNIT_ASSERT_MESSAGE("Should be upper", sUpperCase.getLength() == 1 && sUpperCase[0] == 0x01F1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be upper", sal_Int32(1), sUpperCase.getLength()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be upper", u'\u01F1', sUpperCase[0]); OUString sLowerCase = m_xCC->toLower(aTest, 0, aTest.getLength(), aLocale); - CPPUNIT_ASSERT_MESSAGE("Should be lower ", sLowerCase.getLength() == 1 && sLowerCase[0] == 0x01F3); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be lower ", sal_Int32(1), sLowerCase.getLength()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be lower ", u'\u01F3', sLowerCase[0]); } } diff --git a/i18npool/qa/cppunit/test_textsearch.cxx b/i18npool/qa/cppunit/test_textsearch.cxx index 51e6a11bfc83..31c66d94cd8d 100644 --- a/i18npool/qa/cppunit/test_textsearch.cxx +++ b/i18npool/qa/cppunit/test_textsearch.cxx @@ -124,9 +124,12 @@ void TestTextSearch::testSearches() m_xSearch->setOptions(aOptions); aRes = m_xSearch->searchForward("11 22 33", 2, 7); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 2) && (aRes.endOffset[0] == 5)); - CPPUNIT_ASSERT((aRes.startOffset[1] == 2) && (aRes.endOffset[1] == 2)); - CPPUNIT_ASSERT((aRes.startOffset[2] == 3) && (aRes.endOffset[2] == 5)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aRes.endOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aRes.startOffset[1]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aRes.endOffset[1]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aRes.startOffset[2]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aRes.endOffset[2]); } void TestTextSearch::testWildcardSearch() @@ -147,44 +150,52 @@ void TestTextSearch::testWildcardSearch() // match first "a", [0,1) aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 0) && (aRes.endOffset[0] == 1)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aRes.endOffset[0]); // match last "a", (5,4] aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 5) && (aRes.endOffset[0] == 4)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aRes.endOffset[0]); aOptions.searchString = "a?"; m_xSearch2->setOptions2( aOptions ); // match "ab", [0,2) aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 0) && (aRes.endOffset[0] == 2)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aRes.endOffset[0]); // match "ac", (4,2] aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 4) && (aRes.endOffset[0] == 2)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aRes.endOffset[0]); aOptions.searchString = "a*c"; m_xSearch2->setOptions2( aOptions ); // match "abac", [0,4) XXX NOTE: first match forward aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 0) && (aRes.endOffset[0] == 4)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aRes.endOffset[0]); // match "ac", (4,2] XXX NOTE: first match backward, not greedy aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 4) && (aRes.endOffset[0] == 2)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aRes.endOffset[0]); aOptions.searchString = "b*a"; m_xSearch2->setOptions2( aOptions ); // match "ba", [1,3) XXX NOTE: first match forward, not greedy aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 1) && (aRes.endOffset[0] == 3)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aRes.endOffset[0]); // match "baca", (5,1] XXX NOTE: first match backward aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 5) && (aRes.endOffset[0] == 1)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aRes.endOffset[0]); aText = "ab?ca"; @@ -193,11 +204,13 @@ void TestTextSearch::testWildcardSearch() // match "b?c", [1,4) aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 1) && (aRes.endOffset[0] == 4)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aRes.endOffset[0]); // match "b?c", (4,1] aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 4) && (aRes.endOffset[0] == 1)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aRes.endOffset[0]); aText = "ab*ca"; @@ -206,11 +219,13 @@ void TestTextSearch::testWildcardSearch() // match "b?c", [1,4) aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 1) && (aRes.endOffset[0] == 4)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aRes.endOffset[0]); // match "b?c", (4,1] aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 4) && (aRes.endOffset[0] == 1)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aRes.endOffset[0]); aOptions.searchString = "ca?"; m_xSearch2->setOptions2( aOptions ); @@ -226,22 +241,26 @@ void TestTextSearch::testWildcardSearch() // match "ca", [3,5) aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 3) && (aRes.endOffset[0] == 5)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aRes.endOffset[0]); // match "ca", (5,3] aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 5) && (aRes.endOffset[0] == 3)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aRes.endOffset[0]); aOptions.searchString = "*ca*"; m_xSearch2->setOptions2( aOptions ); // match "abaca", [0,5) aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 0) && (aRes.endOffset[0] == 5)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aRes.endOffset[0]); // match "abaca", (5,0] aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 5) && (aRes.endOffset[0] == 0)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aRes.endOffset[0]); aText = "123123"; aOptions.searchString = "*2?"; @@ -249,22 +268,26 @@ void TestTextSearch::testWildcardSearch() // match first "123", [0,3) aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 0) && (aRes.endOffset[0] == 3)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aRes.endOffset[0]); // match "123123", (6,0] Yes this looks odd, but it is as searching "?2*" forward. aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 6) && (aRes.endOffset[0] == 0)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aRes.endOffset[0]); aOptions.searchFlag |= util::SearchFlags::WILD_MATCH_SELECTION; m_xSearch2->setOptions2( aOptions ); // match "123123", [0,6) with greedy '*' aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 0) && (aRes.endOffset[0] == 6)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), aRes.endOffset[0]); // match "123123", (6,0] aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aRes.subRegExpressions); - CPPUNIT_ASSERT((aRes.startOffset[0] == 6) && (aRes.endOffset[0] == 0)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), aRes.startOffset[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aRes.endOffset[0]); } void TestTextSearch::testApostropheSearch() |