test/source/beans/xpropertyset.cxx | 3 - test/source/sheet/databaseimportdescriptor.cxx | 42 ++++++++++++------------- test/source/sheet/xdatabaserange.cxx | 3 - test/source/sheet/xdatapilottable2.cxx | 15 ++++---- test/source/sheet/xsubtotalfield.cxx | 4 +- test/source/text/textcontent.cxx | 2 - 6 files changed, 34 insertions(+), 35 deletions(-)
New commits: commit 706798376f42771f9c644852eeaeed5540f421ef Author: Arkadiy Illarionov <qar...@gmail.com> AuthorDate: Sun Jun 30 20:50:45 2019 +0300 Commit: Arkadiy Illarionov <qar...@gmail.com> CommitDate: Mon Jul 1 07:18:16 2019 +0200 Simplify Sequence iterations in test Use range-based loops or replace with STL functions Change-Id: I93efa86f49eb49dbdd3b7572dbd538bc300ded05 Reviewed-on: https://gerrit.libreoffice.org/74932 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qar...@gmail.com> diff --git a/test/source/beans/xpropertyset.cxx b/test/source/beans/xpropertyset.cxx index f8ac7d17f206..c1638ca0e548 100644 --- a/test/source/beans/xpropertyset.cxx +++ b/test/source/beans/xpropertyset.cxx @@ -283,9 +283,8 @@ void XPropertySet::fillPropsToTest(const uno::Reference<beans::XPropertySetInfo> aSkip.insert("CharRelief"); aSkip.insert("IsLayerMode"); - for (sal_Int32 i = 0; i < aProps.getLength(); ++i) + for (const beans::Property& aProp : aProps) { - beans::Property aProp = aProps[i]; if (aSkip.count(aProp.Name) > 0) continue; diff --git a/test/source/sheet/databaseimportdescriptor.cxx b/test/source/sheet/databaseimportdescriptor.cxx index acbe44b1ff71..482af249e5e9 100644 --- a/test/source/sheet/databaseimportdescriptor.cxx +++ b/test/source/sheet/databaseimportdescriptor.cxx @@ -30,69 +30,69 @@ void DatabaseImportDescriptor::testDatabaseImportDescriptorProperties() uno::Reference<util::XImportable> xImportable(getXImportable(), UNO_QUERY_THROW); uno::Sequence<beans::PropertyValue> aPropValues = xImportable->createImportDescriptor(true); - for (auto i = 0; i < aPropValues.getLength(); i++) + for (auto& rPropValue : aPropValues) { uno::Any aOldValue; uno::Any aNewValue; - if (aPropValues[i].Name == "DatabaseName" || aPropValues[i].Name == "SourceObject" - || aPropValues[i].Name == "ConnectionResource") + if (rPropValue.Name == "DatabaseName" || rPropValue.Name == "SourceObject" + || rPropValue.Name == "ConnectionResource") { OUString aValue; - aOldValue = aPropValues[i].Value; + aOldValue = rPropValue.Value; aOldValue >>= aValue; OString aMsgGet = "Unable to get PropertyValue " - + OUStringToOString(aPropValues[i].Name, RTL_TEXTENCODING_UTF8); + + OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgGet.getStr(), OUString(""), aValue); aNewValue <<= OUString("New"); - aPropValues[i].Value = aNewValue; + rPropValue.Value = aNewValue; - aOldValue = aPropValues[i].Value; + aOldValue = rPropValue.Value; aOldValue >>= aValue; OString aMsgSet = "Unable to set PropertyValue " - + OUStringToOString(aPropValues[i].Name, RTL_TEXTENCODING_UTF8); + + OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgSet.getStr(), OUString("New"), aValue); } - else if (aPropValues[i].Name == "IsNative") + else if (rPropValue.Name == "IsNative") { bool aValue = true; - aOldValue = aPropValues[i].Value; + aOldValue = rPropValue.Value; aOldValue >>= aValue; OString aMsgGet = "Unable to get PropertyValue " - + OUStringToOString(aPropValues[i].Name, RTL_TEXTENCODING_UTF8); + + OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_MESSAGE(aMsgGet.getStr(), !aValue); aNewValue <<= true; - aPropValues[i].Value = aNewValue; + rPropValue.Value = aNewValue; - aOldValue = aPropValues[i].Value; + aOldValue = rPropValue.Value; aOldValue >>= aValue; OString aMsgSet = "Unable to set PropertyValue " - + OUStringToOString(aPropValues[i].Name, RTL_TEXTENCODING_UTF8); + + OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_MESSAGE(aMsgSet.getStr(), aValue); } - else if (aPropValues[i].Name == "SourceType") + else if (rPropValue.Name == "SourceType") { sheet::DataImportMode aValue; - aOldValue = aPropValues[i].Value; + aOldValue = rPropValue.Value; aOldValue >>= aValue; OString aMsgGet = "Unable to get PropertyValue " - + OUStringToOString(aPropValues[i].Name, RTL_TEXTENCODING_UTF8); + + OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgGet.getStr(), sheet::DataImportMode_NONE, aValue); aNewValue <<= sheet::DataImportMode_SQL; - aPropValues[i].Value = aNewValue; + rPropValue.Value = aNewValue; - aOldValue = aPropValues[i].Value; + aOldValue = rPropValue.Value; aOldValue >>= aValue; OString aMsgSet = "Unable to set PropertyValue " - + OUStringToOString(aPropValues[i].Name, RTL_TEXTENCODING_UTF8); + + OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgSet.getStr(), sheet::DataImportMode_SQL, aValue); } else { OString aMsg = "Unsupported PropertyValue " - + OUStringToOString(aPropValues[i].Name, RTL_TEXTENCODING_UTF8); + + OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8); CPPUNIT_FAIL(aMsg.getStr()); } } diff --git a/test/source/sheet/xdatabaserange.cxx b/test/source/sheet/xdatabaserange.cxx index 36ce1d5362fb..756d204ff597 100644 --- a/test/source/sheet/xdatabaserange.cxx +++ b/test/source/sheet/xdatabaserange.cxx @@ -65,9 +65,8 @@ void XDatabaseRange::testGetSortDescriptor() { uno::Reference< sheet::XDatabaseRange > xDBRange(init("SortDescriptor"), UNO_QUERY_THROW); uno::Sequence< beans::PropertyValue > xSortDescr = xDBRange->getSortDescriptor(); - for (sal_Int32 i = 0; i < xSortDescr.getLength(); ++i) + for (const beans::PropertyValue& aProp : xSortDescr) { - beans::PropertyValue aProp = xSortDescr[i]; //std::cout << "Prop " << i << " Name: " << OUString(aProp.Name) << std::endl; if (aProp.Name == "IsSortColumns") diff --git a/test/source/sheet/xdatapilottable2.cxx b/test/source/sheet/xdatapilottable2.cxx index 7e4714db2378..98ecf2742453 100644 --- a/test/source/sheet/xdatapilottable2.cxx +++ b/test/source/sheet/xdatapilottable2.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/sheet/DataResult.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <cppunit/extensions/HelperMacros.h> +#include <numeric> using namespace css; using namespace css::uno; @@ -78,13 +79,13 @@ void XDataPilotTable2::testGetDrillDownData() if( aData.getLength() > 1 ) { - for ( sal_Int32 row = 1; row < aData.getLength(); ++row) - { - Any aAny = aData[row][nDim]; - double nValue = 0; - if (aAny >>= nValue) - sum += nValue; - } + sum = std::accumulate(std::next(aData.begin()), aData.end(), double(0), + [nDim](double res, const Sequence<Any>& rSeq) { + double nValue = 0; + if (rSeq[nDim] >>= nValue) + return res + nValue; + return res; + }); } CPPUNIT_ASSERT_DOUBLES_EQUAL(nVal, sum, 1E-12); diff --git a/test/source/sheet/xsubtotalfield.cxx b/test/source/sheet/xsubtotalfield.cxx index 41824a1d0f64..dfd48f849e6e 100644 --- a/test/source/sheet/xsubtotalfield.cxx +++ b/test/source/sheet/xsubtotalfield.cxx @@ -35,8 +35,8 @@ template<> struct assertion_traits<uno::Sequence< sheet::SubTotalColumn > > { OStringStream ost; ost << "Sequence: Length: " << x.getLength() << "\n"; - for (auto element = x.begin(); element != x.end(); ++element) - ost << "Column: " << element->Column << " Function:\n"; + for (const auto& rElement : x) + ost << "Column: " << rElement.Column << " Function:\n"; // FIXME: Find a way to print Function //ost << "Column: " << element->Column << " Function: " << element->Function << "\n"; return ost.str(); diff --git a/test/source/text/textcontent.cxx b/test/source/text/textcontent.cxx index 714011117ca0..36451bb7a37f 100644 --- a/test/source/text/textcontent.cxx +++ b/test/source/text/textcontent.cxx @@ -44,7 +44,7 @@ void TextContent::testTextContentProperties() uno::Sequence<text::TextContentAnchorType> aAnchorTypes; CPPUNIT_ASSERT(xPS->getPropertyValue("AnchorTypes") >>= aAnchorTypes); - CPPUNIT_ASSERT(aAnchorTypes.getLength()); + CPPUNIT_ASSERT(aAnchorTypes.hasElements()); text::WrapTextMode aExpectedWTM; CPPUNIT_ASSERT(xPS->getPropertyValue("TextWrap") >>= aExpectedWTM); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits