summaryrefslogtreecommitdiff
path: root/test/source/sheet
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-06-30 20:50:45 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-07-01 07:18:16 +0200
commit706798376f42771f9c644852eeaeed5540f421ef (patch)
tree81e4b1e9278694018a3b42f732411fe304427756 /test/source/sheet
parentbfc19d77cb8db445f1c6123347c19a4c0c6a6cf8 (diff)
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 <qarkai@gmail.com>
Diffstat (limited to 'test/source/sheet')
-rw-r--r--test/source/sheet/databaseimportdescriptor.cxx42
-rw-r--r--test/source/sheet/xdatabaserange.cxx3
-rw-r--r--test/source/sheet/xdatapilottable2.cxx15
-rw-r--r--test/source/sheet/xsubtotalfield.cxx4
4 files changed, 32 insertions, 32 deletions
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();