-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathUnbytesTest.cpp
103 lines (76 loc) · 2.04 KB
/
UnbytesTest.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
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
#include <vector>
#include <string>
#include <gtest/gtest.h>
#include "CommonTests.h"
#include "boolinq.h"
using namespace boolinq;
//////////////////////////////////////////////////////////////////////////
TEST(Unbytes, OneIntDefault)
{
unsigned char src[] = {0xAA,0xBB,0xCC,0xDD};
unsigned ans[] = {0xDDCCBBAA};
auto rng = from(src);
auto dst = rng.unbytes<unsigned>();
CheckRangeEqArray(dst, ans);
}
TEST(Unbytes, OneIntFL)
{
unsigned char src[] = {0xAA,0xBB,0xCC,0xDD};
unsigned ans[] = {0xDDCCBBAA};
auto rng = from(src);
auto dst = rng.unbytes<unsigned>(BytesFirstToLast);
CheckRangeEqArray(dst, ans);
}
TEST(Unbytes, OneIntLF)
{
unsigned char src[] = {0xAA,0xBB,0xCC,0xDD};
unsigned ans[] = {0xAABBCCDD};
auto rng = from(src);
auto dst = rng.unbytes<unsigned>(BytesLastToFirst);
CheckRangeEqArray(dst, ans);
}
//////////////////////////////////////////////////////////////////////////
TEST(Unbytes, TwoIntsDefault)
{
unsigned char src[] =
{
0x78,0x56,0x34,0x12,
0xAA,0xBB,0xCC,0xDD,
};
unsigned ans[] = {0x12345678,0xDDCCBBAA};
auto rng = from(src);
auto dst = rng.unbytes<unsigned>();
CheckRangeEqArray(dst, ans);
}
TEST(Unbytes, TwoIntsFL)
{
unsigned char src[] =
{
0x78,0x56,0x34,0x12,
0xAA,0xBB,0xCC,0xDD,
};
unsigned ans[] = {0x12345678,0xDDCCBBAA};
auto rng = from(src);
auto dst = rng.unbytes<unsigned>(BytesFirstToLast);
CheckRangeEqArray(dst, ans);
}
TEST(Unbytes, TwoIntsLF)
{
unsigned char src[] =
{
0x78,0x56,0x34,0x12,
0xAA,0xBB,0xCC,0xDD,
};
unsigned ans[] = {0x78563412,0xAABBCCDD};
auto rng = from(src);
auto dst = rng.unbytes<unsigned>(BytesLastToFirst);
CheckRangeEqArray(dst, ans);
}
//////////////////////////////////////////////////////////////////////////
TEST(Unbytes, EmptyDefault)
{
std::vector<unsigned char> src;
auto rng = from(src);
auto dst = rng.unbytes<int>();
EXPECT_THROW(dst.next(), LinqEndException);
}