From 479915440d0e1f5607bc5a1a4794df962197a152 Mon Sep 17 00:00:00 2001 From: Wai-Shing Luk Date: Wed, 22 May 2024 19:44:10 +0800 Subject: [PATCH] cleanup --- .hadolint.yaml | 4 -- .isort.cfg | 2 - .markdownlint.yaml | 10 --- .shellcheckrc | 3 - test_interval.cpp | 96 ----------------------------- test_recti.cpp | 62 ------------------- test_recti3d.cpp | 149 --------------------------------------------- 7 files changed, 326 deletions(-) delete mode 100644 .hadolint.yaml delete mode 100644 .isort.cfg delete mode 100644 .markdownlint.yaml delete mode 100644 .shellcheckrc delete mode 100644 test_interval.cpp delete mode 100644 test_recti.cpp delete mode 100644 test_recti3d.cpp diff --git a/.hadolint.yaml b/.hadolint.yaml deleted file mode 100644 index 98bf0cd..0000000 --- a/.hadolint.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Following source doesn't work in most setups -ignored: - - SC1090 - - SC1091 diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index b9fb3f3..0000000 --- a/.isort.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[settings] -profile=black diff --git a/.markdownlint.yaml b/.markdownlint.yaml deleted file mode 100644 index fb94039..0000000 --- a/.markdownlint.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# Autoformatter friendly markdownlint config (all formatting rules disabled) -default: true -blank_lines: false -bullet: false -html: false -indentation: false -line_length: false -spaces: false -url: false -whitespace: false diff --git a/.shellcheckrc b/.shellcheckrc deleted file mode 100644 index ce4686b..0000000 --- a/.shellcheckrc +++ /dev/null @@ -1,3 +0,0 @@ -# Following source doesn't work in most setups -disable=SC1090 -disable=SC1091 diff --git a/test_interval.cpp b/test_interval.cpp deleted file mode 100644 index 0728ad3..0000000 --- a/test_interval.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include // for ResultBuilder, CHECK, Expression_lhs - -#include // for Vdcorput -#include // for list, __list_iterator, operator!= -#include // for operator<< -#include // for Interval, operator<<, operator+, ope... -#include // for set, set<>::iterator - -using recti::Interval; - -TEST_CASE("Interval test") { - auto a = Interval{4, 8}; - auto b = Interval{5, 6}; - auto v = 3; - - CHECK(!(a < b)); - CHECK(!(b < a)); - CHECK(!(a > b)); - CHECK(!(b > a)); - CHECK(a <= b); - CHECK(b <= a); - CHECK(a >= b); - CHECK(b >= a); - - CHECK(!(b == a)); - CHECK(b != a); - - CHECK((a - v) + v == a); - - CHECK(a.contains(4)); - CHECK(a.contains(8)); - CHECK(a.intersect_with(8) == Interval{8, 8}); - CHECK(a.contains(b)); - CHECK(a.intersect_with(b) == b); - CHECK(!b.contains(a)); - CHECK(a.overlaps(b)); - CHECK(b.overlaps(a)); - - CHECK(min_dist(a, b) == 0); -} - -TEST_CASE("Interval of Interval test") { - auto a = Interval{Interval{3, 4}, Interval{8, 9}}; - auto b = Interval{Interval{5, 6}, Interval{6, 7}}; - auto v = 3; - - CHECK(!(a < b)); - CHECK(!(b < a)); - CHECK(!(a > b)); - CHECK(!(b > a)); - CHECK(a <= b); - CHECK(b <= a); - CHECK(a >= b); - CHECK(b >= a); - - CHECK(!(b == a)); - CHECK(b != a); - - CHECK((a - v) + v == a); - - CHECK(a.contains(Interval{4, 5})); - CHECK(a.contains(Interval{7, 8})); - - CHECK(a.intersect_with(Interval{7, 8}) == Interval{Interval{7, 7}, Interval{8, 8}}); // ??? - - CHECK(a.contains(b)); - CHECK(a.intersect_with(b) == b); - CHECK(!b.contains(a)); - CHECK(a.overlaps(b)); - CHECK(b.overlaps(a)); -} - -TEST_CASE("Interval overlapping test") { - constexpr auto N = 20; - auto lst = std::list>{}; - auto hgenX = ildsgen::VdCorput(3, 7); - - for (auto i = 0; i != N; ++i) { - for (auto j = 0; j != N; ++j) { - auto x = hgenX.pop(); - auto xrng = Interval{x, x + 100}; - lst.push_back(xrng); - } - } - - std::set> S; // set of maximal non-overlapped rectangles - std::list> L; // list of the removed rectangles - - for (const auto &intvl : lst) { - if (S.contains(intvl)) { - L.push_back(intvl); - } else { - S.insert(intvl); - } - } -} diff --git a/test_recti.cpp b/test_recti.cpp deleted file mode 100644 index ead1fef..0000000 --- a/test_recti.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include // for ResultBuilder, CHECK, Expression_lhs - -#include // for recti -#include // for Rectangle, HSegment, VSegment -// #include -#include // for operator<< - -#include "recti/interval.hpp" // for Interval, min_dist, overlap -#include "recti/point.hpp" // for Point, operator<<, operator+, operat... -#include "recti/vector2.hpp" // for operator/, vector2 - -// using std::randint; -using namespace recti; - -// template struct my_point : Point { double data; }; - -TEST_CASE("Point test") { - auto a = Point{4, 8}; - auto b = Point{5, 6}; - auto v = (b - a) / 2; // integer division - - CHECK(!(a == b)); - CHECK(a != b); - CHECK((a + v) + v != b); // due to integer division - CHECK((a - v) + v == a); - - CHECK(a.flip_xy().flip_xy() == a); - CHECK(a.flip_y().flip_y() == a); -} - -TEST_CASE("Rectangle test") { - auto xrng1 = Interval{4, 8}; - auto yrng1 = Interval{5, 7}; - auto r1 = Rectangle{xrng1, yrng1}; - auto xrng2 = Interval{5, 7}; - auto yrng2 = Interval{6, 6}; - auto r2 = Rectangle{xrng2, yrng2}; - auto p = Point{7, 6}; - auto v = Vector2{5, 6}; - Rectangle r3 = r1 - v; - - CHECK(r1 != r2); - CHECK(r3 + v == r1); - - // CHECK(r1 <= p); - CHECK(r1.contains(p)); - CHECK(r1.contains(r2)); - CHECK(r1.overlaps(r2)); - CHECK(overlap(r1, r2)); - - CHECK(r1.min_dist_with(r2) == 0); - CHECK(min_dist(r1, r2) == 0); -} - -TEST_CASE("Segment test") { - auto xrng1 = Interval{4, 8}; - auto yrng1 = Interval{5, 7}; - auto s1 = HSegment{xrng1, 6}; - auto s2 = VSegment{5, yrng1}; - - CHECK(s1.overlaps(s2)); -} diff --git a/test_recti3d.cpp b/test_recti3d.cpp deleted file mode 100644 index be6e31a..0000000 --- a/test_recti3d.cpp +++ /dev/null @@ -1,149 +0,0 @@ -#include // for ResultBuilder, CHECK, Expression_lhs - -#include // for operator<< -#include // for recti -#include // for merge_obj -#include // for Rectangle - -#include "recti/interval.hpp" // for min_dist, Interval, overlap -#include "recti/point.hpp" // for Point, operator<<, operator+, operator- -#include "recti/vector2.hpp" // for Vector2, operator/ - -// using std::randint; -using namespace recti; - -// template struct my_point : Point { double data; }; - -TEST_CASE("Point 3D test") { - auto a = Point{Point{40000, 80000}, 20000}; - auto b = Point{Point{50000, 60000}, 10000}; - auto v = (b - a) / 2; // integer division - - CHECK(!(a == b)); - CHECK(a != b); - CHECK((a + v) + v == b); // may not true due to integer division - CHECK((a - v) + v == a); - - CHECK(a.flip_xy().flip_xy() == a); - // CHECK(a.flip_y().flip_y() == a); -} - -TEST_CASE("Interval test") { - auto a = Point{Interval{4, 8}, 1}; - auto b = Point{Interval{5, 6}, 1}; - auto v = Vector2{3, 0}; - - CHECK(!(a < b)); - CHECK(!(b < a)); - CHECK(!(a > b)); - CHECK(!(b > a)); - CHECK(a <= b); - CHECK(b <= a); - CHECK(a >= b); - CHECK(b >= a); - - CHECK(!(b == a)); - CHECK(b != a); - - CHECK((a - v) + v == a); - - CHECK(a.contains(b)); - CHECK(a.intersect_with(b) == b); - CHECK(!b.contains(a)); - CHECK(a.overlaps(b)); - CHECK(b.overlaps(a)); - - CHECK(min_dist(a, b) == 0); -} - -TEST_CASE("Rectangle 3D test") { - auto xrng1 = Interval{40000, 80000}; - auto yrng1 = Interval{50000, 70000}; - auto r1 = Point{Rectangle{xrng1, yrng1}, 1000}; - auto xrng2 = Interval{50000, 70000}; - auto yrng2 = Interval{60000, 60000}; - auto r2 = Point{Rectangle{xrng2, yrng2}, 1000}; - auto v = Vector2{Vector2{50000, 60000}, 0}; - auto p1 = Point{Point{70000, 60000}, 1000}; - auto p2 = Point{Point{70000, 60000}, 2000}; - - CHECK(r1 != r2); - CHECK((r1 - v) + v == r1); - - // CHECK(r1 <= p); - CHECK(r1.contains(p1)); - CHECK(!r1.contains(p2)); - CHECK(r1.contains(r2)); - CHECK(r1.overlaps(r2)); - CHECK(overlap(r1, r2)); - - CHECK(r1.min_dist_with(r2) == 0); - CHECK(min_dist(r1, r2) == 0); - - CHECK(r1.min_dist_with(p2) == p2.min_dist_with(r1)); - // CHECK(min_dist(r1, p2) == min_dist(p2, r1)); -} - -// TEST_CASE("Segment test") { -// auto xrng1 = Interval{4, 8}; -// auto yrng1 = Interval{5, 7}; -// auto s1 = HSegment{xrng1, 6}; -// auto s2 = VSegment{5, yrng1}; - -// CHECK(s1.overlaps(s2)); -// } - -// TEST_CASE("Interval overlapping test") { -// constexpr auto N = 20; -// auto lst = std::list>{}; -// auto hgenX = Vdcorput(3, 7); -// // auto hgenY = Vdcorput(2, 11); - -// for (auto i = 0; i != N; ++i) { -// for (auto j = 0; j != N; ++j) { -// auto xcoord = hgenX(); -// // auto ycoord = hgenY(); -// auto xrng = Interval{xcoord, xcoord + 100}; -// // auto yrng = Interval{ycoord, ycoord + 100}; -// // auto r = Rectangle{xrng, yrng}; -// // lst.push_back(r); -// lst.push_back(xrng); -// } -// } - -// std::set> S; // set of maximal non-overlapped -// rectangles std::list> L; // list of the removed -// rectangles - -// for (const auto& intvl : lst) { -// if (S.find(intvl) != S.end()) { -// L.push_back(intvl); -// } else { -// S.insert(intvl); -// } -// } - -// // for (const auto& r : S) -// // { -// // cout << " \\draw " << r << ";\n"; -// // } -// // for (const auto& r : L) -// // { -// // cout << " \\draw[color=red] " << r << ";\n"; -// // } -// } - -TEST_CASE("MergeObj test") { - auto a = Point{40000, 80000}; - auto b = Point{50000, 60000}; - - auto m1 = MergeObj{a + 50000, a - 50000}; - auto m2 = MergeObj{b + 90000, b - 90000}; - // auto v = Vector2{Vector2{50000, 60000}, 0}; - - CHECK(m1 != m2); - // CHECK((m1 - v) + v == m1); - CHECK(!overlap(m1, m2)); - CHECK(m1.min_dist_with(m2) == m2.min_dist_with(m1)); - CHECK(min_dist(m1, m2) == min_dist(m2, m1)); -}