summaryrefslogtreecommitdiff
path: root/o3tl
diff options
context:
space:
mode:
authorPhilipp Hofer <philipp.hofer@protonmail.com>2020-11-12 13:07:41 +0100
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2020-11-18 12:55:43 +0100
commit6d5ff94b994e7279cea3d54d9d546f4f1a8cdb4d (patch)
treec8608a04ae05f60940806537665fd0a7327839c9 /o3tl
parent856bdfb0585cea3c67eedfb535c6477d51e4c352 (diff)
tdf#123936 Formatting files in module o3tl with clang-format
Change-Id: Ieb1229869cae8c14480243af98b270b9053fbde1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105691 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'o3tl')
-rw-r--r--o3tl/qa/test-lru_map.cxx59
-rw-r--r--o3tl/qa/test-safeint.cxx14
2 files changed, 36 insertions, 37 deletions
diff --git a/o3tl/qa/test-lru_map.cxx b/o3tl/qa/test-lru_map.cxx
index a03a6bf37200..ba9ee71835ce 100644
--- a/o3tl/qa/test-lru_map.cxx
+++ b/o3tl/qa/test-lru_map.cxx
@@ -103,7 +103,6 @@ void lru_map_test::testReplaceValue()
CPPUNIT_ASSERT_EQUAL(size_t(2), lru.size());
CPPUNIT_ASSERT_EQUAL(6, lru.find(1)->second);
CPPUNIT_ASSERT_EQUAL(300, lru.find(3)->second);
-
}
void lru_map_test::testReplaceKey()
@@ -182,8 +181,8 @@ void lru_map_test::testLruRemoval()
CPPUNIT_ASSERT_EQUAL(700, lru.find(7)->second);
}
-namespace {
-
+namespace
+{
struct TestClassKey
{
int mA;
@@ -192,13 +191,10 @@ struct TestClassKey
TestClassKey(int a, int b)
: mA(a)
, mB(b)
- {}
-
- bool operator==(TestClassKey const& aOther) const
{
- return mA == aOther.mA
- && mB == aOther.mB;
}
+
+ bool operator==(TestClassKey const& aOther) const { return mA == aOther.mA && mB == aOther.mB; }
};
struct TestClassKeyHashFunction
@@ -211,7 +207,6 @@ struct TestClassKeyHashFunction
return seed;
}
};
-
}
void lru_map_test::testCustomHash()
@@ -220,45 +215,47 @@ void lru_map_test::testCustomHash()
o3tl::lru_map<TestClassKey, int, TestClassKeyHashFunction> lru(2);
CPPUNIT_ASSERT_EQUAL(size_t(0), lru.size());
- lru.insert(std::make_pair<TestClassKey, int>(TestClassKey(1,1), 2));
+ lru.insert(std::make_pair<TestClassKey, int>(TestClassKey(1, 1), 2));
CPPUNIT_ASSERT_EQUAL(size_t(1), lru.size());
- lru.insert(std::make_pair<TestClassKey, int>(TestClassKey(1,1), 7));
+ lru.insert(std::make_pair<TestClassKey, int>(TestClassKey(1, 1), 7));
CPPUNIT_ASSERT_EQUAL(size_t(1), lru.size());
- lru.insert(std::make_pair<TestClassKey, int>(TestClassKey(1,2), 9));
+ lru.insert(std::make_pair<TestClassKey, int>(TestClassKey(1, 2), 9));
CPPUNIT_ASSERT_EQUAL(size_t(2), lru.size());
- CPPUNIT_ASSERT(bool(lru.end() == lru.find(TestClassKey(0,0)))); // non existent
- CPPUNIT_ASSERT_EQUAL(7, lru.find(TestClassKey(1,1))->second);
- CPPUNIT_ASSERT_EQUAL(9, lru.find(TestClassKey(1,2))->second);
+ CPPUNIT_ASSERT(bool(lru.end() == lru.find(TestClassKey(0, 0)))); // non existent
+ CPPUNIT_ASSERT_EQUAL(7, lru.find(TestClassKey(1, 1))->second);
+ CPPUNIT_ASSERT_EQUAL(9, lru.find(TestClassKey(1, 2))->second);
- lru.insert(std::make_pair<TestClassKey, int>(TestClassKey(2,1), 13));
+ lru.insert(std::make_pair<TestClassKey, int>(TestClassKey(2, 1), 13));
CPPUNIT_ASSERT_EQUAL(size_t(2), lru.size());
- CPPUNIT_ASSERT(bool(lru.end() == lru.find(TestClassKey(1,1))));
- CPPUNIT_ASSERT_EQUAL(9, lru.find(TestClassKey(1,2))->second);
- CPPUNIT_ASSERT_EQUAL(13, lru.find(TestClassKey(2,1))->second);
+ CPPUNIT_ASSERT(bool(lru.end() == lru.find(TestClassKey(1, 1))));
+ CPPUNIT_ASSERT_EQUAL(9, lru.find(TestClassKey(1, 2))->second);
+ CPPUNIT_ASSERT_EQUAL(13, lru.find(TestClassKey(2, 1))->second);
}
void lru_map_test::testRemoveIf()
{
typedef o3tl::lru_map<int, int> IntMap;
typedef IntMap::key_value_pair_t IntMapPair;
- struct limit_except : public std::exception {};
+ struct limit_except : public std::exception
+ {
+ };
IntMap lru(6);
int i = 0;
for (; i < 8; i++)
- lru.insert({i, i});
+ lru.insert({ i, i });
CPPUNIT_ASSERT_EQUAL(size_t(6), lru.size());
// now contains 7..2
// remove everything < 4 from the back
try
{
- lru.remove_if([] (IntMapPair const& rPair) {
+ lru.remove_if([](IntMapPair const& rPair) {
if (rPair.first >= 4)
throw limit_except();
return true;
@@ -272,26 +269,26 @@ void lru_map_test::testRemoveIf()
}
// remove all even numbers
- lru.remove_if([] (IntMapPair const& rPair) { return (0 == rPair.first % 2); });
+ lru.remove_if([](IntMapPair const& rPair) { return (0 == rPair.first % 2); });
CPPUNIT_ASSERT_EQUAL(size_t(2), lru.size());
// contains 7, 5
- lru.insert({5, 5});
+ lru.insert({ 5, 5 });
// contains 5, 7
i = 5;
- for (auto &rPair : lru)
+ for (auto& rPair : lru)
{
CPPUNIT_ASSERT_EQUAL(i, rPair.first);
i += 2;
}
// remove the first item
- lru.remove_if([] (IntMapPair const& rPair) { return (rPair.first == 5); });
+ lru.remove_if([](IntMapPair const& rPair) { return (rPair.first == 5); });
CPPUNIT_ASSERT_EQUAL(size_t(1), lru.size());
// remove the only item
- lru.remove_if([] (IntMapPair const& rPair) { return (rPair.first == 7); });
+ lru.remove_if([](IntMapPair const& rPair) { return (rPair.first == 7); });
CPPUNIT_ASSERT_EQUAL(size_t(0), lru.size());
}
@@ -299,14 +296,14 @@ void lru_map_test::testNoAutoCleanup()
{
o3tl::lru_map<int, int> lru(0);
CPPUNIT_ASSERT_EQUAL(size_t(0), lru.size());
- lru.insert({0,0});
- lru.insert({1,1});
+ lru.insert({ 0, 0 });
+ lru.insert({ 1, 1 });
CPPUNIT_ASSERT_EQUAL(size_t(2), lru.size());
- lru.insert({0,0});
+ lru.insert({ 0, 0 });
CPPUNIT_ASSERT_EQUAL(size_t(2), lru.size());
int i = 0;
- for (auto &rPair : lru)
+ for (auto& rPair : lru)
{
CPPUNIT_ASSERT_EQUAL(i, rPair.first);
++i;
diff --git a/o3tl/qa/test-safeint.cxx b/o3tl/qa/test-safeint.cxx
index 19269d4b05b3..4c4333082f46 100644
--- a/o3tl/qa/test-safeint.cxx
+++ b/o3tl/qa/test-safeint.cxx
@@ -17,16 +17,18 @@
#include <o3tl/safeint.hxx>
-namespace {
-
-class Test: public CppUnit::TestFixture {
+namespace
+{
+class Test : public CppUnit::TestFixture
+{
private:
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testSignedSaturatingAdd);
CPPUNIT_TEST(testUnsignedSaturatingAdd);
CPPUNIT_TEST_SUITE_END();
- void testSignedSaturatingAdd() {
+ void testSignedSaturatingAdd()
+ {
auto const min = std::numeric_limits<int>::min();
auto const max = std::numeric_limits<int>::max();
@@ -87,7 +89,8 @@ private:
CPPUNIT_ASSERT_EQUAL(max, o3tl::saturating_add(max, max));
}
- void testUnsignedSaturatingAdd() {
+ void testUnsignedSaturatingAdd()
+ {
auto const max = std::numeric_limits<unsigned int>::max();
CPPUNIT_ASSERT_EQUAL(0U, o3tl::saturating_add(0U, 0U));
@@ -113,7 +116,6 @@ private:
};
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */