-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitswitch_test.cpp
50 lines (42 loc) · 939 Bytes
/
bitswitch_test.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
#include <sps/bitswitch.hpp>
#include <iostream>
#include <gtest/gtest.h>
using std::cout;
using std::endl;
using std::cin;
using sps::bool2int;
using sps::operator "" _bin2int;
TEST(bitswitch_test, switch_case) {
const size_t kBooleans = 2;
bool bArray[kBooleans];
/*
for (size_t i = 0 ; i < kBooleans ; i++) {
cin >> bArray[i];
}
*/
bArray[0] = true;
bArray[1] = false;
uint32_t mask = bool2int(2, bArray[0], bArray[1]);
switch (mask) {
case "00"_bin2int:
cout << "both false" << endl;
break;
case "01"_bin2int:
cout << "first false, second true" << endl;
break;
case "10"_bin2int:
cout << "first true, second false" << endl;
break;
case "11"_bin2int:
cout << "both true" << endl;
break;
default:
break;
}
uint32_t basis = 0;
cout << basis << endl;
}
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}