-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcht_test.cpp
45 lines (42 loc) · 1.31 KB
/
cht_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "cht.hpp"
#include <catch2/catch_test_macros.hpp>
TEST_CASE("cht behaves as expected", "[cht]") {
cht<int> c({{2, 1}, {3, 2}, {1, -2}});
REQUIRE(c.size() == 2);
REQUIRE(c.query(-4).first == -10);
REQUIRE(c.query(-3).second == 1);
REQUIRE(c.query(-3).first == -7);
REQUIRE(c.query(-2).first == -4);
REQUIRE(c.query(0).first == -2);
REQUIRE(c.query(2).first == 0);
REQUIRE(c.query(2).second == 2);
cht<int> c2({{1, 0}, {2, 2}, {-1, 0}});
REQUIRE(c2.size() == 3);
REQUIRE(c2.query(-3).first == -4);
REQUIRE(c2.query(-2).first == -2);
REQUIRE(c2.query(-1).first == -1);
REQUIRE(c2.query(0).first == 0);
REQUIRE(c2.query(1).first == -1);
}
TEST_CASE("lichao_tree behaves as expected", "[cht]") {
lichao_tree<int> c(-100, 100);
c.push_line({2, 1});
c.push_line({3, 2});
c.push_line({1, -2});
REQUIRE(c.query(-4).first == -10);
REQUIRE(c.query(-3).second == 1);
REQUIRE(c.query(-3).first == -7);
REQUIRE(c.query(-2).first == -4);
REQUIRE(c.query(0).first == -2);
REQUIRE(c.query(2).first == 0);
REQUIRE(c.query(2).second == 2);
lichao_tree<int> c2(-100, 100);
c2.push_line({1, 0});
c2.push_line({2, 2});
c2.push_line({-1, 0});
REQUIRE(c2.query(-3).first == -4);
REQUIRE(c2.query(-2).first == -2);
REQUIRE(c2.query(-1).first == -1);
REQUIRE(c2.query(0).first == 0);
REQUIRE(c2.query(1).first == -1);
}