From 6c76ade9516ada09222a18af69eb381b2e859b24 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 30 Sep 2016 09:59:19 +0200 Subject: i18npool: fix loplugin:cppunitassertequals warnings Change-Id: I2ebe54af7b769189e248b1a3af55ee1b6a66174a Reviewed-on: https://gerrit.libreoffice.org/29399 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- i18npool/qa/cppunit/test_breakiterator.cxx | 86 +++++++++++----------- .../qa/cppunit/test_characterclassification.cxx | 6 +- i18npool/qa/cppunit/test_textsearch.cxx | 74 +++++++++---------- 3 files changed, 83 insertions(+), 83 deletions(-) (limited to 'i18npool') diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx index 58b6a98f0978..dd3e85007403 100644 --- a/i18npool/qa/cppunit/test_breakiterator.cxx +++ b/i18npool/qa/cppunit/test_breakiterator.cxx @@ -87,13 +87,13 @@ void TestBreakIterator::testLineBreaking() { //Here we want the line break to leave text here) on the next line i18n::LineBreakResults aResult = m_xBreak->getLineBreak(aTest, strlen("(some tex"), aLocale, 0, aHyphOptions, aUserOptions); - CPPUNIT_ASSERT_MESSAGE("Expected a break at the start of the word", aResult.breakIndex == 6); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected a break at the start of the word", static_cast(6), aResult.breakIndex); } { //Here we want the line break to leave "here)" on the next line i18n::LineBreakResults aResult = m_xBreak->getLineBreak(aTest, strlen("(some text here"), aLocale, 0, aHyphOptions, aUserOptions); - CPPUNIT_ASSERT_MESSAGE("Expected a break at the start of the word", aResult.breakIndex == 11); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected a break at the start of the word", static_cast(11), aResult.breakIndex); } } @@ -109,7 +109,7 @@ void TestBreakIterator::testLineBreaking() { //Here we want the line break to happen at the whitespace i18n::LineBreakResults aResult = m_xBreak->getLineBreak(aTest, aTest.getLength()-1, aLocale, 0, aHyphOptions, aUserOptions); - CPPUNIT_ASSERT_MESSAGE("Expected a break at the start of the word", aResult.breakIndex == aWord.getLength()+1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected a break at the start of the word", aWord.getLength()+1, aResult.breakIndex); } } @@ -124,7 +124,7 @@ void TestBreakIterator::testLineBreaking() //Here we want the line break to leave /bar/ba clumped together on the next line i18n::LineBreakResults aResult = m_xBreak->getLineBreak(aTest, strlen("foo /bar/ba"), aLocale, 0, aHyphOptions, aUserOptions); - CPPUNIT_ASSERT_MESSAGE("Expected a break at the first slash", aResult.breakIndex == 4); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected a break at the first slash", static_cast(4), aResult.breakIndex); } } @@ -139,7 +139,7 @@ void TestBreakIterator::testLineBreaking() //Here we want the line break to move the whole lot to the next line i18n::LineBreakResults aResult = m_xBreak->getLineBreak(aTest, aTest.getLength()-2, aLocale, 0, aHyphOptions, aUserOptions); - CPPUNIT_ASSERT_MESSAGE("Expected a break at the start of the line, not at ]", aResult.breakIndex == 0); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected a break at the start of the line, not at ]", static_cast(0), aResult.breakIndex); } } @@ -339,7 +339,7 @@ void TestBreakIterator::testWordBoundaries() { CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aDoublePositions)); nPos = m_xBreak->nextWord(aTest, nPos, aLocale, i18n::WordType::ANYWORD_IGNOREWHITESPACES).startPos; - CPPUNIT_ASSERT(nPos == aDoublePositions[i++]); + CPPUNIT_ASSERT_EQUAL(aDoublePositions[i++], nPos); } while (nPos < aTest.getLength()); nPos = aTest.getLength(); @@ -347,7 +347,7 @@ void TestBreakIterator::testWordBoundaries() do { nPos = m_xBreak->previousWord(aTest, nPos, aLocale, i18n::WordType::ANYWORD_IGNOREWHITESPACES).startPos; - CPPUNIT_ASSERT(nPos == aDoublePositions[--i]); + CPPUNIT_ASSERT_EQUAL(aDoublePositions[--i], nPos); } while (nPos > 0); } @@ -362,7 +362,7 @@ void TestBreakIterator::testWordBoundaries() { CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aSinglePositions)); nPos = m_xBreak->nextWord(aTest, nPos, aLocale, i18n::WordType::ANYWORD_IGNOREWHITESPACES).startPos; - CPPUNIT_ASSERT(nPos == aSinglePositions[i++]); + CPPUNIT_ASSERT_EQUAL(aSinglePositions[i++], nPos); } while (nPos < aTest.getLength()); nPos = aTest.getLength(); @@ -370,13 +370,13 @@ void TestBreakIterator::testWordBoundaries() do { nPos = m_xBreak->previousWord(aTest, nPos, aLocale, i18n::WordType::ANYWORD_IGNOREWHITESPACES).startPos; - CPPUNIT_ASSERT(nPos == aSinglePositions[--i]); + CPPUNIT_ASSERT_EQUAL(aSinglePositions[--i], nPos); } while (nPos > 0); } const sal_Int32 aSingleQuotePositions[] = {0, 1, 9, 10}; - CPPUNIT_ASSERT(aTests[0] == '\''); + CPPUNIT_ASSERT_EQUAL(static_cast('\''), aTests[0]); { OUString aTest = aBase.replaceAll("xx", OUStringLiteral1(aTests[0])); sal_Int32 nPos = -1; @@ -385,7 +385,7 @@ void TestBreakIterator::testWordBoundaries() { CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aSingleQuotePositions)); nPos = m_xBreak->nextWord(aTest, nPos, aLocale, i18n::WordType::ANYWORD_IGNOREWHITESPACES).startPos; - CPPUNIT_ASSERT(nPos == aSingleQuotePositions[i++]); + CPPUNIT_ASSERT_EQUAL(aSingleQuotePositions[i++], nPos); } while (nPos < aTest.getLength()); nPos = aTest.getLength(); @@ -393,7 +393,7 @@ void TestBreakIterator::testWordBoundaries() do { nPos = m_xBreak->previousWord(aTest, nPos, aLocale, i18n::WordType::ANYWORD_IGNOREWHITESPACES).startPos; - CPPUNIT_ASSERT(nPos == aSingleQuotePositions[--i]); + CPPUNIT_ASSERT_EQUAL(aSingleQuotePositions[--i], nPos); } while (nPos > 0); } @@ -414,10 +414,10 @@ void TestBreakIterator::testWordBoundaries() CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aExpected)); nPos = m_xBreak->getWordBoundary(aTest, nPos, aLocale, i18n::WordType::DICTIONARY_WORD, true).endPos; - CPPUNIT_ASSERT(aExpected[i++] == nPos); + CPPUNIT_ASSERT_EQUAL(aExpected[i++], nPos); } while (nPos++ < aTest.getLength()); - CPPUNIT_ASSERT(i == SAL_N_ELEMENTS(aExpected)); + CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(aExpected), i); } //See https://bz.apache.org/ooo/show_bug.cgi?id=85411 @@ -456,10 +456,10 @@ void TestBreakIterator::testWordBoundaries() CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aExpected)); nPos = m_xBreak->getWordBoundary(aTest, nPos, aLocale, i18n::WordType::DICTIONARY_WORD, true).endPos; - CPPUNIT_ASSERT(aExpected[i++] == nPos); + CPPUNIT_ASSERT_EQUAL(aExpected[i++], nPos); } while (nPos++ < aTest.getLength()); - CPPUNIT_ASSERT(i == SAL_N_ELEMENTS(aExpected)); + CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(aExpected), i); } //https://bz.apache.org/ooo/show_bug.cgi?id=21290 @@ -497,10 +497,10 @@ void TestBreakIterator::testWordBoundaries() CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aExpected)); nPos = m_xBreak->getWordBoundary(aTest, nPos, aLocale, i18n::WordType::DICTIONARY_WORD, true).endPos; - CPPUNIT_ASSERT(aExpected[i++] == nPos); + CPPUNIT_ASSERT_EQUAL(aExpected[i++], nPos); } while (nPos++ < aTest.getLength()); - CPPUNIT_ASSERT(i == SAL_N_ELEMENTS(aExpected)); + CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(aExpected), i); } //See https://bz.apache.org/ooo/show_bug.cgi?id=58513 @@ -520,10 +520,10 @@ void TestBreakIterator::testWordBoundaries() CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aExpected)); nPos = m_xBreak->getWordBoundary(aTest, nPos, aLocale, i18n::WordType::WORD_COUNT, true).endPos; - CPPUNIT_ASSERT(aExpected[i++] == nPos); + CPPUNIT_ASSERT_EQUAL(aExpected[i++], nPos); } while (nPos++ < aTest.getLength()); - CPPUNIT_ASSERT(i == SAL_N_ELEMENTS(aExpected)); + CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(aExpected), i); } { @@ -536,12 +536,12 @@ void TestBreakIterator::testWordBoundaries() CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aExpected)); aBounds = m_xBreak->getWordBoundary(aTest, nPos, aLocale, i18n::WordType::DICTIONARY_WORD, true); - CPPUNIT_ASSERT(aExpected[i++] == aBounds.startPos); - CPPUNIT_ASSERT(aExpected[i++] == aBounds.endPos); + CPPUNIT_ASSERT_EQUAL(aExpected[i++], aBounds.startPos); + CPPUNIT_ASSERT_EQUAL(aExpected[i++], aBounds.endPos); nPos = aBounds.endPos; } while (nPos++ < aTest.getLength()); - CPPUNIT_ASSERT(i == SAL_N_ELEMENTS(aExpected)); + CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(aExpected), i); } } @@ -603,10 +603,10 @@ void TestBreakIterator::testGraphemeIteration() sal_Int32 nPos; nPos = m_xBreak->nextCharacters(aTest, 0, aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); - CPPUNIT_ASSERT_MESSAGE("Should skip full grapheme", nPos == SAL_N_ELEMENTS(BA_HALANT_LA)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full grapheme", static_cast(SAL_N_ELEMENTS(BA_HALANT_LA)), nPos); nPos = m_xBreak->previousCharacters(aTest, SAL_N_ELEMENTS(BA_HALANT_LA), aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); - CPPUNIT_ASSERT_MESSAGE("Should skip full grapheme", nPos == 0); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full grapheme", static_cast(0), nPos); } { @@ -617,10 +617,10 @@ void TestBreakIterator::testGraphemeIteration() sal_Int32 nPos; nPos = m_xBreak->nextCharacters(aTest, 0, aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); - CPPUNIT_ASSERT_MESSAGE("Should skip full grapheme", nPos == SAL_N_ELEMENTS(HA_HALANT_NA_VOWELSIGNI)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full grapheme", static_cast(SAL_N_ELEMENTS(HA_HALANT_NA_VOWELSIGNI)), nPos); nPos = m_xBreak->previousCharacters(aTest, SAL_N_ELEMENTS(HA_HALANT_NA_VOWELSIGNI), aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); - CPPUNIT_ASSERT_MESSAGE("Should skip full grapheme", nPos == 0); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full grapheme", static_cast(0), nPos); } { @@ -631,10 +631,10 @@ void TestBreakIterator::testGraphemeIteration() sal_Int32 nPos; nPos = m_xBreak->nextCharacters(aTest, 0, aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); - CPPUNIT_ASSERT_MESSAGE("Should skip full grapheme", nPos == SAL_N_ELEMENTS(TA_HALANT_MA_HALANT_YA)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full grapheme", static_cast(SAL_N_ELEMENTS(TA_HALANT_MA_HALANT_YA)), nPos); nPos = m_xBreak->previousCharacters(aTest, SAL_N_ELEMENTS(TA_HALANT_MA_HALANT_YA), aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); - CPPUNIT_ASSERT_MESSAGE("Should skip full grapheme", nPos == 0); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full grapheme", static_cast(0), nPos); } aLocale.Language = "ta"; @@ -649,10 +649,10 @@ void TestBreakIterator::testGraphemeIteration() nPos = m_xBreak->nextCharacters(aTest, 0, aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); - CPPUNIT_ASSERT_MESSAGE("Should skip full grapheme", nPos == SAL_N_ELEMENTS(KA_VIRAMA_SSA)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full grapheme", static_cast(SAL_N_ELEMENTS(KA_VIRAMA_SSA)), nPos); nPos = m_xBreak->previousCharacters(aTest, SAL_N_ELEMENTS(KA_VIRAMA_SSA), aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); - CPPUNIT_ASSERT_MESSAGE("Should skip full grapheme", nPos == 0); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full grapheme", static_cast(0), nPos); } { @@ -664,10 +664,10 @@ void TestBreakIterator::testGraphemeIteration() nPos = m_xBreak->nextCharacters(aTest, 0, aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); - CPPUNIT_ASSERT_MESSAGE("Should skip full grapheme", nPos == SAL_N_ELEMENTS(KA_VOWELSIGNU)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full grapheme", static_cast(SAL_N_ELEMENTS(KA_VOWELSIGNU)), nPos); nPos = m_xBreak->previousCharacters(aTest, SAL_N_ELEMENTS(KA_VOWELSIGNU), aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); - CPPUNIT_ASSERT_MESSAGE("Should skip full grapheme", nPos == 0); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full grapheme", static_cast(0), nPos); } { @@ -684,7 +684,7 @@ void TestBreakIterator::testGraphemeIteration() sal_Int32 nOldPos = nPos; nPos = m_xBreak->nextCharacters(aTest, nPos, aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); - CPPUNIT_ASSERT_MESSAGE("Should skip 2 units", nPos == nOldPos+2); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip 2 units", nOldPos+2, nPos); } for (sal_Int32 i = 0; i < 4; ++i) @@ -692,7 +692,7 @@ void TestBreakIterator::testGraphemeIteration() sal_Int32 nOldPos = nPos; nPos = m_xBreak->previousCharacters(aTest, nPos, aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); - CPPUNIT_ASSERT_MESSAGE("Should skip 2 units", nPos == nOldPos-2); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip 2 units", nOldPos-2, nPos); } } @@ -711,7 +711,7 @@ void TestBreakIterator::testGraphemeIteration() ++nGraphemeCount; } - CPPUNIT_ASSERT_MESSAGE("Should be considered 1 grapheme", nGraphemeCount == 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be considered 1 grapheme", static_cast(1), nGraphemeCount); } aLocale.Language = "hi"; @@ -726,10 +726,10 @@ void TestBreakIterator::testGraphemeIteration() nPos = m_xBreak->nextCharacters(aTest, 0, aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); - CPPUNIT_ASSERT_MESSAGE("Should skip full grapheme", nPos == SAL_N_ELEMENTS(SHA_VOWELSIGNII)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full grapheme", static_cast(SAL_N_ELEMENTS(SHA_VOWELSIGNII)), nPos); nPos = m_xBreak->previousCharacters(aTest, SAL_N_ELEMENTS(SHA_VOWELSIGNII), aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); - CPPUNIT_ASSERT_MESSAGE("Should skip full grapheme", nPos == 0); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full grapheme", static_cast(0), nPos); } } @@ -767,8 +767,8 @@ void TestBreakIterator::testWeak() aMsg.append("Char 0x"); aMsg.append(static_cast(aWeaks[i]), 16); aMsg.append(" should have been weak"); - CPPUNIT_ASSERT_MESSAGE(aMsg.getStr(), - nScript == i18n::ScriptType::WEAK); + CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(), + i18n::ScriptType::WEAK, nScript); } } } @@ -806,8 +806,8 @@ void TestBreakIterator::testAsian() aMsg.append("Char 0x"); aMsg.append(static_cast(aAsians[i]), 16); aMsg.append(" should have been asian"); - CPPUNIT_ASSERT_MESSAGE(aMsg.getStr(), - nScript == i18n::ScriptType::ASIAN); + CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(), + i18n::ScriptType::ASIAN, nScript); } } } @@ -882,7 +882,7 @@ void TestBreakIterator::testThai() { CPPUNIT_ASSERT(!aPositions.empty()); nPos = m_xBreak->previousWord(aTest, nPos, aLocale, i18n::WordType::ANYWORD_IGNOREWHITESPACES).startPos; - CPPUNIT_ASSERT(nPos == aPositions.top()); + CPPUNIT_ASSERT_EQUAL(aPositions.top(), nPos); aPositions.pop(); } while (nPos > 0); diff --git a/i18npool/qa/cppunit/test_characterclassification.cxx b/i18npool/qa/cppunit/test_characterclassification.cxx index 16cf087324e7..70c902f71aaa 100644 --- a/i18npool/qa/cppunit/test_characterclassification.cxx +++ b/i18npool/qa/cppunit/test_characterclassification.cxx @@ -49,11 +49,11 @@ void TestCharacterClassification::testTitleCase() //basic example OUString sTest("Some text"); OUString sTitleCase = m_xCC->toTitle(sTest, 0, sTest.getLength(), aLocale); - CPPUNIT_ASSERT_MESSAGE("Should be title", sTitleCase == "Some Text"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be title", OUString("Some Text"), sTitleCase); OUString sUpperCase = m_xCC->toUpper(sTest, 0, sTest.getLength(), aLocale); - CPPUNIT_ASSERT_MESSAGE("Should be upper", sUpperCase == "SOME TEXT"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be upper", OUString("SOME TEXT"), sUpperCase); OUString sLowerCase = m_xCC->toLower(sTest, 0, sTest.getLength(), aLocale); - CPPUNIT_ASSERT_MESSAGE("Should be lower ", sLowerCase == "some text"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be lower ", OUString("some text"), sLowerCase); } { diff --git a/i18npool/qa/cppunit/test_textsearch.cxx b/i18npool/qa/cppunit/test_textsearch.cxx index c4e98c9300e8..a5a62436535d 100644 --- a/i18npool/qa/cppunit/test_textsearch.cxx +++ b/i18npool/qa/cppunit/test_textsearch.cxx @@ -72,11 +72,11 @@ void TestTextSearch::testICU() pRegexMatcher->reset( aSource ); CPPUNIT_ASSERT( pRegexMatcher->find( 0, nErr ) ); - CPPUNIT_ASSERT( nErr == U_ZERO_ERROR ); - CPPUNIT_ASSERT( pRegexMatcher->start( nErr ) == 4 ); - CPPUNIT_ASSERT( nErr == U_ZERO_ERROR ); - CPPUNIT_ASSERT( pRegexMatcher->end( nErr ) == 5 ); - CPPUNIT_ASSERT( nErr == U_ZERO_ERROR ); + CPPUNIT_ASSERT_EQUAL( U_ZERO_ERROR, nErr ); + CPPUNIT_ASSERT_EQUAL( static_cast(4), pRegexMatcher->start( nErr ) ); + CPPUNIT_ASSERT_EQUAL( U_ZERO_ERROR, nErr ); + CPPUNIT_ASSERT_EQUAL( static_cast(5), pRegexMatcher->end( nErr ) ); + CPPUNIT_ASSERT_EQUAL( U_ZERO_ERROR, nErr ); delete pRegexMatcher; @@ -90,11 +90,11 @@ void TestTextSearch::testICU() pRegexMatcher->reset( aSource2 ); CPPUNIT_ASSERT( pRegexMatcher->find( 0, nErr ) ); - CPPUNIT_ASSERT( nErr == U_ZERO_ERROR ); - CPPUNIT_ASSERT( pRegexMatcher->start( nErr ) == 0 ); - CPPUNIT_ASSERT( nErr == U_ZERO_ERROR ); - CPPUNIT_ASSERT( pRegexMatcher->end( nErr ) == 1 ); - CPPUNIT_ASSERT( nErr == U_ZERO_ERROR ); + CPPUNIT_ASSERT_EQUAL( U_ZERO_ERROR, nErr ); + CPPUNIT_ASSERT_EQUAL( static_cast(0), pRegexMatcher->start( nErr ) ); + CPPUNIT_ASSERT_EQUAL( U_ZERO_ERROR, nErr ); + CPPUNIT_ASSERT_EQUAL( static_cast(1), pRegexMatcher->end( nErr ) ); + CPPUNIT_ASSERT_EQUAL( U_ZERO_ERROR, nErr ); delete pRegexMatcher; } @@ -118,21 +118,21 @@ void TestTextSearch::testSearches() // search forward aRes = m_xSearch->searchForward( str, startPos, endPos ); CPPUNIT_ASSERT( aRes.subRegExpressions > 0 ); - CPPUNIT_ASSERT( aRes.startOffset[0] == fStartRes ); - CPPUNIT_ASSERT( aRes.endOffset[0] == fEndRes ); + CPPUNIT_ASSERT_EQUAL( fStartRes, aRes.startOffset[0] ); + CPPUNIT_ASSERT_EQUAL( fEndRes, aRes.endOffset[0] ); // search backwards aRes = m_xSearch->searchBackward( str, endPos, startPos ); CPPUNIT_ASSERT( aRes.subRegExpressions > 0 ); - CPPUNIT_ASSERT( aRes.startOffset[0] == bStartRes ); - CPPUNIT_ASSERT( aRes.endOffset[0] == bEndRes ); + CPPUNIT_ASSERT_EQUAL( bStartRes, aRes.startOffset[0] ); + CPPUNIT_ASSERT_EQUAL( bEndRes, aRes.endOffset[0] ); aOptions.transliterateFlags = ::css::i18n::TransliterationModules::TransliterationModules_IGNORE_CASE | ::css::i18n::TransliterationModules::TransliterationModules_IGNORE_WIDTH; aOptions.searchString = "([^ ]*)[ ]*([^ ]*)"; m_xSearch->setOptions(aOptions); aRes = m_xSearch->searchForward("11 22 33", 2, 7); - CPPUNIT_ASSERT(aRes.subRegExpressions == 3); + CPPUNIT_ASSERT_EQUAL(static_cast(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)); @@ -155,44 +155,44 @@ void TestTextSearch::testWildcardSearch() m_xSearch2->setOptions2( aOptions ); // match first "a", [0,1) aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 0) && (aRes.endOffset[0] == 1)); // match last "a", (5,4] aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 5) && (aRes.endOffset[0] == 4)); aOptions.searchString = "a?"; m_xSearch2->setOptions2( aOptions ); // match "ab", [0,2) aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 0) && (aRes.endOffset[0] == 2)); // match "ac", (4,2] aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 4) && (aRes.endOffset[0] == 2)); 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(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 0) && (aRes.endOffset[0] == 4)); // match "ac", (4,2] XXX NOTE: first match backward, not greedy aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 4) && (aRes.endOffset[0] == 2)); 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(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 1) && (aRes.endOffset[0] == 3)); // match "baca", (5,1] XXX NOTE: first match backward aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 5) && (aRes.endOffset[0] == 1)); aText = "ab?ca"; @@ -201,11 +201,11 @@ void TestTextSearch::testWildcardSearch() m_xSearch2->setOptions2( aOptions ); // match "b?c", [1,4) aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 1) && (aRes.endOffset[0] == 4)); // match "b?c", (4,1] aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 4) && (aRes.endOffset[0] == 1)); aText = "ab*ca"; @@ -214,42 +214,42 @@ void TestTextSearch::testWildcardSearch() m_xSearch2->setOptions2( aOptions ); // match "b?c", [1,4) aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 1) && (aRes.endOffset[0] == 4)); // match "b?c", (4,1] aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 4) && (aRes.endOffset[0] == 1)); aOptions.searchString = "ca?"; m_xSearch2->setOptions2( aOptions ); // no match aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); - CPPUNIT_ASSERT(aRes.subRegExpressions == 0); + CPPUNIT_ASSERT_EQUAL(static_cast(0), aRes.subRegExpressions); // no match aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); - CPPUNIT_ASSERT(aRes.subRegExpressions == 0); + CPPUNIT_ASSERT_EQUAL(static_cast(0), aRes.subRegExpressions); aOptions.searchString = "ca*"; m_xSearch2->setOptions2( aOptions ); // match "ca", [3,5) aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 3) && (aRes.endOffset[0] == 5)); // match "ca", (5,3] aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 5) && (aRes.endOffset[0] == 3)); aOptions.searchString = "*ca*"; m_xSearch2->setOptions2( aOptions ); // match "abaca", [0,5) aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 0) && (aRes.endOffset[0] == 5)); // match "abaca", (5,0] aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 5) && (aRes.endOffset[0] == 0)); aText = "123123"; @@ -257,22 +257,22 @@ void TestTextSearch::testWildcardSearch() m_xSearch2->setOptions2( aOptions ); // match first "123", [0,3) aRes = m_xSearch2->searchForward( aText, 0, aText.getLength()); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 0) && (aRes.endOffset[0] == 3)); // 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(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 6) && (aRes.endOffset[0] == 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(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 0) && (aRes.endOffset[0] == 6)); // match "123123", (6,0] aRes = m_xSearch2->searchBackward( aText, aText.getLength(), 0); - CPPUNIT_ASSERT(aRes.subRegExpressions == 1); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aRes.subRegExpressions); CPPUNIT_ASSERT((aRes.startOffset[0] == 6) && (aRes.endOffset[0] == 0)); } -- cgit