Skip to content

Commit f90763e

Browse files
committed
Created new random tests: TestExtraction.testRandom4() to TestExtraction.testRandom8()
Created new unit test for issue #12
1 parent 8ef07f2 commit f90763e

File tree

4 files changed

+210
-0
lines changed

4 files changed

+210
-0
lines changed

msvc/bin2cpp_unittest.vcxproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,17 @@
107107
<ClCompile Include="..\test\main.cpp" />
108108
<ClCompile Include="..\test\TestExtraction.cpp" />
109109
<ClCompile Include="generated_files\testHtml100000\_testHtml100000.cpp" />
110+
<ClCompile Include="generated_files\testIssue12Mini\_testIssue12Mini.cpp" />
111+
<ClCompile Include="generated_files\testIssue12\_testIssue12.cpp" />
110112
<ClCompile Include="generated_files\testIssue13\_testIssue13.cpp" />
111113
<ClCompile Include="generated_files\testRandom1\_testRandom1.cpp" />
112114
<ClCompile Include="generated_files\testRandom2\_testRandom2.cpp" />
113115
<ClCompile Include="generated_files\testRandom3\_testRandom3.cpp" />
116+
<ClCompile Include="generated_files\testRandom4\_testRandom4.cpp" />
117+
<ClCompile Include="generated_files\testRandom5\_testRandom5.cpp" />
118+
<ClCompile Include="generated_files\testRandom6\_testRandom6.cpp" />
119+
<ClCompile Include="generated_files\testRandom7\_testRandom7.cpp" />
120+
<ClCompile Include="generated_files\testRandom8\_testRandom8.cpp" />
114121
<ClCompile Include="generated_files\testSequential10MB\_testSequential10MB.cpp" />
115122
<ClCompile Include="generated_files\testText100000\_testText100000.cpp" />
116123
<ClCompile Include="generated_files\testText1000\_testText1000.cpp" />
@@ -134,10 +141,17 @@
134141
<ClInclude Include="..\test\gtesthelper.h" />
135142
<ClInclude Include="..\test\TestExtraction.h" />
136143
<ClInclude Include="generated_files\testHtml100000\_testHtml100000.h" />
144+
<ClInclude Include="generated_files\testIssue12Mini\_testIssue12Mini.h" />
145+
<ClInclude Include="generated_files\testIssue12\_testIssue12.h" />
137146
<ClInclude Include="generated_files\testIssue13\_testIssue13.h" />
138147
<ClInclude Include="generated_files\testRandom1\_testRandom1.h" />
139148
<ClInclude Include="generated_files\testRandom2\_testRandom2.h" />
140149
<ClInclude Include="generated_files\testRandom3\_testRandom3.h" />
150+
<ClInclude Include="generated_files\testRandom4\_testRandom4.h" />
151+
<ClInclude Include="generated_files\testRandom5\_testRandom5.h" />
152+
<ClInclude Include="generated_files\testRandom6\_testRandom6.h" />
153+
<ClInclude Include="generated_files\testRandom7\_testRandom7.h" />
154+
<ClInclude Include="generated_files\testRandom8\_testRandom8.h" />
141155
<ClInclude Include="generated_files\testSequential10MB\_testSequential10MB.h" />
142156
<ClInclude Include="generated_files\testText100000\_testText100000.h" />
143157
<ClInclude Include="generated_files\testText1000\_testText1000.h" />

msvc/bin2cpp_unittest.vcxproj.filters

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,27 @@
6060
<ClCompile Include="generated_files\testIssue13\_testIssue13.cpp">
6161
<Filter>Generated Files</Filter>
6262
</ClCompile>
63+
<ClCompile Include="generated_files\testRandom4\_testRandom4.cpp">
64+
<Filter>Generated Files</Filter>
65+
</ClCompile>
66+
<ClCompile Include="generated_files\testRandom5\_testRandom5.cpp">
67+
<Filter>Generated Files</Filter>
68+
</ClCompile>
69+
<ClCompile Include="generated_files\testRandom6\_testRandom6.cpp">
70+
<Filter>Generated Files</Filter>
71+
</ClCompile>
72+
<ClCompile Include="generated_files\testRandom7\_testRandom7.cpp">
73+
<Filter>Generated Files</Filter>
74+
</ClCompile>
75+
<ClCompile Include="generated_files\testRandom8\_testRandom8.cpp">
76+
<Filter>Generated Files</Filter>
77+
</ClCompile>
78+
<ClCompile Include="generated_files\testIssue12\_testIssue12.cpp">
79+
<Filter>Generated Files</Filter>
80+
</ClCompile>
81+
<ClCompile Include="generated_files\testIssue12Mini\_testIssue12Mini.cpp">
82+
<Filter>Generated Files</Filter>
83+
</ClCompile>
6384
</ItemGroup>
6485
<ItemGroup>
6586
<None Include="bin2cppTest.x86.debug.xml">
@@ -104,6 +125,27 @@
104125
<ClInclude Include="generated_files\testIssue13\_testIssue13.h">
105126
<Filter>Generated Files</Filter>
106127
</ClInclude>
128+
<ClInclude Include="generated_files\testRandom4\_testRandom4.h">
129+
<Filter>Generated Files</Filter>
130+
</ClInclude>
131+
<ClInclude Include="generated_files\testRandom5\_testRandom5.h">
132+
<Filter>Generated Files</Filter>
133+
</ClInclude>
134+
<ClInclude Include="generated_files\testRandom6\_testRandom6.h">
135+
<Filter>Generated Files</Filter>
136+
</ClInclude>
137+
<ClInclude Include="generated_files\testRandom7\_testRandom7.h">
138+
<Filter>Generated Files</Filter>
139+
</ClInclude>
140+
<ClInclude Include="generated_files\testRandom8\_testRandom8.h">
141+
<Filter>Generated Files</Filter>
142+
</ClInclude>
143+
<ClInclude Include="generated_files\testIssue12\_testIssue12.h">
144+
<Filter>Generated Files</Filter>
145+
</ClInclude>
146+
<ClInclude Include="generated_files\testIssue12Mini\_testIssue12Mini.h">
147+
<Filter>Generated Files</Filter>
148+
</ClInclude>
107149
</ItemGroup>
108150
<ItemGroup>
109151
<CustomBuild Include="generate_test_files.bat" />

msvc/generate_test_files.bat

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,36 @@ mkdir %OUTDIR% 1>NUL 2>NUL
3636
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=100000 --fill=random --seed=3
3737
bin2cpp.exe %OUTDIR%\%TEST_NAME%.bin %OUTDIR% _%TEST_NAME%.h %TEST_NAME% 450 -override
3838

39+
set TEST_NAME=testRandom4
40+
set OUTDIR=.\generated_files\%TEST_NAME%
41+
mkdir %OUTDIR% 1>NUL 2>NUL
42+
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=1000 --fill=random --seed=4
43+
bin2cpp.exe %OUTDIR%\%TEST_NAME%.bin %OUTDIR% _%TEST_NAME%.h %TEST_NAME% 200 -override
44+
45+
set TEST_NAME=testRandom5
46+
set OUTDIR=.\generated_files\%TEST_NAME%
47+
mkdir %OUTDIR% 1>NUL 2>NUL
48+
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=1000 --fill=random --seed=5
49+
bin2cpp.exe %OUTDIR%\%TEST_NAME%.bin %OUTDIR% _%TEST_NAME%.h %TEST_NAME% 200 -override
50+
51+
set TEST_NAME=testRandom6
52+
set OUTDIR=.\generated_files\%TEST_NAME%
53+
mkdir %OUTDIR% 1>NUL 2>NUL
54+
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=1000 --fill=random --seed=6
55+
bin2cpp.exe %OUTDIR%\%TEST_NAME%.bin %OUTDIR% _%TEST_NAME%.h %TEST_NAME% 200 -override
56+
57+
set TEST_NAME=testRandom7
58+
set OUTDIR=.\generated_files\%TEST_NAME%
59+
mkdir %OUTDIR% 1>NUL 2>NUL
60+
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=1000 --fill=random --seed=7
61+
bin2cpp.exe %OUTDIR%\%TEST_NAME%.bin %OUTDIR% _%TEST_NAME%.h %TEST_NAME% 200 -override
62+
63+
set TEST_NAME=testRandom8
64+
set OUTDIR=.\generated_files\%TEST_NAME%
65+
mkdir %OUTDIR% 1>NUL 2>NUL
66+
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=1000 --fill=random --seed=8
67+
bin2cpp.exe %OUTDIR%\%TEST_NAME%.bin %OUTDIR% _%TEST_NAME%.h %TEST_NAME% 200 -override
68+
3969
set TEST_NAME=testHtml100000
4070
set OUTDIR=.\generated_files\%TEST_NAME%
4171
mkdir %OUTDIR% 1>NUL 2>NUL
@@ -60,6 +90,18 @@ REM mkdir %OUTDIR% 1>NUL 2>NUL
6090
REM testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=31457280 --fill=sequential
6191
REM bin2cpp.exe %OUTDIR%\%TEST_NAME%.bin %OUTDIR% _%TEST_NAME%.h %TEST_NAME% 450 -override
6292

93+
set TEST_NAME=testIssue12
94+
set OUTDIR=.\generated_files\%TEST_NAME%
95+
mkdir %OUTDIR% 1>NUL 2>NUL
96+
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=100000 --fill=random --seed=3
97+
bin2cpp.exe %OUTDIR%\%TEST_NAME%.bin %OUTDIR% _%TEST_NAME%.h %TEST_NAME% 450 -override
98+
99+
set TEST_NAME=testIssue12Mini
100+
set OUTDIR=.\generated_files\%TEST_NAME%
101+
mkdir %OUTDIR% 1>NUL 2>NUL
102+
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=100 --fill=random --seed=3 --skip=47240
103+
bin2cpp.exe %OUTDIR%\%TEST_NAME%.bin %OUTDIR% _%TEST_NAME%.h %TEST_NAME% 10 -override
104+
63105
set TEST_NAME=testIssue13
64106
set OUTDIR=.\generated_files\%TEST_NAME%
65107
mkdir %OUTDIR% 1>NUL 2>NUL

test/TestExtraction.cpp

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@
55
#include "generated_files\testRandom1\_testRandom1.h"
66
#include "generated_files\testRandom2\_testRandom2.h"
77
#include "generated_files\testRandom3\_testRandom3.h"
8+
#include "generated_files\testRandom4\_testRandom4.h"
9+
#include "generated_files\testRandom5\_testRandom5.h"
10+
#include "generated_files\testRandom6\_testRandom6.h"
11+
#include "generated_files\testRandom7\_testRandom7.h"
12+
#include "generated_files\testRandom8\_testRandom8.h"
813
#include "generated_files\testSequential10MB\_testSequential10MB.h"
914
#include "generated_files\testText10\_testText10.h"
1015
#include "generated_files\testText1000\_testText1000.h"
1116
#include "generated_files\testText100000\_testText100000.h"
17+
#include "generated_files\testIssue12\_testIssue12.h"
18+
#include "generated_files\testIssue12Mini\_testIssue12Mini.h"
1219
#include "generated_files\testIssue13\_testIssue13.h"
1320

1421
gTestHelper & hlp = gTestHelper::getInstance();
@@ -148,6 +155,81 @@ TEST_F(TestExtraction, testRandom3)
148155
ASSERT_TRUE(equal) << reason.c_str();
149156
}
150157

158+
TEST_F(TestExtraction, testRandom4)
159+
{
160+
static const std::string expectedFilePath = getExpectedFilePath();
161+
static const std::string outputFilePath = getActualFilePath();
162+
163+
const bin2cpp::File & file = bin2cpp::getTestRandom4File();
164+
bool extractSuccess = file.save(outputFilePath.c_str());
165+
ASSERT_TRUE(extractSuccess);
166+
167+
//assert content is the same
168+
std::string reason;
169+
bool equal = hlp.isFileEquals(expectedFilePath.c_str(), outputFilePath.c_str(), reason);
170+
ASSERT_TRUE(equal) << reason.c_str();
171+
}
172+
173+
TEST_F(TestExtraction, testRandom5)
174+
{
175+
static const std::string expectedFilePath = getExpectedFilePath();
176+
static const std::string outputFilePath = getActualFilePath();
177+
178+
const bin2cpp::File & file = bin2cpp::getTestRandom5File();
179+
bool extractSuccess = file.save(outputFilePath.c_str());
180+
ASSERT_TRUE(extractSuccess);
181+
182+
//assert content is the same
183+
std::string reason;
184+
bool equal = hlp.isFileEquals(expectedFilePath.c_str(), outputFilePath.c_str(), reason);
185+
ASSERT_TRUE(equal) << reason.c_str();
186+
}
187+
188+
TEST_F(TestExtraction, testRandom6)
189+
{
190+
static const std::string expectedFilePath = getExpectedFilePath();
191+
static const std::string outputFilePath = getActualFilePath();
192+
193+
const bin2cpp::File & file = bin2cpp::getTestRandom6File();
194+
bool extractSuccess = file.save(outputFilePath.c_str());
195+
ASSERT_TRUE(extractSuccess);
196+
197+
//assert content is the same
198+
std::string reason;
199+
bool equal = hlp.isFileEquals(expectedFilePath.c_str(), outputFilePath.c_str(), reason);
200+
ASSERT_TRUE(equal) << reason.c_str();
201+
}
202+
203+
TEST_F(TestExtraction, testRandom7)
204+
{
205+
static const std::string expectedFilePath = getExpectedFilePath();
206+
static const std::string outputFilePath = getActualFilePath();
207+
208+
const bin2cpp::File & file = bin2cpp::getTestRandom7File();
209+
bool extractSuccess = file.save(outputFilePath.c_str());
210+
ASSERT_TRUE(extractSuccess);
211+
212+
//assert content is the same
213+
std::string reason;
214+
bool equal = hlp.isFileEquals(expectedFilePath.c_str(), outputFilePath.c_str(), reason);
215+
ASSERT_TRUE(equal) << reason.c_str();
216+
}
217+
218+
TEST_F(TestExtraction, testRandom8)
219+
{
220+
static const std::string expectedFilePath = getExpectedFilePath();
221+
static const std::string outputFilePath = getActualFilePath();
222+
223+
const bin2cpp::File & file = bin2cpp::getTestRandom8File();
224+
bool extractSuccess = file.save(outputFilePath.c_str());
225+
ASSERT_TRUE(extractSuccess);
226+
227+
//assert content is the same
228+
std::string reason;
229+
bool equal = hlp.isFileEquals(expectedFilePath.c_str(), outputFilePath.c_str(), reason);
230+
ASSERT_TRUE(equal) << reason.c_str();
231+
}
232+
151233
TEST_F(TestExtraction, testSequential10MB)
152234
{
153235
static const std::string expectedFilePath = getExpectedFilePath();
@@ -163,6 +245,36 @@ TEST_F(TestExtraction, testSequential10MB)
163245
ASSERT_TRUE(equal) << reason.c_str();
164246
}
165247

248+
TEST_F(TestExtraction, testIssue12)
249+
{
250+
static const std::string expectedFilePath = getExpectedFilePath();
251+
static const std::string outputFilePath = getActualFilePath();
252+
253+
const bin2cpp::File & file = bin2cpp::getTestIssue12File();
254+
bool extractSuccess = file.save(outputFilePath.c_str());
255+
ASSERT_TRUE(extractSuccess);
256+
257+
//assert content is the same
258+
std::string reason;
259+
bool equal = hlp.isFileEquals(expectedFilePath.c_str(), outputFilePath.c_str(), reason);
260+
ASSERT_TRUE(equal) << reason.c_str();
261+
}
262+
263+
TEST_F(TestExtraction, testIssue12Mini)
264+
{
265+
static const std::string expectedFilePath = getExpectedFilePath();
266+
static const std::string outputFilePath = getActualFilePath();
267+
268+
const bin2cpp::File & file = bin2cpp::getTestIssue12MiniFile();
269+
bool extractSuccess = file.save(outputFilePath.c_str());
270+
ASSERT_TRUE(extractSuccess);
271+
272+
//assert content is the same
273+
std::string reason;
274+
bool equal = hlp.isFileEquals(expectedFilePath.c_str(), outputFilePath.c_str(), reason);
275+
ASSERT_TRUE(equal) << reason.c_str();
276+
}
277+
166278
TEST_F(TestExtraction, testIssue13)
167279
{
168280
static const std::string expectedFilePath = getExpectedFilePath();

0 commit comments

Comments
 (0)