File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 2222 XX(Libc) \
2323 XX(PreCache) \
2424 XX(BitSet) \
25+ XX(Range) \
2526 XX(String) \
2627 XX(ArduinoString) \
2728 XX(Wiring) \
Original file line number Diff line number Diff line change 1+ #include < HostTests.h>
2+ #include < Data/Range.h>
3+
4+ class RangeTest : public TestGroup
5+ {
6+ public:
7+ RangeTest () : TestGroup(_F(" Range" ))
8+ {
9+ }
10+
11+ void execute () override
12+ {
13+ TEST_CASE (" constexpr" )
14+ {
15+ constexpr TRange<int > range (0 , 100 );
16+ constexpr auto int64 = 120000000000LL ;
17+ constexpr auto val = range.clip (int64);
18+ static_assert (val == 100 , " Bad clip" );
19+
20+ constexpr int64_t tmp = 0x8000000000LL ;
21+ static_assert (!range.contains (tmp));
22+ }
23+
24+ TEST_CASE (" truncation" )
25+ {
26+ constexpr TRange<int8_t > range (0 , 100 );
27+ int val = 0x1020 ;
28+ val = range.clip (val);
29+ REQUIRE_EQ (val, 100 );
30+ }
31+
32+ TEST_CASE (" Membership" )
33+ {
34+ constexpr TRange<int8_t > range (0 , 100 );
35+ int val = 0x8000 ;
36+ REQUIRE (!range.contains (val));
37+ }
38+ }
39+ };
40+
41+ void REGISTER_TEST (Range)
42+ {
43+ registerGroup<RangeTest>();
44+ }
You can’t perform that action at this time.
0 commit comments