-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_boolvec.cpp
45 lines (43 loc) · 1.22 KB
/
test_boolvec.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
#include "SerializationSupport.hpp"
#include <iostream>
using namespace mutils;
int main(){
std::vector<bool> b;
std::cout << mutils::bytes_size(0) << std::endl;
{
char buf[256];
to_bytes(b,buf);
assert(b == *from_bytes<std::vector<bool>>(nullptr,buf));
assert(mutils::bytes_size(b) == mutils::bytes_size(std::size_t{0}));
std::cout << mutils::bytes_size(std::size_t{0}) << std::endl;
}
auto i = 0u;
while (better_rand() < .8 || i < 100) {
b.push_back(better_rand() > .5 ? true : false);
++i;
}
assert(b.size() > 5);
std::cout << b.size() << std::endl;
std::size_t canary;
canary = 471341890183081ul;
char data[b.size()];
auto canary2 = canary;
assert(data);
bzero(data,b.size());
assert(canary == 471341890183081ul);
assert(canary2 == canary);
const auto size = bytes_size(b);
const auto size2 = to_bytes(b,data);
assert(size == size2);
std::cout << size << std::endl;
assert(canary == 471341890183081ul);
assert(canary2 == canary);
std::cout << data << std::endl;
std::cout << (std::size_t) data << std::endl;
std::cout << "i am concerned" << std::endl;
assert(data);
assert(canary == 471341890183081ul);
canary = 348920;
auto newb = from_bytes<std::vector<bool> >(nullptr,data);
assert(*newb == b);
}