aria2/test/MessageDigestHelperTest.cc

45 lines
1.2 KiB
C++
Raw Normal View History

#include "message_digest_helper.h"
#include <cppunit/extensions/HelperMacros.h>
#include "util.h"
2007-08-08 14:40:28 +00:00
#include "DefaultDiskWriter.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 "MessageDigest.h"
2007-08-08 14:40:28 +00:00
namespace aria2 {
2007-08-08 14:40:28 +00:00
class MessageDigestHelperTest:public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(MessageDigestHelperTest);
CPPUNIT_TEST(testDigestDiskWriter);
2007-08-08 14:40:28 +00:00
CPPUNIT_TEST_SUITE_END();
private:
public:
void setUp() {
}
void testDigestDiskWriter();
2007-08-08 14:40:28 +00:00
};
CPPUNIT_TEST_SUITE_REGISTRATION( MessageDigestHelperTest );
void MessageDigestHelperTest::testDigestDiskWriter() {
2013-07-02 16:13:13 +00:00
auto diskio = std::make_shared<DefaultDiskWriter>
(A2_TEST_DIR"/4096chunk.txt");
diskio->enableReadOnly();
diskio->openExistingFile();
CPPUNIT_ASSERT_EQUAL(std::string("608cabc0f2fa18c260cafd974516865c772363d5"),
util::toHex(message_digest::digest
2013-07-02 16:13:13 +00:00
(MessageDigest::sha1().get(),
diskio, 0, 4096)));
2007-08-08 14:40:28 +00:00
CPPUNIT_ASSERT_EQUAL(std::string("7a4a9ae537ebbbb826b1060e704490ad0f365ead"),
util::toHex(message_digest::digest
2013-07-02 16:13:13 +00:00
(MessageDigest::sha1().get(),
diskio, 5, 100)));
2007-08-08 14:40:28 +00:00
}
} // namespace aria2