22#include " gtesthelper.h"
33
44#include " generated_files\testHtml100000\_testHtml100000.h"
5- #include " generated_files\testPredictable100000\_testPredictable100000 .h"
6- #include " generated_files\testRandom100000\_testRandom100000 .h"
5+ #include " generated_files\testRandom1\_testRandom1 .h"
6+ #include " generated_files\testRandom2\_testRandom2 .h"
77#include " generated_files\testSequential10MB\_testSequential10MB.h"
8+ #include " generated_files\testText10\_testText10.h"
9+ #include " generated_files\testText1000\_testText1000.h"
810#include " generated_files\testText100000\_testText100000.h"
9- #include " generated_files\testSmall10\_testSmall10.h"
1011
1112gTestHelper & hlp = gTestHelper ::getInstance();
1213
14+ std::string getExpectedFilePath ()
15+ {
16+ std::string file;
17+ file.append (" generated_files\\ " );
18+ file.append (hlp.getTestCaseName ());
19+ file.append (" \\ " );
20+ file.append (hlp.getTestCaseName ());
21+ file.append (" .bin" );
22+ return file;
23+ }
24+
25+ std::string getActualFilePath ()
26+ {
27+ std::string file;
28+ file.append (" generated_files\\ " );
29+ file.append (hlp.getTestCaseName ());
30+ file.append (" \\ " );
31+ file.append (hlp.getTestCaseName ());
32+ file.append (" .output" );
33+ return file;
34+ }
35+
1336void TestExtraction::SetUp ()
1437{
1538}
@@ -18,92 +41,107 @@ void TestExtraction::TearDown()
1841{
1942}
2043
21- TEST_F (TestExtraction, testSmall10 )
44+ TEST_F (TestExtraction, testText10 )
2245{
23- static const char * expectedFilePath = " generated_files \\ testSmall10 \\ testSmall10.bin " ;
24- static const char * outputFilePath = " generated_files \\ testSmall10 \\ testSmall10.output " ;
46+ static const std::string expectedFilePath = getExpectedFilePath () ;
47+ static const std::string outputFilePath = getActualFilePath () ;
2548
26- const bin2cpp::File & file = bin2cpp::getTestSmall10File ();
27- bool extractSuccess = file.save (outputFilePath);
49+ const bin2cpp::File & file = bin2cpp::getTestText10File ();
50+ bool extractSuccess = file.save (outputFilePath. c_str () );
2851 ASSERT_TRUE (extractSuccess);
2952
3053 // assert content is the same
3154 std::string reason;
32- bool equal = hlp.isFileEquals (expectedFilePath, outputFilePath, reason);
55+ bool equal = hlp.isFileEquals (expectedFilePath. c_str () , outputFilePath. c_str () , reason);
3356 ASSERT_TRUE (equal) << reason.c_str ();
3457}
3558
36- TEST_F (TestExtraction, testHtml100000 )
59+ TEST_F (TestExtraction, testText1000 )
3760{
38- static const char * expectedFilePath = " generated_files \\ testHtml100000 \\ testHtml100000.bin " ;
39- static const char * outputFilePath = " generated_files \\ testHtml100000 \\ testHtml100000.output " ;
61+ static const std::string expectedFilePath = getExpectedFilePath () ;
62+ static const std::string outputFilePath = getActualFilePath () ;
4063
41- const bin2cpp::File & file = bin2cpp::getTestHtml100000File ();
42- bool extractSuccess = file.save (outputFilePath);
64+ const bin2cpp::File & file = bin2cpp::getTestText1000File ();
65+ bool extractSuccess = file.save (outputFilePath. c_str () );
4366 ASSERT_TRUE (extractSuccess);
4467
4568 // assert content is the same
4669 std::string reason;
47- bool equal = hlp.isFileEquals (expectedFilePath, outputFilePath, reason);
70+ bool equal = hlp.isFileEquals (expectedFilePath. c_str () , outputFilePath. c_str () , reason);
4871 ASSERT_TRUE (equal) << reason.c_str ();
4972}
5073
51- TEST_F (TestExtraction, testPredictable100000 )
74+ TEST_F (TestExtraction, testText100000 )
5275{
53- static const char * expectedFilePath = " generated_files \\ testPredictable100000 \\ testPredictable100000.bin " ;
54- static const char * outputFilePath = " generated_files \\ testPredictable100000 \\ testPredictable100000.output " ;
76+ static const std::string expectedFilePath = getExpectedFilePath () ;
77+ static const std::string outputFilePath = getActualFilePath () ;
5578
56- const bin2cpp::File & file = bin2cpp::getTestPredictable100000File ();
57- bool extractSuccess = file.save (outputFilePath);
79+ const bin2cpp::File & file = bin2cpp::getTestText100000File ();
80+ bool extractSuccess = file.save (outputFilePath. c_str () );
5881 ASSERT_TRUE (extractSuccess);
5982
6083 // assert content is the same
6184 std::string reason;
62- bool equal = hlp.isFileEquals (expectedFilePath, outputFilePath, reason);
85+ bool equal = hlp.isFileEquals (expectedFilePath. c_str () , outputFilePath. c_str () , reason);
6386 ASSERT_TRUE (equal) << reason.c_str ();
6487}
6588
66- TEST_F (TestExtraction, testRandom100000 )
89+ TEST_F (TestExtraction, testHtml100000 )
6790{
68- static const char * expectedFilePath = " generated_files \\ testRandom100000 \\ testRandom100000.bin " ;
69- static const char * outputFilePath = " generated_files \\ testRandom100000 \\ testRandom100000.output " ;
91+ static const std::string expectedFilePath = getExpectedFilePath () ;
92+ static const std::string outputFilePath = getActualFilePath () ;
7093
71- const bin2cpp::File & file = bin2cpp::getTestRandom100000File ();
72- bool extractSuccess = file.save (outputFilePath);
94+ const bin2cpp::File & file = bin2cpp::getTestHtml100000File ();
95+ bool extractSuccess = file.save (outputFilePath. c_str () );
7396 ASSERT_TRUE (extractSuccess);
7497
7598 // assert content is the same
7699 std::string reason;
77- bool equal = hlp.isFileEquals (expectedFilePath, outputFilePath, reason);
100+ bool equal = hlp.isFileEquals (expectedFilePath. c_str () , outputFilePath. c_str () , reason);
78101 ASSERT_TRUE (equal) << reason.c_str ();
79102}
80103
81- TEST_F (TestExtraction, testSequential10MB )
104+ TEST_F (TestExtraction, testRandom1 )
82105{
83- static const char * expectedFilePath = " generated_files \\ testSequential10MB \\ testSequential10MB.bin " ;
84- static const char * outputFilePath = " generated_files \\ testSequential10MB \\ testSequential10MB.output " ;
106+ static const std::string expectedFilePath = getExpectedFilePath () ;
107+ static const std::string outputFilePath = getActualFilePath () ;
85108
86- const bin2cpp::File & file = bin2cpp::getTestSequential10MBFile ();
87- bool extractSuccess = file.save (outputFilePath);
109+ const bin2cpp::File & file = bin2cpp::getTestRandom1File ();
110+ bool extractSuccess = file.save (outputFilePath. c_str () );
88111 ASSERT_TRUE (extractSuccess);
89112
90113 // assert content is the same
91114 std::string reason;
92- bool equal = hlp.isFileEquals (expectedFilePath, outputFilePath, reason);
115+ bool equal = hlp.isFileEquals (expectedFilePath. c_str () , outputFilePath. c_str () , reason);
93116 ASSERT_TRUE (equal) << reason.c_str ();
94117}
95118
96- TEST_F (TestExtraction, testText100000 )
119+ TEST_F (TestExtraction, testRandom2 )
97120{
98- static const char * expectedFilePath = " generated_files \\ testText100000 \\ testText100000.bin " ;
99- static const char * outputFilePath = " generated_files \\ testText100000 \\ testText100000.output " ;
121+ static const std::string expectedFilePath = getExpectedFilePath () ;
122+ static const std::string outputFilePath = getActualFilePath () ;
100123
101- const bin2cpp::File & file = bin2cpp::getTestText100000File ();
102- bool extractSuccess = file.save (outputFilePath);
124+ const bin2cpp::File & file = bin2cpp::getTestRandom2File ();
125+ bool extractSuccess = file.save (outputFilePath.c_str ());
126+ ASSERT_TRUE (extractSuccess);
127+
128+ // assert content is the same
129+ std::string reason;
130+ bool equal = hlp.isFileEquals (expectedFilePath.c_str (), outputFilePath.c_str (), reason);
131+ ASSERT_TRUE (equal) << reason.c_str ();
132+ }
133+
134+ TEST_F (TestExtraction, testSequential10MB)
135+ {
136+ static const std::string expectedFilePath = getExpectedFilePath ();
137+ static const std::string outputFilePath = getActualFilePath ();
138+
139+ const bin2cpp::File & file = bin2cpp::getTestSequential10MBFile ();
140+ bool extractSuccess = file.save (outputFilePath.c_str ());
103141 ASSERT_TRUE (extractSuccess);
104142
105143 // assert content is the same
106144 std::string reason;
107- bool equal = hlp.isFileEquals (expectedFilePath, outputFilePath, reason);
145+ bool equal = hlp.isFileEquals (expectedFilePath. c_str () , outputFilePath. c_str () , reason);
108146 ASSERT_TRUE (equal) << reason.c_str ();
109147}
0 commit comments