mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 21:47:37 +03:00
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
52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
#include "MessageDigestHelper.h"
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
#include "util.h"
|
|
#include "DefaultDiskWriter.h"
|
|
#include "MessageDigest.h"
|
|
|
|
namespace aria2 {
|
|
|
|
class MessageDigestHelperTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(MessageDigestHelperTest);
|
|
CPPUNIT_TEST(testHexDigestDiskWriter);
|
|
CPPUNIT_TEST(testDigest);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
private:
|
|
|
|
public:
|
|
void setUp() {
|
|
}
|
|
|
|
void testHexDigestDiskWriter();
|
|
void testDigest();
|
|
};
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( MessageDigestHelperTest );
|
|
|
|
void MessageDigestHelperTest::testHexDigestDiskWriter() {
|
|
SharedHandle<DefaultDiskWriter> diskio
|
|
(new DefaultDiskWriter("4096chunk.txt"));
|
|
diskio->openExistingFile();
|
|
CPPUNIT_ASSERT_EQUAL(std::string("608cabc0f2fa18c260cafd974516865c772363d5"),
|
|
MessageDigestHelper::hexDigest
|
|
(MessageDigest::sha1(), diskio, 0, 4096));
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("7a4a9ae537ebbbb826b1060e704490ad0f365ead"),
|
|
MessageDigestHelper::hexDigest
|
|
(MessageDigest::sha1(), diskio, 5, 100));
|
|
}
|
|
|
|
void MessageDigestHelperTest::testDigest()
|
|
{
|
|
std::string data = "aria2";
|
|
SharedHandle<MessageDigest> sha1 = MessageDigest::sha1();
|
|
sha1->update(data.data(), data.size());
|
|
CPPUNIT_ASSERT_EQUAL(std::string("f36003f22b462ffa184390533c500d8989e9f681"),
|
|
sha1->hexDigest());
|
|
}
|
|
|
|
} // namespace aria2
|