diff options
Diffstat (limited to 'svl')
-rw-r--r-- | svl/qa/unit/svl.cxx | 24 | ||||
-rw-r--r-- | svl/qa/unit/test_URIHelper.cxx | 105 |
2 files changed, 59 insertions, 70 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 9a682fc08751..05b5155054d9 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -276,13 +276,12 @@ void Test::testNumberFormat() SvNumberFormatter aFormatter(m_xContext, eLang); - for (size_t i = 0; i < SAL_N_ELEMENTS(aTests); ++i) + for (auto const[eStart, eEnd, nSize, pCodes] : aTests) { - size_t nStart = aTests[i].eStart; - size_t nEnd = aTests[i].eEnd; - - CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected number of formats for this category.", - aTests[i].nSize, (nEnd - nStart + 1)); + size_t nStart = eStart; + size_t nEnd = eEnd; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected number of formats for this category.", nSize, + (nEnd - nStart + 1)); for (size_t j = nStart; j <= nEnd; ++j) { @@ -292,7 +291,7 @@ void Test::testNumberFormat() CPPUNIT_ASSERT_MESSAGE("Number format entry is expected, but doesn't exist.", p); OUString aCode = p->GetFormatstring(); - CPPUNIT_ASSERT_EQUAL( OString( aTests[i].pCodes[j-nStart] ), aCode.toUtf8()); + CPPUNIT_ASSERT_EQUAL(OString( pCodes[j-nStart]), aCode.toUtf8()); } } @@ -1117,9 +1116,9 @@ void Test::testDateInput() LanguageType eLang = LANGUAGE_ENGLISH_US; SvNumberFormatter aFormatter(m_xContext, eLang); - for (size_t i=0; i < SAL_N_ELEMENTS(aData); ++i) + for (auto const& aEntry : aData) { - checkDateInput( aFormatter, aData[i][0], aData[i][1]); + checkDateInput(aFormatter, aEntry[0], aEntry[1]); } } @@ -1177,14 +1176,13 @@ void Test::testIsNumberFormat() { "−1000", true } // unicode minus }; - for (size_t i = 0; i < SAL_N_ELEMENTS(aTests); ++i) + for (auto const[pFormat, bTestIsNumber] : aTests) { sal_uInt32 nIndex = 0; double nNumber = 0; - OUString aString = OUString::fromUtf8(aTests[i].pFormat); + OUString aString = OUString::fromUtf8(pFormat); bool bIsNumber = aFormatter.IsNumberFormat(aString, nIndex, nNumber); - CPPUNIT_ASSERT_EQUAL_MESSAGE(aTests[i].pFormat, aTests[i].bIsNumber, bIsNumber); - + CPPUNIT_ASSERT_EQUAL_MESSAGE(pFormat, bTestIsNumber, bIsNumber); } } diff --git a/svl/qa/unit/test_URIHelper.cxx b/svl/qa/unit/test_URIHelper.cxx index 4e4bbab31934..3f2624785f24 100644 --- a/svl/qa/unit/test_URIHelper.cxx +++ b/svl/qa/unit/test_URIHelper.cxx @@ -247,35 +247,36 @@ void Test::testNormalizedMakeRelative() { "nonex3/nonex4" } #endif }; - for (std::size_t i = 0; i < SAL_N_ELEMENTS(tests); ++i) { - css::uno::Reference< css::uri::XUriReference > ref( - URIHelper::normalizedMakeRelative( - m_context, OUString::createFromAscii(tests[i].base), - OUString::createFromAscii(tests[i].absolute))); - bool ok = tests[i].relative == nullptr - ? !ref.is() - : ref.is() && ref->getUriReference().equalsAscii(tests[i].relative); + for (auto const[base, absolute, relative] : tests) + { + css::uno::Reference< css::uri::XUriReference > ref(URIHelper::normalizedMakeRelative( + m_context, OUString::createFromAscii(base), OUString::createFromAscii(absolute))); + bool ok = relative == nullptr ? !ref.is() + : ref.is() && ref->getUriReference().equalsAscii(relative); OString msg; - if (!ok) { - OStringBuffer buf(OString::Concat("<") - + tests[i].base - + ">, <" - + tests[i].absolute - + ">: "); - if (ref.is()) { + if (!ok) + { + OStringBuffer buf(OString::Concat("<") + base + ">, <" + absolute + ">: "); + if (ref.is()) + { buf.append('<'); buf.append( OUStringToOString( ref->getUriReference(), RTL_TEXTENCODING_UTF8)); buf.append('>'); - } else { + } + else + { buf.append("none"); } buf.append(" instead of "); - if (tests[i].relative == nullptr) { + if (relative == nullptr) + { buf.append("none"); - } else { - buf.append(OString::Concat("<") + tests[i].relative + ">"); + } + else + { + buf.append(OString::Concat("<") + relative + ">"); } msg = buf.makeStringAndClear(); } @@ -369,32 +370,27 @@ void Test::testFindFirstURLInText() { { "wfs:", nullptr, 0, 0 } }; CharClass charClass( m_context, LanguageTag( css::lang::Locale("en", "US", ""))); - for (std::size_t i = 0; i < SAL_N_ELEMENTS(tests); ++i) { - OUString input(OUString::createFromAscii(tests[i].input)); + for (auto const[pInput, pResult, nBegin, nEnd] : tests) + { + OUString input(OUString::createFromAscii(pInput)); sal_Int32 begin = 0; sal_Int32 end = input.getLength(); - OUString result( - URIHelper::FindFirstURLInText(input, begin, end, charClass)); - bool ok = tests[i].result == nullptr - ? (result.getLength() == 0 && begin == input.getLength() - && end == input.getLength()) - : (result.equalsAscii(tests[i].result) && begin == tests[i].begin - && end == tests[i].end); + OUString result(URIHelper::FindFirstURLInText(input, begin, end, charClass)); + bool ok = pResult == nullptr + ? (result.getLength() == 0 && begin == input.getLength() + && end == input.getLength()) + : (result.equalsAscii(pResult) && begin == nBegin && end == nEnd); OString msg; - if (!ok) { + if (!ok) + { OStringBuffer buf; - buf.append(OString::Concat("\"") - + tests[i].input - + "\" -> "); - buf.append(tests[i].result == nullptr ? "none" : tests[i].result); - buf.append(" (" - + OString::number(tests[i].begin) - + ", " - + OString::number(tests[i].end) + buf.append(OString::Concat("\"") + pInput + "\" -> "); + buf.append(pResult == nullptr ? "none" : pResult); + buf.append(" (" + OString::number(nBegin) + ", " + OString::number(nEnd) + ")" " != " - + OUStringToOString(result, RTL_TEXTENCODING_UTF8) - + " (" + OString::number(begin) + ", " + OString::number(end) +")"); + + OUStringToOString(result, RTL_TEXTENCODING_UTF8) + " (" + + OString::number(begin) + ", " + OString::number(end) +")"); msg = buf.makeStringAndClear(); } CPPUNIT_ASSERT_MESSAGE(msg.getStr(), ok); @@ -425,32 +421,27 @@ void Test::testFindFirstDOIInText() { { "doi:11.1093/ajae/aaq063", nullptr, 0, 0 }, // doesn't begin with doi:10. }; CharClass charClass( m_context, LanguageTag( css::lang::Locale("en", "US", ""))); - for (std::size_t i = 0; i < SAL_N_ELEMENTS(tests); ++i) { - OUString input(OUString::createFromAscii(tests[i].input)); + for (auto const[pInput, pResult, nBegin, nEnd] : tests) + { + OUString input(OUString::createFromAscii(pInput)); sal_Int32 begin = 0; sal_Int32 end = input.getLength(); OUString result( URIHelper::FindFirstDOIInText(input, begin, end, charClass)); - bool ok = tests[i].result == nullptr - ? (result.getLength() == 0 && begin == input.getLength() - && end == input.getLength()) - : (result.equalsAscii(tests[i].result) && begin == tests[i].begin - && end == tests[i].end); + bool ok = pResult == nullptr + ? (result.getLength() == 0 && begin == input.getLength() && end == input.getLength()) + : (result.equalsAscii(pResult) && begin == nBegin && end == nEnd); OString msg; - if (!ok) { + if (!ok) + { OStringBuffer buf; - buf.append(OString::Concat("\"") - + tests[i].input - + "\" -> "); - buf.append(tests[i].result == nullptr ? "none" : tests[i].result); - buf.append(" (" - + OString::number(tests[i].begin) - + ", " - + OString::number(tests[i].end) + buf.append(OString::Concat("\"") + pInput + "\" -> "); + buf.append(pResult == nullptr ? "none" : pResult); + buf.append(" (" + OString::number(nBegin) + ", " + OString::number(nEnd) + ")" " != " - + OUStringToOString(result, RTL_TEXTENCODING_UTF8) - + " (" + OString::number(begin) + ", " + OString::number(end) +")"); + + OUStringToOString(result, RTL_TEXTENCODING_UTF8) + " (" + + OString::number(begin) + ", " + OString::number(end) +")"); msg = buf.makeStringAndClear(); } CPPUNIT_ASSERT_MESSAGE(msg.getStr(), ok); |