-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBitwiseAndOpTest.h
More file actions
76 lines (58 loc) · 1.66 KB
/
BitwiseAndOpTest.h
File metadata and controls
76 lines (58 loc) · 1.66 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
#define BOOST_TEST_MODULE BitwiseAndOpTest
#include "../IntX.h"
#include "../Utils/Constants.h"
#include <vector>
#include <boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(BitwiseAndOpTest)
BOOST_AUTO_TEST_CASE(ShouldBitwiseAndTwoIntX)
{
IntX int1 = IntX(11);
IntX int2 = IntX(13);
IntX result = int1 & int2;
IntX result2 = int1 & 13;
IntX result3 = (IntX)11 & int2;
BOOST_CHECK(result == 9);
BOOST_CHECK(result == result2);
BOOST_CHECK(result2 == result3);
}
BOOST_AUTO_TEST_CASE(ShouldBitwiseAndPositiveAndNegativeIntX)
{
IntX int1 = IntX(-11);
IntX int2 = IntX(13);
IntX result = int1 & int2;
IntX result2 = int1 & 13;
IntX result3 = (IntX)-11 & int2;
BOOST_CHECK(result == 9);
BOOST_CHECK(result == result2);
BOOST_CHECK(result2 == result3);
}
BOOST_AUTO_TEST_CASE(ShouldBitwiseAndTwoNegativeIntX)
{
IntX int1 = IntX(-11);
IntX int2 = IntX(-13);
IntX result = int1 & int2;
IntX result2 = int1 & -13;
IntX result3 = (IntX)-11 & int2;
BOOST_CHECK(result == -9);
BOOST_CHECK(result == result2);
BOOST_CHECK(result2 == result3);
}
BOOST_AUTO_TEST_CASE(ShouldBitwiseAndIntXAndZero)
{
IntX int1 = IntX(11);
IntX int2 = IntX();
IntX result = int1 & int2;
IntX result2 = int1 & 0;
IntX result3 = (IntX)11 & int2;
BOOST_CHECK(result == 0);
BOOST_CHECK(result == result2);
BOOST_CHECK(result2 == result3);
}
BOOST_AUTO_TEST_CASE(ShouldBitwiseAndTwoBigIntX)
{
IntX int1 = IntX(vector<UInt32>({ 11, 6, Constants::MaxUInt32Value, Constants::MaxUInt32Value }), false);
IntX int2 = IntX(vector<UInt32>({ 13, 3, 0 }), false);
IntX result = int1 & int2;
BOOST_CHECK(result == IntX(vector<UInt32>({ 9, 2 }), false));
}
BOOST_AUTO_TEST_SUITE_END()