aria2/test/GZipDecoderTest.cc

59 lines
1.2 KiB
C++
Raw Normal View History

#include "GZipDecoder.h"
2010-11-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Replaced MessageDigestContext with MessageDigest. Cleaned up unnecessary functions in MessageDigestHelper. * src/BtPieceMessage.cc * src/Checksum.h * src/DHTTokenTracker.cc * src/DownloadCommand.cc * src/DownloadCommand.h * src/HashFuncEntry.h * src/IteratableChecksumValidator.cc * src/IteratableChecksumValidator.h * src/IteratableChunkChecksumValidator.cc * src/IteratableChunkChecksumValidator.h * src/LibgcryptMessageDigestImpl.cc * src/LibgcryptMessageDigestImpl.h * src/LibsslMessageDigestImpl.cc * src/LibsslMessageDigestImpl.h * src/MSEHandshake.cc * src/MSEHandshake.h * src/Makefile.am * src/MessageDigest.cc * src/MessageDigest.h * src/MessageDigestHelper.cc * src/MessageDigestHelper.h * src/MessageDigestImpl.h * src/MetalinkParserController.cc * src/Piece.cc * src/Piece.h * src/UTMetadataDataExtensionMessage.cc * src/bittorrent_helper.cc * src/messageDigest.cc: Removed * src/messageDigest.h: Removed * src/util.cc * src/version_usage.cc * test/BittorrentHelperTest.cc * test/GZipDecoderTest.cc * test/GZipDecodingStreamFilterTest.cc * test/IteratableChecksumValidatorTest.cc * test/IteratableChunkChecksumValidatorTest.cc * test/Makefile.am * test/MessageDigestHelperTest.cc * test/MessageDigestTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkProcessorTest.cc * test/PieceTest.cc * test/TestUtil.cc * test/TestUtil.h * test/UTMetadataDataExtensionMessageTest.cc * test/UTMetadataPostDownloadHandlerTest.cc
2010-11-11 02:56:24 +00:00
#include <iostream>
#include <fstream>
#include <cppunit/extensions/HelperMacros.h>
#include "TestUtil.h"
#include "Exception.h"
#include "util.h"
#include "MessageDigest.h"
namespace aria2 {
class GZipDecoderTest:public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(GZipDecoderTest);
CPPUNIT_TEST(testDecode);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {}
void tearDown() {}
void testDecode();
};
CPPUNIT_TEST_SUITE_REGISTRATION(GZipDecoderTest);
void GZipDecoderTest::testDecode()
{
GZipDecoder decoder;
decoder.init();
std::string outfile(A2_TEST_OUT_DIR"/aria2_GZipDecoderTest_testDecode");
char buf[4096];
std::ifstream in(A2_TEST_DIR"/gzip_decode_test.gz", std::ios::binary);
std::ofstream out(outfile.c_str(), std::ios::binary);
while(in) {
in.read(buf, sizeof(buf));
std::string r = decoder.decode
(reinterpret_cast<const unsigned char*>(buf), in.gcount());
out.write(r.data(), r.size());
}
CPPUNIT_ASSERT(decoder.finished());
decoder.release();
out.close();
CPPUNIT_ASSERT_EQUAL(std::string("8b577b33c0411b2be9d4fa74c7402d54a8d21f96"),
2013-07-02 16:13:13 +00:00
fileHexDigest(MessageDigest::sha1().get(), outfile));
}
} // namespace aria2