-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaligned_autotest.cpp
53 lines (44 loc) · 2.13 KB
/
aligned_autotest.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
46
47
48
49
50
51
52
53
#define BOOST_TEST_MODULE aligned
#include <boost/test/unit_test.hpp>
#include "aligned.hpp"
BOOST_AUTO_TEST_CASE( less_test )
{
using namespace circular;
BOOST_CHECK(less(0, 5));
BOOST_CHECK(!less(5, 0));
BOOST_CHECK(less(-5, 0));
BOOST_CHECK(!less(0, -5));
BOOST_CHECK(!less(0, 0));
BOOST_CHECK(!less(5, 5));
BOOST_CHECK(!less(-5, -5));
BOOST_CHECK(!less<ptrdiff_t>(5, std::numeric_limits<ptrdiff_t>::min() + 5));
BOOST_CHECK(!less<ptrdiff_t>(std::numeric_limits<ptrdiff_t>::min() + 5, 5));
BOOST_CHECK( less<ptrdiff_t>(5, std::numeric_limits<ptrdiff_t>::min() + 4));
BOOST_CHECK(!less<ptrdiff_t>(4, std::numeric_limits<ptrdiff_t>::min() + 5));
BOOST_CHECK( less<ptrdiff_t>(std::numeric_limits<ptrdiff_t>::min() + 5, 4));
BOOST_CHECK(!less<ptrdiff_t>(std::numeric_limits<ptrdiff_t>::min() + 4, 5));
BOOST_CHECK(!less<ptrdiff_t>(-5, std::numeric_limits<ptrdiff_t>::min() - 5));
BOOST_CHECK(!less<ptrdiff_t>(std::numeric_limits<ptrdiff_t>::min() - 5, -5));
BOOST_CHECK(!less<ptrdiff_t>(-6, std::numeric_limits<ptrdiff_t>::min() - 5));
BOOST_CHECK(less<ptrdiff_t>(-5, std::numeric_limits<ptrdiff_t>::min() - 6));
BOOST_CHECK(!less<ptrdiff_t>(std::numeric_limits<ptrdiff_t>::min() - 6, -5));
BOOST_CHECK(less<ptrdiff_t>(std::numeric_limits<ptrdiff_t>::min() - 5, -6));
BOOST_CHECK( less<uint8_t>(0xEF, 0x0));
BOOST_CHECK( less<uint8_t>(0x7F, 0xEF));
BOOST_CHECK( less<uint8_t>(0x0, 0x7F));
BOOST_CHECK(!less<uint8_t>(0x0, 0x80));
BOOST_CHECK(!less<uint8_t>(0x80, 0x0));
BOOST_CHECK(!less<uint8_t>(0x7F, 0xFF));
BOOST_CHECK(!less<uint8_t>(0xFF, 0x7F));
BOOST_CHECK( less<uint8_t>(0x80, 0xFF));
}
BOOST_AUTO_TEST_CASE( distance_test )
{
using namespace circular;
BOOST_CHECK_EQUAL(distance(-5, 5), 10);
BOOST_CHECK_EQUAL(distance(5, -5), 10);
BOOST_CHECK_EQUAL(distance(5, 5), 0);
BOOST_CHECK_EQUAL(distance(-5, -5), 0);
BOOST_CHECK_EQUAL(distance<ptrdiff_t>(-5, std::numeric_limits<ptrdiff_t>::max() - 5), std::numeric_limits<ptrdiff_t>::max());
BOOST_CHECK_EQUAL(distance<ptrdiff_t>(-5, std::numeric_limits<ptrdiff_t>::max() - 4), std::numeric_limits<ptrdiff_t>::min());
}