-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlimits_test.cpp
35 lines (28 loc) · 1.14 KB
/
limits_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
#include "limits.hpp"
#include <catch2/catch_test_macros.hpp>
TEST_CASE("limit for int", "[limits]") {
REQUIRE(cp_limits<int>::infinity() == 0x3f3f3f3f);
REQUIRE(cp_limits<int>::negative_infinity() == -0x3f3f3f3f);
}
TEST_CASE("limit for long long", "[limits]") {
REQUIRE(cp_limits<long long>::infinity() == 0x3f3f3f3f3f3f3f3fLL);
REQUIRE(cp_limits<long long>::negative_infinity() == -0x3f3f3f3f3f3f3f3fLL);
}
TEST_CASE("limit for pair<int, int>", "[limits]") {
REQUIRE(cp_limits<std::pair<int, int>>::infinity() ==
std::make_pair(0x3f3f3f3f, 0x3f3f3f3f));
REQUIRE(cp_limits<std::pair<int, int>>::negative_infinity() ==
std::make_pair(-0x3f3f3f3f, -0x3f3f3f3f));
}
TEST_CASE("limit for char", "[limits]") {
REQUIRE(cp_limits<char>::infinity() > 'z');
REQUIRE(cp_limits<char>::negative_infinity() < ' ');
}
TEST_CASE("limit for size_t", "[limits]") {
REQUIRE(cp_limits<size_t>::infinity() < std::numeric_limits<size_t>::max());
REQUIRE(cp_limits<size_t>::negative_infinity() == 0);
}
TEST_CASE("limit for short", "[limits]") {
REQUIRE(cp_limits<short>::infinity() > 10000);
REQUIRE(cp_limits<short>::negative_infinity() < -10000);
}