forked from k06a/boolinq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DotCallTest.cpp
172 lines (148 loc) · 4.09 KB
/
DotCallTest.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "CommonTests.h"
#include "boolinq.h"
using namespace boolinq;
//////////////////////////////////////////////////////////////////////////
TEST(DotCall, BytesRange)
{
int src[] = {0x12345678,0xAABBCCDD};
int ansFL[] =
{
0x78,0x56,0x34,0x12,
0xDD,0xCC,0xBB,0xAA,
};
int ansLF[] =
{
0x12,0x34,0x56,0x78,
0xAA,0xBB,0xCC,0xDD,
};
auto dstFL1 = from(src).bytes();
auto dstFL2 = from(src).bytes(FirstToLast);
auto dstLF1 = from(src).bytes(LastToFirst);
CheckRangeEqArray(dstFL1, ansFL);
CheckRangeEqArray(dstFL2, ansFL);
CheckRangeEqArray(dstLF1, ansLF);
}
//////////////////////////////////////////////////////////////////////////
TEST(DotCall, UnbytesRange)
{
unsigned char src[] =
{
0x78,0x56,0x34,0x12,
0xDD,0xCC,0xBB,0xAA,
};
int ansFL[] = {0x12345678,0xAABBCCDD};
int ansLF[] = {0x78563412,0xDDCCBBAA};
auto dstFL1 = from(src).unbytes<int>();
auto dstFL2 = from(src).unbytes<int>(FirstToLast);
auto dstLF1 = from(src).unbytes<int>(LastToFirst);
CheckRangeEqArray(dstFL1, ansFL);
CheckRangeEqArray(dstFL2, ansFL);
CheckRangeEqArray(dstLF1, ansLF);
}
//////////////////////////////////////////////////////////////////////////
TEST(DotCall, BitsRangeHL)
{
int src[] = {0xAABBCCDD};
int ansFL[] =
{
1,1,0,1,1,1,0,1,
1,1,0,0,1,1,0,0,
1,0,1,1,1,0,1,1,
1,0,1,0,1,0,1,0,
};
int ansLF[] =
{
1,0,1,0,1,0,1,0,
1,0,1,1,1,0,1,1,
1,1,0,0,1,1,0,0,
1,1,0,1,1,1,0,1,
};
auto dstFL1 = from(src).bits();
auto dstFL2 = from(src).bits(HighToLow);
auto dstFL3 = from(src).bits(HighToLow,FirstToLast);
auto dstLF1 = from(src).bits(HighToLow,LastToFirst);
CheckRangeEqArray(dstFL1, ansFL);
CheckRangeEqArray(dstFL2, ansFL);
CheckRangeEqArray(dstFL3, ansFL);
CheckRangeEqArray(dstLF1, ansLF);
}
TEST(DotCall, BitsRangeLH)
{
int src[] = {0xAABBCCDD};
int ansFL[] =
{
1,0,1,1,1,0,1,1,
0,0,1,1,0,0,1,1,
1,1,0,1,1,1,0,1,
0,1,0,1,0,1,0,1,
};
int ansLF[] =
{
0,1,0,1,0,1,0,1,
1,1,0,1,1,1,0,1,
0,0,1,1,0,0,1,1,
1,0,1,1,1,0,1,1,
};
auto dstFL1 = from(src).bits(LowToHigh);
auto dstFL2 = from(src).bits(LowToHigh,FirstToLast);
auto dstLF1 = from(src).bits(LowToHigh,LastToFirst);
CheckRangeEqArray(dstFL1, ansFL);
CheckRangeEqArray(dstFL2, ansFL);
CheckRangeEqArray(dstLF1, ansLF);
}
//////////////////////////////////////////////////////////////////////////
TEST(DotCall, UnbitsRangeHLFL)
{
int src[] =
{
1,1,0,1,1,1,0,1,
1,1,0,0,1,1,0,0,
1,0,1,1,1,0,1,1,
1,0,1,0,1,0,1,0
};
int ans_4b[] = {0xDD,0xCC,0xBB,0xAA};
int ans_1i[] = {0xAABBCCDD};
int ansLF_1i[] = {0xDDCCBBAA};
auto dst1_4b = from(src).unbits();
auto dst2_4b = from(src).unbits(HighToLow);
auto dst1_1i = from(src).unbits<int>(HighToLow);
auto dst2_1i = from(src).unbits<int>(HighToLow,FirstToLast);
auto dst3_1i = from(src).unbits<int>(HighToLow,LastToFirst);
CheckRangeEqArray(dst1_4b, ans_4b);
CheckRangeEqArray(dst2_4b, ans_4b);
CheckRangeEqArray(dst1_1i, ans_1i);
CheckRangeEqArray(dst2_1i, ans_1i);
CheckRangeEqArray(dst3_1i, ansLF_1i);
}
//TEST(DotCall, UnbitsRangeLH)
//{
// int src[] = {0xAABBCCDD};
// int ansFL[] =
// {
// 1,0,1,1,1,0,1,1,
// 0,0,1,1,0,0,1,1,
// 1,1,0,1,1,1,0,1,
// 0,1,0,1,0,1,0,1,
// };
// int ansLF[] =
// {
// 0,1,0,1,0,1,0,1,
// 1,1,0,1,1,1,0,1,
// 0,0,1,1,0,0,1,1,
// 1,0,1,1,1,0,1,1,
// };
//
// auto dstFL1 = from(src).bits<LowToHigh>();
// auto dstFL2 = from(src).bits<LowToHigh,FirstToLast>();
// auto dstLF1 = from(src).bits<LowToHigh,LastToFirst>();
//
// CheckRangeEqArray(dstFL1, ansFL);
// CheckRangeEqArray(dstFL2, ansFL);
// CheckRangeEqArray(dstLF1, ansLF);
//}