mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 21:13:35 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace stl_helpers_tests
|
||||
{
|
||||
using namespace base;
|
||||
@@ -35,8 +34,7 @@ void TestSortUnique()
|
||||
{
|
||||
using Value = int;
|
||||
using Pair = std::pair<Value, int>;
|
||||
Cont<Pair> d =
|
||||
{{1, 22}, {2, 33}, {1, 23}, {4, 54}, {3, 34}, {5, 23}, {2, 23}, {7, 32}, {1, 12}};
|
||||
Cont<Pair> d = {{1, 22}, {2, 33}, {1, 23}, {4, 54}, {3, 34}, {5, 23}, {2, 23}, {7, 32}, {1, 12}};
|
||||
|
||||
SortUnique(d, LessBy(&Pair::first), EqualsBy(&Pair::first));
|
||||
|
||||
@@ -48,8 +46,7 @@ void TestSortUnique()
|
||||
{
|
||||
using Value = double;
|
||||
using Pair = std::pair<Value, int>;
|
||||
Cont<Pair> d =
|
||||
{{0.5, 11}, {1000.99, 234}, {0.5, 23}, {1234.56789, 54}, {1000.99, 34}};
|
||||
Cont<Pair> d = {{0.5, 11}, {1000.99, 234}, {0.5, 23}, {1234.56789, 54}, {1000.99, 34}};
|
||||
|
||||
SortUnique(d, LessBy(&Pair::first), EqualsBy(&Pair::first));
|
||||
|
||||
@@ -155,17 +152,18 @@ UNIT_TEST(IgnoreFirstArgument)
|
||||
|
||||
namespace
|
||||
{
|
||||
struct EqualZero
|
||||
{
|
||||
bool operator() (int x) { return (x == 0); }
|
||||
};
|
||||
struct EqualZero
|
||||
{
|
||||
bool operator()(int x) { return (x == 0); }
|
||||
};
|
||||
|
||||
template <class ContT> void CheckNoZero(ContT & c, typename ContT::iterator i)
|
||||
{
|
||||
c.erase(i, c.end());
|
||||
TEST(find_if(c.begin(), c.end(), EqualZero()) == c.end(), ());
|
||||
}
|
||||
template <class ContT>
|
||||
void CheckNoZero(ContT & c, typename ContT::iterator i)
|
||||
{
|
||||
c.erase(i, c.end());
|
||||
TEST(find_if(c.begin(), c.end(), EqualZero()) == c.end(), ());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(RemoveIfKeepValid)
|
||||
{
|
||||
@@ -222,20 +220,18 @@ UNIT_TEST(RemoveIfKeepValid)
|
||||
|
||||
namespace
|
||||
{
|
||||
template <class T, size_t N1, size_t N2, size_t N3>
|
||||
void CheckAccumulateIntervals(size_t & idTest,
|
||||
std::pair<T, T> (&arr1)[N1],
|
||||
std::pair<T, T> (&arr2)[N2],
|
||||
std::pair<T, T> (&arr3)[N3])
|
||||
{
|
||||
std::vector<std::pair<T, T> > res;
|
||||
AccumulateIntervals1With2(arr1, arr1 + N1, arr2, arr2 + N2, back_inserter(res));
|
||||
template <class T, size_t N1, size_t N2, size_t N3>
|
||||
void CheckAccumulateIntervals(size_t & idTest, std::pair<T, T> (&arr1)[N1], std::pair<T, T> (&arr2)[N2],
|
||||
std::pair<T, T> (&arr3)[N3])
|
||||
{
|
||||
std::vector<std::pair<T, T>> res;
|
||||
AccumulateIntervals1With2(arr1, arr1 + N1, arr2, arr2 + N2, back_inserter(res));
|
||||
|
||||
++idTest;
|
||||
TEST_EQUAL(N3, res.size(), ("Test", idTest, res));
|
||||
TEST(equal(res.begin(), res.end(), arr3), ("Test", idTest, res));
|
||||
}
|
||||
++idTest;
|
||||
TEST_EQUAL(N3, res.size(), ("Test", idTest, res));
|
||||
TEST(equal(res.begin(), res.end(), arr3), ("Test", idTest, res));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(AccumulateIntervals)
|
||||
{
|
||||
@@ -245,7 +241,7 @@ UNIT_TEST(AccumulateIntervals)
|
||||
// bound cases
|
||||
{
|
||||
std::vector<T> res;
|
||||
T arr[] = { T(10, 20) };
|
||||
T arr[] = {T(10, 20)};
|
||||
|
||||
res.clear();
|
||||
AccumulateIntervals1With2(arr, arr + 1, arr, arr, back_inserter(res));
|
||||
@@ -258,71 +254,65 @@ UNIT_TEST(AccumulateIntervals)
|
||||
|
||||
// check splice overlapped
|
||||
{
|
||||
T arr1[] = { T(10, 20), T(30, 40) };
|
||||
T arr2[] = { T(19, 31) };
|
||||
T res[] = { T(10, 40) };
|
||||
T arr1[] = {T(10, 20), T(30, 40)};
|
||||
T arr2[] = {T(19, 31)};
|
||||
T res[] = {T(10, 40)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
|
||||
// check skip not overlapped
|
||||
{
|
||||
T arr1[] = { T(10, 20), T(30, 40) };
|
||||
T arr2[] = { T(0, 9), T(21, 29), T(41, 50) };
|
||||
T res[2] = { T(10, 20), T(30, 40) };
|
||||
T arr1[] = {T(10, 20), T(30, 40)};
|
||||
T arr2[] = {T(0, 9), T(21, 29), T(41, 50)};
|
||||
T res[2] = {T(10, 20), T(30, 40)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
{
|
||||
T arr1[] = { T(10, 20), T(30, 40) };
|
||||
T arr2[] = { T(1, 2), T(3, 4), T(5, 6),
|
||||
T(21, 22), T(23, 24), T(25, 26),
|
||||
T(41, 42), T(43, 44), T(45, 46)
|
||||
};
|
||||
T res[] = { T(10, 20), T(30, 40) };
|
||||
T arr1[] = {T(10, 20), T(30, 40)};
|
||||
T arr2[] = {T(1, 2), T(3, 4), T(5, 6), T(21, 22), T(23, 24), T(25, 26), T(41, 42), T(43, 44), T(45, 46)};
|
||||
T res[] = {T(10, 20), T(30, 40)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
|
||||
// check equal bounds
|
||||
{
|
||||
T arr1[] = { T(20, 30) };
|
||||
T arr2[] = { T(10, 20), T(30, 40) };
|
||||
T res[] = { T(20, 30) };
|
||||
T arr1[] = {T(20, 30)};
|
||||
T arr2[] = {T(10, 20), T(30, 40)};
|
||||
T res[] = {T(20, 30)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
{
|
||||
T arr1[] = { T(10, 20), T(30, 40) };
|
||||
T arr2[] = { T(20, 30) };
|
||||
T res[] = { T(10, 20), T(30, 40) };
|
||||
T arr1[] = {T(10, 20), T(30, 40)};
|
||||
T arr2[] = {T(20, 30)};
|
||||
T res[] = {T(10, 20), T(30, 40)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
|
||||
// check large overlap interval
|
||||
{
|
||||
T arr1[] = { T(10, 20), T(30, 40), T(50, 60) };
|
||||
T arr2[] = { T(0, 100) };
|
||||
T res[] = { T(0, 100) };
|
||||
T arr1[] = {T(10, 20), T(30, 40), T(50, 60)};
|
||||
T arr2[] = {T(0, 100)};
|
||||
T res[] = {T(0, 100)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
{
|
||||
T arr1[] = { T(0, 100) };
|
||||
T arr2[] = { T(10, 20), T(30, 40), T(50, 60) };
|
||||
T res[] = { T(0, 100) };
|
||||
T arr1[] = {T(0, 100)};
|
||||
T arr2[] = {T(10, 20), T(30, 40), T(50, 60)};
|
||||
T res[] = {T(0, 100)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
|
||||
// check splice overlapped
|
||||
{
|
||||
T arr1[] = { T(10, 20), T(30, 40) };
|
||||
T arr2[] = { T(5, 15), T(35, 45) };
|
||||
T res[] = { T(5, 20), T(30, 45) };
|
||||
T arr1[] = {T(10, 20), T(30, 40)};
|
||||
T arr2[] = {T(5, 15), T(35, 45)};
|
||||
T res[] = {T(5, 20), T(30, 45)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
{
|
||||
T arr1[] = { T(10, 20), T(30, 40) };
|
||||
T arr2[] = { T(1, 2), T(3, 4), T(5, 15),
|
||||
T(17, 25), T(26, 27), T(28, 32),
|
||||
T(38, 45), T(46, 50)
|
||||
};
|
||||
T res[] = { T(5, 25), T(28, 45) };
|
||||
T arr1[] = {T(10, 20), T(30, 40)};
|
||||
T arr2[] = {T(1, 2), T(3, 4), T(5, 15), T(17, 25), T(26, 27), T(28, 32), T(38, 45), T(46, 50)};
|
||||
T res[] = {T(5, 25), T(28, 45)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
}
|
||||
@@ -353,6 +343,7 @@ UNIT_TEST(Map_EmplaceOrAssign)
|
||||
|
||||
Obj(Obj const &) = delete;
|
||||
Obj & operator=(Obj const &) = delete;
|
||||
|
||||
public:
|
||||
Obj(int v) : m_v(v) {}
|
||||
Obj(Obj &&) = default;
|
||||
@@ -370,4 +361,4 @@ UNIT_TEST(Map_EmplaceOrAssign)
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace stl_helpers_test
|
||||
} // namespace stl_helpers_tests
|
||||
|
||||
Reference in New Issue
Block a user