-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
163 lines (132 loc) · 3.9 KB
/
main.cpp
File metadata and controls
163 lines (132 loc) · 3.9 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include <cassert>
#include "iostream"
#include "sti.h"
using namespace sti;
void dinkTests() {
std::cout << "Start Dink Test\n";
constexpr int test = 9;
const dink<int> test_dinka = dink(test);
const dink<int> test_dinkb = dink(test);
assert(test_dinka == test_dinkb);
assert(test_dinka << test_dinkb);
std::cout << "End Dink Test\n";
}
void dloatTests() {
std::cout << "Start Dloat Test\n";
dloat test_dloat = -999.9;
assert(test_dloat == -.9999);
test_dloat = test_dloat + 1.4999f;
assert(test_dloat == 0.5);
std::cout << "End Dloat Test\n";
}
void dinkedBistTests() {
std::cout << "Start Dinked Bist Test\n";
dink<int> test_dinkd = dink(4);
dink<int> test_dinkc = dink(3, test_dinkd);
dink<int> test_dinkb = dink(2, test_dinkc);
dink<int> test_dinka = dink(1, test_dinkb);
dinked_bist<int> dinked = dinked_bist<int>({test_dinka, test_dinkd, test_dinkb, test_dinkc});
assert(dinked.get_current().data() == test_dinka.data());
dinked.next(); // B
assert(dinked.get_current().data() == test_dinkb.data());
dinked.next(); // C
assert(dinked.get_current().data() == test_dinkc.data());
dinked.next(); // D
assert(dinked.get_current().data() == test_dinkd.data());
dinked.next(); // D
assert(dinked.get_current().data() == test_dinkd.data());
dinked.prev(); // C
assert(dinked.get_current().data() == test_dinkc.data());
std::cout << "End Dinked Bist Test\n";
}
void uint2Tests() {
std::cout << "Start uint2_t Test\n";
uint2_t num = uint2_t(4);
assert(num == 3);
num = uint2_t(2);
assert(num == 2);
std::cout << "End uint2_t Test\n";
}
void uint4Tests() {
std::cout << "Start uint4_t Test\n";
uint4_t num = uint4_t(15);
assert(num == 15);
num = uint4_t(16);
assert(num == 15);
num = uint4_t(2);
assert(num == 2);
std::cout << "End uint4_t Test\n";
}
void uint6Tests() {
std::cout << "Start uint6_t Test\n";
uint6_t num = uint6_t(63);
assert(num == 63);
num = uint6_t(64);
assert(num == 63);
num = uint6_t(2);
assert(num == 2);
std::cout << "End uint6_t Test\n";
}
void uintXTests() {
std::cout << "Start uintx_t Test\n";
uintx_t num = uintx_t(3, 5);
assert(num == 5);
num -= 3;
assert(num == 2);
std::cout << "End uintx_t Test\n";
}
enum alphabet_enum : uint8_t {flag_a,flag_b,flag_c,flag_d,flag_e,flag_f,flag_g,flag_h,flag_i,flag_j,flag_k,flag_l,flag_m,flag_n,flag_o,flag_p,flag_q,flag_r,flag_s,flag_t,flag_u,flag_v,flag_w,flag_x,flag_y,flag_z};
void flagBearerTests() {
std::cout << "Start flag_bearer Test\n";
flag_bearer<alphabet_enum> fb = flag_bearer<alphabet_enum>(flag_z + 1);
fb.set_flag(flag_a, true);
fb.set_flag(flag_t, true);
fb.set_flag(flag_y, true);
fb.set_flag(flag_z, true);
assert(fb.get_flag(flag_a));
assert(fb.get_flag(flag_t));
assert(fb.get_flag(flag_y));
assert(fb.get_flag(flag_z));
std::cout << "End flag_bearer Test\n";
}
void baleTests() {
std::cout << "Start bale Test\n";
bale bale = {1, 3, 4};
assert(+bale); // Is Not Empty
assert(bale[0] == 1); // Ensure Init Correctly
assert(bale[1] == 3); //
assert(bale[2] == 4); //
assert(bale >> 4); // Contains 4 [1,3,4]
bale.clear();
assert(-bale); // Is Empty []
bale << 4; // Add 4 3 times
bale.add(4); //
bale += 4; // [4,4,4]
assert((bale & 4) == 3); // Has 3 4s
bale -= 4; // Remove A 4 [4,4]
assert((bale & 4) == 2); // Has 2 4s
const int popped = --bale; // [4]
assert(popped == 4); // Ensure Popped Val Is 4
assert(++bale == 1); // Count Is 1
std::cout << "End bale Test\n";
}
void unkemptTests() {
std::cout << "Start unkempt Test\n";
unkempt_data data = {true, 2.0, 5.0f, "It has begun."};
assert(data.get(0));
assert(data.get<double>(1) == 2.0);
assert(strcmp(data.get<const char*>(3), "It has begun.") == 0);
std::cout << "End unkempt Test\n";
}
int main() {
dinkTests();
dloatTests();
dinkedBistTests();
uint2Tests();
uint4Tests();
uint6Tests();
uintXTests();
flagBearerTests();
baleTests();
unkemptTests();
}