-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.cpp
80 lines (63 loc) · 1.92 KB
/
tests.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
75
76
77
78
79
80
#include "utils.c"
#include <gtest/gtest.h>
TEST(uint1024tTest, AddOpTest) {
uint1024_t x;
uint1024_t y;
uint1024_t res;
char str[309];
x = from_uint(0);
y = from_uint(0);
res = add_op(&x, &y);
num_to_str(&res, str);
ASSERT_EQ(strcmp(str, "0"), 0) << "0 + 0 is not " << str;
y = from_uint(245534091);
res = add_op(&x, &y);
num_to_str(&res, str);
ASSERT_EQ(strcmp(str, "245534091"), 0) << "0 + 245534091 is not " << str;
x = from_uint(8936633);
res = add_op(&x, &y);
num_to_str(&res, str);
ASSERT_EQ(strcmp(str, "254470724"), 0) << "8936633 + 245534091 is not " << str;
}
TEST(uint1024tTest, MultOpTest) {
uint1024_t x;
uint1024_t y;
uint1024_t res;
char str[309];
x = from_uint(0);
y = from_uint(0);
res = mult_op(&x, &y);
num_to_str(&res, str);
ASSERT_EQ(strcmp(str, "0"), 0) << "0 * 0 is not " << str;
y = from_uint(245534091);
res = mult_op(&x, &y);
num_to_str(&res, str);
ASSERT_EQ(strcmp(str, "0"), 0) << "0 * 245534091 is not " << str;
x = from_uint(8936633);
res = mult_op(&x, &y);
num_to_str(&res, str);
ASSERT_EQ(strcmp(str, "2194248060255603"), 0) << "8936633 * 245534091 is not " << str;
}
TEST(uint1024tTest, SubtrOpTest) {
uint1024_t x;
uint1024_t y;
uint1024_t res;
char str[309];
x = from_uint(0);
y = from_uint(0);
res = subtr_op(&x, &y);
num_to_str(&res, str);
ASSERT_EQ(strcmp(str, "0"), 0) << "0 + 0 is not " << str;
x = from_uint(245534091);
res = subtr_op(&x, &y);
num_to_str(&res, str);
ASSERT_EQ(strcmp(str, "245534091"), 0) << "245534091 - 0 is not " << str;
y = from_uint(8936633);
res = subtr_op(&x, &y);
num_to_str(&res, str);
ASSERT_EQ(strcmp(str, "236597458"), 0) << "245534091 - 8936633 is not " << str;
}
int main(int argc, char **argv) {
testing::InitGoogleTest();
return RUN_ALL_TESTS();
}