| 29 | CPPUNIT_TEST_SUITE_REGISTRATION(GZipDecoderTest); |
| 30 | |
| 31 | void GZipDecoderTest::testDecode() |
| 32 | { |
| 33 | GZipDecoder decoder; |
| 34 | decoder.init(); |
| 35 | |
| 36 | std::string outfile(A2_TEST_OUT_DIR "/aria2_GZipDecoderTest_testDecode"); |
| 37 | |
| 38 | char buf[4_k]; |
| 39 | std::ifstream in(A2_TEST_DIR "/gzip_decode_test.gz", std::ios::binary); |
| 40 | std::ofstream out(outfile.c_str(), std::ios::binary); |
| 41 | while (in) { |
| 42 | in.read(buf, sizeof(buf)); |
| 43 | |
| 44 | std::string r = decoder.decode(reinterpret_cast<const unsigned char*>(buf), |
| 45 | in.gcount()); |
| 46 | |
| 47 | out.write(r.data(), r.size()); |
| 48 | } |
| 49 | CPPUNIT_ASSERT(decoder.finished()); |
| 50 | decoder.release(); |
| 51 | |
| 52 | out.close(); |
| 53 | |
| 54 | CPPUNIT_ASSERT_EQUAL(std::string("8b577b33c0411b2be9d4fa74c7402d54a8d21f96"), |
| 55 | fileHexDigest(MessageDigest::sha1().get(), outfile)); |
| 56 | } |
| 57 | |
| 58 | } // namespace aria2 |
nothing calls this directly
no test coverage detected