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>
This commit is contained in:
committed by
Christian Lohmaier
parent
856bdfb058
commit
6d5ff94b99
+28
-31
@@ -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;
|
||||
|
||||
@@ -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: */
|
||||
|
||||
@@ -7671,8 +7671,6 @@ o3tl/qa/cow_wrapper_clients.cxx
|
||||
o3tl/qa/cow_wrapper_clients.hxx
|
||||
o3tl/qa/test-cow_wrapper.cxx
|
||||
o3tl/qa/test-enumarray.cxx
|
||||
o3tl/qa/test-lru_map.cxx
|
||||
o3tl/qa/test-safeint.cxx
|
||||
o3tl/qa/test-sorted_vector.cxx
|
||||
o3tl/qa/test-span.cxx
|
||||
o3tl/qa/test-typed_flags.cxx
|
||||
|
||||
Reference in New Issue
Block a user