-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtracebit.cpp
More file actions
50 lines (31 loc) · 1.26 KB
/
Copy pathtracebit.cpp
File metadata and controls
50 lines (31 loc) · 1.26 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
#include <string>
#include "traceuint.h"
#ifdef TEST_TRACEBIT
#include <cassert>
using std::endl;
void test8(Tuint8 t1, Tuint8 t2) {
assert((t1 & t2).value() == (t1.value() & t2.value()));
assert((t1 | t2).value() == (t1.value() | t2.value()));
assert((t1 ^ t2).value() == (t1.value() ^ t2.value()));
assert((t1 <<2).value() == (unsigned char)(t1.value() << 2));
assert((t1 >>2).value() == (unsigned char)(t1.value() >> 2));
assert((t1 + t2).value() == (unsigned char)(t1.value() + t2.value()));
}
void test32(Tuint32 t1, Tuint32 t2) {
assert((t1 & t2).value() == (t1.value() & t2.value()));
assert((t1 | t2).value() == (t1.value() | t2.value()));
assert((t1 ^ t2).value() == (t1.value() ^ t2.value()));
assert((t1 <<2).value() == (unsigned long)(t1.value() << 2));
assert((t1 >>2).value() == (unsigned long)(t1.value() >> 2));
assert((t1 + t2).value() == (unsigned long)(t1.value() + t2.value()));
}
int main() {
test8(Tuint8(0xde), Tuint8(0x24));
test8(Tuint8(0xff), Tuint8(0x01));
test8(Tuint8(0xff), Tuint8(0x00));
test8(Tuint8(0xaa), Tuint8(0xaa));
test32(Tuint32(0xffffffff), Tuint32(0x1));
test32(Tuint32(0x124311aa), Tuint32(0xaa001122));
std::cout << "Tests ok" << std::endl;
}
#endif