summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dave@treblig.org>2023-05-31 01:58:18 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2023-06-02 16:58:57 +0200
commit7bec1689fcbe9102aa220739b6113118d9a8dd1f (patch)
treead0146c3bf6f14530e36b79a0c620cfd1dad4084
parentf8036f2f5238adf227d0ffa646e503f0446bb37b (diff)
tdf#145538,tdf#147021: qa: range based loops
A bunch of range based loop changes in various qa sections that also take out about 1% of SAL_N_ELEMENTS Change-Id: I8ef000e9aa400cd8363b48f6175f6ab258cefbd9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152422 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--filter/qa/cppunit/priority-test.cxx13
-rw-r--r--sal/qa/rtl/strings/test_oustring_convert.cxx4
-rw-r--r--sal/qa/rtl/strings/test_oustring_endswith.cxx19
-rw-r--r--sal/qa/rtl/textenc/rtl_textcvt.cxx71
-rw-r--r--sal/qa/rtl/uri/rtl_testuri.cxx34
-rw-r--r--sc/qa/unit/subsequent_export_test.cxx22
-rw-r--r--svl/qa/unit/svl.cxx24
-rw-r--r--svl/qa/unit/test_URIHelper.cxx105
-rw-r--r--sw/qa/core/macros-test.cxx6
-rw-r--r--sw/qa/extras/odfexport/odfexport2.cxx4
-rw-r--r--xmloff/qa/unit/uxmloff.cxx13
11 files changed, 146 insertions, 169 deletions
diff --git a/filter/qa/cppunit/priority-test.cxx b/filter/qa/cppunit/priority-test.cxx
index 18e63c3188ee..7b37ce07e6ee 100644
--- a/filter/qa/cppunit/priority-test.cxx
+++ b/filter/qa/cppunit/priority-test.cxx
@@ -50,20 +50,17 @@ void PriorityFilterTest::testPriority()
// TODO: expand this to check more of these priorities
};
- for (size_t i = 0; i < SAL_N_ELEMENTS(aToCheck); i++)
+ for (auto const[pURL, pFormat] : aToCheck)
{
- OUString aURL = OUString::createFromAscii(aToCheck[i].pURL);
+ OUString aURL = OUString::createFromAscii(pURL);
try
{
OUString aTypeName = xDetection->queryTypeByURL(aURL);
- OUString aFormatCorrect = OUString::createFromAscii(aToCheck[i].pFormat);
+ OUString aFormatCorrect = OUString::createFromAscii(pFormat);
OUString aMsg = "Mis-matching formats "
- "'" +
- aTypeName +
- "' should be '" +
- aFormatCorrect +
- "'";
+ "'" +
+ aTypeName + "' should be '" + aFormatCorrect + "'";
CPPUNIT_ASSERT_EQUAL_MESSAGE(OUStringToOString(aMsg,
RTL_TEXTENCODING_UTF8).getStr(),
aFormatCorrect, aTypeName);
diff --git a/sal/qa/rtl/strings/test_oustring_convert.cxx b/sal/qa/rtl/strings/test_oustring_convert.cxx
index da930a03f244..e74276a11b0f 100644
--- a/sal/qa/rtl/strings/test_oustring_convert.cxx
+++ b/sal/qa/rtl/strings/test_oustring_convert.cxx
@@ -170,8 +170,8 @@ void test::oustring::Convert::convertToString()
OUSTRING_TO_OSTRING_CVTFLAGS,
"A?B",
"A?B" } };
- for (size_t i = 0; i < SAL_N_ELEMENTS(aTests); ++i)
- testConvertToString(aTests[i]);
+ for (auto const& aTest : aTests)
+ testConvertToString(aTest);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/qa/rtl/strings/test_oustring_endswith.cxx b/sal/qa/rtl/strings/test_oustring_endswith.cxx
index bf01577e28be..9ec08fa55045 100644
--- a/sal/qa/rtl/strings/test_oustring_endswith.cxx
+++ b/sal/qa/rtl/strings/test_oustring_endswith.cxx
@@ -93,20 +93,17 @@ void test::oustring::EndsWith::endsWith()
RTL_CONSTASCII_STRINGPARAM("b\0c"), true },
{ RTL_CONSTASCII_STRINGPARAM("a\0b\0c"),
RTL_CONSTASCII_STRINGPARAM("b"), false } };
- for (size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
+ for (auto const[pStr1, nStr1Len, pStr2, nStr2Len, bEndsWith] : data)
+ {
OStringBuffer msg;
- appendString(msg, OString(data[i].str1, data[i].str1Len));
+ appendString(msg, OString(pStr1, nStr1Len));
msg.append(".endsWithIgnoreAsciiCaseAsciiL(");
- appendString(msg, OString(data[i].str2, data[i].str2Len));
+ appendString(msg, OString(pStr2, nStr2Len));
msg.append(") == ");
- msg.append(data[i].endsWith);
- CPPUNIT_ASSERT_EQUAL_MESSAGE(
- msg.getStr(),
- data[i].endsWith,
- OUString(
- data[i].str1, data[i].str1Len,
- RTL_TEXTENCODING_ASCII_US).endsWithIgnoreAsciiCaseAsciiL(
- data[i].str2, data[i].str2Len));
+ msg.append(bEndsWith);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.getStr(), bEndsWith,
+ OUString(pStr1, nStr1Len, RTL_TEXTENCODING_ASCII_US)
+ .endsWithIgnoreAsciiCaseAsciiL(pStr2, nStr2Len));
}
}
diff --git a/sal/qa/rtl/textenc/rtl_textcvt.cxx b/sal/qa/rtl/textenc/rtl_textcvt.cxx
index 05aab30a063a..e64dbd4c5e03 100644
--- a/sal/qa/rtl/textenc/rtl_textcvt.cxx
+++ b/sal/qa/rtl/textenc/rtl_textcvt.cxx
@@ -1353,8 +1353,9 @@ void Test::testSingleByte() {
0x03A6,0x0398,0x03A9,0x03B4,0x221E,0x03C6,0x03B5,0x2229,
0x2261,0x00B1,0x2265,0x2264,0x2320,0x2321,0x00F7,0x2248,
0x00B0,0x2219,0x00B7,0x221A,0x207F,0x00B2,0x25A0,0x00A0 } } };
- for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
- testSingleByteCharSet(data[i]);
+ for (auto const& aDatum : data)
+ {
+ testSingleByteCharSet(aDatum);
}
}
@@ -2628,8 +2629,9 @@ void Test::testComplex() {
RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR }
#endif
};
- for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
- doComplexCharSetTest(data[i]);
+ for (auto const& aDatum : data)
+ {
+ doComplexCharSetTest(aDatum);
}
}
@@ -2723,8 +2725,9 @@ void Test::testComplexCut() {
false,
false,
RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR } */ };
- for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
- doComplexCharSetCutTest(data[i]);
+ for (auto const& aDatum : data)
+ {
+ doComplexCharSetCutTest(aDatum);
}
#endif
}
@@ -3189,21 +3192,21 @@ void Test::testMime() {
{ "CP154", RTL_TEXTENCODING_PT154, false },
{ "Cyrillic-Asian", RTL_TEXTENCODING_PT154, false }
};
- for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
- if (data[i].mime == nullptr) {
- OSL_ASSERT(data[i].reverse);
- CPPUNIT_ASSERT_EQUAL(
- static_cast< char const * >(nullptr),
- rtl_getMimeCharsetFromTextEncoding(data[i].encoding));
- } else {
- CPPUNIT_ASSERT_EQUAL(
- data[i].encoding,
- rtl_getTextEncodingFromMimeCharset(data[i].mime));
- if (data[i].reverse) {
- CPPUNIT_ASSERT_EQUAL(
- OString(data[i].mime),
- OString(
- rtl_getMimeCharsetFromTextEncoding(data[i].encoding)));
+ for (auto const[pMime,nEncoding,bReverse] : data)
+ {
+ if (pMime == nullptr)
+ {
+ OSL_ASSERT(bReverse);
+ CPPUNIT_ASSERT_EQUAL(static_cast< char const * >(nullptr),
+ rtl_getMimeCharsetFromTextEncoding(nEncoding));
+ }
+ else
+ {
+ CPPUNIT_ASSERT_EQUAL(nEncoding, rtl_getTextEncodingFromMimeCharset(pMime));
+ if (bReverse)
+ {
+ CPPUNIT_ASSERT_EQUAL(OString(pMime),
+ OString( rtl_getMimeCharsetFromTextEncoding(nEncoding)));
}
}
}
@@ -3290,17 +3293,16 @@ void Test::testWindows() {
{ 0, RTL_TEXTENCODING_UCS2, true },
{ 57002, RTL_TEXTENCODING_ISCII_DEVANAGARI, true }
};
- for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
- OSL_ASSERT(data[i].codePage != 0 || data[i].reverse);
- if (data[i].codePage != 0) {
- CPPUNIT_ASSERT_EQUAL(
- data[i].encoding,
- rtl_getTextEncodingFromWindowsCodePage(data[i].codePage));
+ for (auto const[nCodePage,nEncoding,bReverse] : data)
+ {
+ OSL_ASSERT(nCodePage != 0 || bReverse);
+ if (nCodePage != 0)
+ {
+ CPPUNIT_ASSERT_EQUAL( nEncoding, rtl_getTextEncodingFromWindowsCodePage(nCodePage));
}
- if (data[i].reverse) {
- CPPUNIT_ASSERT_EQUAL(
- data[i].codePage,
- rtl_getWindowsCodePageFromTextEncoding(data[i].encoding));
+ if (bReverse)
+ {
+ CPPUNIT_ASSERT_EQUAL( nCodePage, rtl_getWindowsCodePageFromTextEncoding(nEncoding));
}
}
}
@@ -3364,11 +3366,12 @@ void Test::testInfo() {
{ RTL_TEXTENCODING_PT154, RTL_TEXTENCODING_INFO_ASCII, true },
{ RTL_TEXTENCODING_PT154, RTL_TEXTENCODING_INFO_MIME, true }
};
- for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
+ for (auto const[nEncoding, nFlag, bValue] : data)
+ {
rtl_TextEncodingInfo info;
info.StructSize = sizeof info;
- CPPUNIT_ASSERT(rtl_getTextEncodingInfo(data[i].encoding, &info));
- CPPUNIT_ASSERT_EQUAL(data[i].value, ((info.Flags & data[i].flag) != 0));
+ CPPUNIT_ASSERT(rtl_getTextEncodingInfo(nEncoding, &info));
+ CPPUNIT_ASSERT_EQUAL(bValue, ((info.Flags & nFlag) != 0));
}
}
diff --git a/sal/qa/rtl/uri/rtl_testuri.cxx b/sal/qa/rtl/uri/rtl_testuri.cxx
index fc45ba238f2c..3b119820aea9 100644
--- a/sal/qa/rtl/uri/rtl_testuri.cxx
+++ b/sal/qa/rtl/uri/rtl_testuri.cxx
@@ -326,31 +326,25 @@ void Test::test_Uri() {
{ "http://a/b/c/", "d", "http://a/b/c/d" },
{ "http://a/b/c//", "d", "http://a/b/c//d" } };
- for (std::size_t i = 0; i < SAL_N_ELEMENTS(aRelToAbsTest); ++i)
+ for (auto const[pBase, pRel, pAbs] : aRelToAbsTest)
{
- OUString aAbs;
+ OUString aAbsResult;
bool bMalformed = false;
- try {
- aAbs = rtl::Uri::convertRelToAbs(
- OUString::createFromAscii(aRelToAbsTest[i].pBase),
- OUString::createFromAscii(aRelToAbsTest[i].pRel));
- } catch (const rtl::MalformedUriException &) {
+ try
+ {
+ aAbsResult = rtl::Uri::convertRelToAbs(OUString::createFromAscii(pBase),
+ OUString::createFromAscii(pRel));
+ }
+ catch (const rtl::MalformedUriException &)
+ {
bMalformed = true;
}
- if (bMalformed
- ? aRelToAbsTest[i].pAbs != nullptr
- : (aRelToAbsTest[i].pAbs == nullptr
- || !aAbs.equalsAscii(aRelToAbsTest[i].pAbs)))
+ if (bMalformed ? pAbs != nullptr : (pAbs == nullptr || !aAbsResult.equalsAscii(pAbs)))
{
- printf(
- "FAILED convertRelToAbs(%s, %s) -> %s != %s\n",
- aRelToAbsTest[i].pBase, aRelToAbsTest[i].pRel,
- (bMalformed
- ? "<MALFORMED>"
- : OUStringToOString(
- aAbs, RTL_TEXTENCODING_UTF8).getStr()),
- (aRelToAbsTest[i].pAbs == nullptr
- ? "<MALFORMED>" : aRelToAbsTest[i].pAbs));
+ printf("FAILED convertRelToAbs(%s, %s) -> %s != %s\n", pBase, pRel,
+ (bMalformed ? "<MALFORMED>"
+ : OUStringToOString(aAbsResult, RTL_TEXTENCODING_UTF8).getStr()),
+ (pAbs == nullptr ? "<MALFORMED>" : pAbs));
CPPUNIT_ASSERT(false);
}
}
diff --git a/sc/qa/unit/subsequent_export_test.cxx b/sc/qa/unit/subsequent_export_test.cxx
index 76459e765347..e528e3fc679c 100644
--- a/sc/qa/unit/subsequent_export_test.cxx
+++ b/sc/qa/unit/subsequent_export_test.cxx
@@ -2179,29 +2179,27 @@ void ScExportTest::testExcelCellBorders(const OUString& sFormatType)
{
ScDocument* pDoc = getScDoc();
- for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
+ for (auto const[nRow, eStyle, nWidth] : aChecks)
{
const editeng::SvxBorderLine* pLine = nullptr;
- pDoc->GetBorderLines(2, aChecks[i].mnRow, 0, nullptr, &pLine, nullptr, nullptr);
+ pDoc->GetBorderLines(2, nRow, 0, nullptr, &pLine, nullptr, nullptr);
CPPUNIT_ASSERT(pLine);
- CPPUNIT_ASSERT_EQUAL(toBorderName(aChecks[i].mnStyle),
- toBorderName(pLine->GetBorderLineStyle()));
- if (aChecks[i].mnWidth >= 0)
- CPPUNIT_ASSERT_EQUAL(aChecks[i].mnWidth, pLine->GetWidth());
+ CPPUNIT_ASSERT_EQUAL(toBorderName(eStyle), toBorderName(pLine->GetBorderLineStyle()));
+ if (nWidth >= 0)
+ CPPUNIT_ASSERT_EQUAL(nWidth, pLine->GetWidth());
}
}
saveAndReload(sFormatType);
ScDocument* pDoc = getScDoc();
- for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
+ for (auto const[nRow, eStyle, nWidth] : aChecks)
{
const editeng::SvxBorderLine* pLine = nullptr;
- pDoc->GetBorderLines(2, aChecks[i].mnRow, 0, nullptr, &pLine, nullptr, nullptr);
+ pDoc->GetBorderLines(2, nRow, 0, nullptr, &pLine, nullptr, nullptr);
CPPUNIT_ASSERT(pLine);
- CPPUNIT_ASSERT_EQUAL(toBorderName(aChecks[i].mnStyle),
- toBorderName(pLine->GetBorderLineStyle()));
- if (aChecks[i].mnWidth >= 0)
- CPPUNIT_ASSERT_EQUAL(aChecks[i].mnWidth, pLine->GetWidth());
+ CPPUNIT_ASSERT_EQUAL(toBorderName(eStyle), toBorderName(pLine->GetBorderLineStyle()));
+ if (nWidth >= 0)
+ CPPUNIT_ASSERT_EQUAL(nWidth, pLine->GetWidth());
}
}
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);
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index a8c76bef1883..33511c471733 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -135,12 +135,12 @@ void SwMacrosTest::testVba()
}
};
- for ( size_t i=0; i<SAL_N_ELEMENTS( testInfo ); ++i )
+ for (auto const & [ sFileBaseName, sMacroUrl ] : testInfo)
{
- OUString sFileName("docm/" + testInfo[i].sFileBaseName);
+ OUString sFileName("docm/" + sFileBaseName);
loadFromURL(sFileName);
- uno::Any aRet = executeMacro(testInfo[i].sMacroUrl);
+ uno::Any aRet = executeMacro(sMacroUrl);
OUString aStringRes;
CPPUNIT_ASSERT_MESSAGE(sFileName.toUtf8().getStr(), aRet >>= aStringRes);
CPPUNIT_ASSERT_EQUAL(OUString("OK"), aStringRes);
diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx
index ec88381e39fe..103892a7723a 100644
--- a/sw/qa/extras/odfexport/odfexport2.cxx
+++ b/sw/qa/extras/odfexport/odfexport2.cxx
@@ -121,7 +121,7 @@ DECLARE_ODFEXPORT_TEST(testReferenceLanguage, "referencelanguage.odt")
uno::Any aHu(OUString("Hu"));
uno::Any ahu(OUString("hu"));
- for (size_t i = 0; i < SAL_N_ELEMENTS(aFieldTexts); i++)
+ for (auto const& sFieldText : aFieldTexts)
{
uno::Any aField = xFields->nextElement();
uno::Reference<lang::XServiceInfo> xServiceInfo(aField, uno::UNO_QUERY);
@@ -131,7 +131,7 @@ DECLARE_ODFEXPORT_TEST(testReferenceLanguage, "referencelanguage.odt")
uno::Any aLang = xPropertySet->getPropertyValue("ReferenceFieldLanguage");
CPPUNIT_ASSERT_EQUAL(true, aLang == aHu || aLang == ahu);
uno::Reference<text::XTextContent> xField(aField, uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(aFieldTexts[i], xField->getAnchor()->getString());
+ CPPUNIT_ASSERT_EQUAL(sFieldText, xField->getAnchor()->getString());
}
}
}
diff --git a/xmloff/qa/unit/uxmloff.cxx b/xmloff/qa/unit/uxmloff.cxx
index 9cad246f976e..86c98989d8cb 100644
--- a/xmloff/qa/unit/uxmloff.cxx
+++ b/xmloff/qa/unit/uxmloff.cxx
@@ -200,7 +200,7 @@ void Test::testMetaGenerator()
{ "LibreOfficeDev/7.0.6.0.0$Linux_X86_64 LibreOffice_project/dfc40e2292c6e19e285c10ed8c8044d9454107d0", ";70600", SvXMLImport::LO_7x },
};
- for (size_t i = 0; i < SAL_N_ELEMENTS(tests); ++i)
+ for (auto const[pGenerator, pBuildId, nResult] : tests)
{
// the DocumentInfo instance is cached so need fresh SvXMLImport
rtl::Reference<SvXMLImport> const pImport(new SvXMLImport(
@@ -209,18 +209,17 @@ void Test::testMetaGenerator()
pImport->initialize(uno::Sequence<uno::Any>{ uno::Any(xInfoSet) });
- SvXMLMetaDocumentContext::setBuildId(
- OUString::createFromAscii(tests[i].generator), xInfoSet);
- if (tests[i].buildId[0] != '\0')
+ SvXMLMetaDocumentContext::setBuildId(OUString::createFromAscii(pGenerator), xInfoSet);
+ if (pBuildId[0] != '\0')
{
- CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(tests[i].buildId),
- xInfoSet->getPropertyValue("BuildId").get<OUString>());
+ CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(pBuildId),
+ xInfoSet->getPropertyValue("BuildId").get<OUString>());
}
else
{
CPPUNIT_ASSERT(!xInfoSet->getPropertyValue("BuildId").hasValue());
}
- CPPUNIT_ASSERT_EQUAL(tests[i].result, pImport->getGeneratorVersion());
+ CPPUNIT_ASSERT_EQUAL(nResult, pImport->getGeneratorVersion());
}
}