-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathlte.cpp
executable file
·74 lines (65 loc) · 3.44 KB
/
lte.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <gtest/gtest.h>
#include "integer.h"
TEST(Comparison, less_than_or_equals){
const integer neg_big("-ffffffffffffffffff", 16);
const integer neg_small("-1", 16);
const integer pos_small( "1", 16);
const integer pos_big("ffffffffffffffffff", 16);
EXPECT_EQ(neg_big <= neg_big, true);
EXPECT_EQ(neg_big <= neg_small, true);
EXPECT_EQ(neg_big <= pos_small, true);
EXPECT_EQ(neg_big <= pos_big, true);
EXPECT_EQ(neg_small <= neg_big, false);
EXPECT_EQ(neg_small <= neg_small, true);
EXPECT_EQ(neg_small <= pos_small, true);
EXPECT_EQ(neg_small <= pos_big, true);
EXPECT_EQ(pos_small <= neg_big, false);
EXPECT_EQ(pos_small <= neg_small, false);
EXPECT_EQ(pos_small <= pos_small, true);
EXPECT_EQ(pos_small <= pos_big, true);
EXPECT_EQ(pos_big <= neg_big, false);
EXPECT_EQ(pos_big <= neg_small, false);
EXPECT_EQ(pos_big <= pos_small, false);
EXPECT_EQ(pos_big <= pos_big, true);
}
#define unsigned_compare_lte(Z) \
do \
{ \
static_assert(std::is_signed <Z>::value, "Type must be signed"); \
\
const T pos_small = std::numeric_limits <Z>::min(); \
const T pos_big = std::numeric_limits <Z>::max(); \
\
const integer int_pos_small(pos_small); \
const integer int_pos_big(pos_big); \
\
} \
while (0)
#define signed_compare_lte(Z) \
do \
{ \
static_assert(std::is_signed <Z>::value, "Type must be signed"); \
\
const T neg_big = std::numeric_limits <Z>::min(); \
const T neg_small = -1; \
const T pos_small = 1; \
const T pos_big = std::numeric_limits <Z>::max(); \
\
const integer int_neg_big(neg_big); \
const integer int_neg_small(neg_small); \
const integer int_pos_small(pos_small); \
const integer int_pos_big(pos_big); \
\
} \
while (0)
// TEST(External, less_than_or_equals){
// unsigned_compare_lte(bool);
// unsigned_compare_lte(uint8_t);
// unsigned_compare_lte(uint16_t);
// unsigned_compare_lte(uint32_t);
// unsigned_compare_lte(uint64_t);
// signed_compare_lte(int8_t);
// signed_compare_lte(int16_t);
// signed_compare_lte(int32_t);
// signed_compare_lte(int64_t);
// }