aria2/test/GZipEncoderTest.cc
Tatsuhiro Tsujikawa 06a52cad02 2010-01-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
aria2 now returns gzip compressed XML-RPC response if XML-RPC
	client accepts gzip content encoding.
	* src/A2STR.cc
	* src/A2STR.h
	* src/GZipEncoder.cc
	* src/GZipEncoder.h
	* src/HttpHeader.cc
	* src/HttpHeader.h
	* src/HttpServer.cc
	* src/HttpServer.h
	* src/HttpServerBodyCommand.cc
	* src/HttpServerCommand.cc
	* src/Makefile.am
	* src/XmlRpcResponse.cc
	* src/XmlRpcResponse.h
	* test/GZipEncoderTest.cc
	* test/Makefile.am
2010-01-22 14:09:39 +00:00

49 lines
1.1 KiB
C++

#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 << util::parseLLInt(inputs[1]);
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