2011-02-05 14:38:51 +00:00
|
|
|
#include "message_digest_helper.h"
|
2009-02-01 02:50:38 +00:00
|
|
|
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
|
2009-10-22 15:35:33 +00:00
|
|
|
#include "util.h"
|
2007-08-08 14:40:28 +00:00
|
|
|
#include "DefaultDiskWriter.h"
|
2010-11-11 02:56:24 +00:00
|
|
|
#include "MessageDigest.h"
|
2007-08-08 14:40:28 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
2007-08-08 14:40:28 +00:00
|
|
|
|
|
|
|
class MessageDigestHelperTest:public CppUnit::TestFixture {
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE(MessageDigestHelperTest);
|
2011-10-13 12:40:07 +00:00
|
|
|
CPPUNIT_TEST(testDigestDiskWriter);
|
2007-08-08 14:40:28 +00:00
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
private:
|
|
|
|
|
|
|
|
public:
|
|
|
|
void setUp() {
|
|
|
|
}
|
|
|
|
|
2011-10-13 12:40:07 +00:00
|
|
|
void testDigestDiskWriter();
|
2007-08-08 14:40:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( MessageDigestHelperTest );
|
|
|
|
|
2011-10-13 12:40:07 +00:00
|
|
|
void MessageDigestHelperTest::testDigestDiskWriter() {
|
2013-07-02 16:13:13 +00:00
|
|
|
auto diskio = std::make_shared<DefaultDiskWriter>
|
|
|
|
(A2_TEST_DIR"/4096chunk.txt");
|
2010-12-02 13:38:36 +00:00
|
|
|
diskio->enableReadOnly();
|
2009-05-04 07:50:38 +00:00
|
|
|
diskio->openExistingFile();
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("608cabc0f2fa18c260cafd974516865c772363d5"),
|
2011-10-13 12:40:07 +00:00
|
|
|
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
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("7a4a9ae537ebbbb826b1060e704490ad0f365ead"),
|
2011-10-13 12:40:07 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|