forked from aria2/aria2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGZipEncoderTest.cc
48 lines (35 loc) · 1.07 KB
/
GZipEncoderTest.cc
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
#include "GZipEncoder.h"
#include <cppunit/extensions/HelperMacros.h>
#include "GZipDecoder.h"
#include "util.h"
namespace aria2 {
class GZipEncoderTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(GZipEncoderTest);
CPPUNIT_TEST(testEncode);
CPPUNIT_TEST_SUITE_END();
public:
void testEncode();
};
CPPUNIT_TEST_SUITE_REGISTRATION(GZipEncoderTest);
void GZipEncoderTest::testEncode()
{
GZipEncoder encoder;
encoder.init();
std::vector<std::string> inputs;
inputs.push_back("Hello World");
inputs.push_back("9223372036854775807");
inputs.push_back("Fox");
encoder << inputs[0];
encoder << (int64_t)9223372036854775807LL;
encoder << inputs[2].c_str();
std::string gzippedData = encoder.str();
GZipDecoder decoder;
decoder.init();
std::string gunzippedData =
decoder.decode(reinterpret_cast<const unsigned char*>(gzippedData.data()),
gzippedData.size());
CPPUNIT_ASSERT(decoder.finished());
CPPUNIT_ASSERT_EQUAL(strjoin(inputs.begin(), inputs.end(), ""),
gunzippedData);
}
} // namespace aria2