mirror of
https://github.com/aria2/aria2.git
synced 2025-04-06 05:57:36 +03:00
Now the constructor of AbstractDiskWriter takes filename as an argument and filename argument is removed from openFile(), initAndOpenFile(), openExistingFile() interface. storeDir member and its accessor functions are removed from DiskAdaptor because it is not used anymore. size() member function of DefaultDiskWriter, DirectDiskAdaptor and MultiDiskAdaptor now can be called without opening file. * src/AbstractDiskWriter.cc * src/AbstractDiskWriter.h * src/AbstractSingleDiskAdaptor.cc * src/AbstractSingleDiskAdaptor.h * src/ByteArrayDiskWriter.cc * src/ByteArrayDiskWriter.h * src/ByteArrayDiskWriterFactory.cc * src/ByteArrayDiskWriterFactory.h * src/DefaultDiskWriter.cc * src/DefaultDiskWriter.h * src/DefaultDiskWriterFactory.cc * src/DefaultDiskWriterFactory.h * src/DefaultPieceStorage.cc * src/DirectDiskAdaptor.cc * src/DirectDiskAdaptor.h * src/DiskAdaptor.h * src/DiskWriter.h * src/DiskWriterFactory.h * src/MessageDigestHelper.cc * src/MultiDiskAdaptor.cc * src/RequestGroup.cc * src/UnknownLengthPieceStorage.cc * src/Util.cc * test/DefaultDiskWriterTest.cc * test/DirectDiskAdaptorTest.cc * test/FallocFileAllocationIteratorTest.cc * test/MessageDigestHelperTest.cc * test/MetalinkProcessorTest.cc * test/MultiDiskAdaptorTest.cc * test/MultiFileAllocationIteratorTest.cc * test/SingleFileAllocationIteratorTest.cc * test/UtilTest.cc
55 lines
1.5 KiB
C++
55 lines
1.5 KiB
C++
#include "MessageDigestHelper.h"
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
#include "Util.h"
|
|
#include "DefaultDiskWriter.h"
|
|
|
|
namespace aria2 {
|
|
|
|
class MessageDigestHelperTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(MessageDigestHelperTest);
|
|
CPPUNIT_TEST(testDigestDiskWriter);
|
|
CPPUNIT_TEST(testDigestFilename);
|
|
CPPUNIT_TEST(testDigestData);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
private:
|
|
|
|
public:
|
|
void setUp() {
|
|
}
|
|
|
|
void testDigestDiskWriter();
|
|
void testDigestFilename();
|
|
void testDigestData();
|
|
};
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( MessageDigestHelperTest );
|
|
|
|
void MessageDigestHelperTest::testDigestDiskWriter() {
|
|
SharedHandle<DefaultDiskWriter> diskio
|
|
(new DefaultDiskWriter("4096chunk.txt"));
|
|
diskio->openExistingFile();
|
|
CPPUNIT_ASSERT_EQUAL(std::string("608cabc0f2fa18c260cafd974516865c772363d5"),
|
|
MessageDigestHelper::digest("sha1", diskio, 0, 4096));
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("7a4a9ae537ebbbb826b1060e704490ad0f365ead"),
|
|
MessageDigestHelper::digest("sha1", diskio, 5, 100));
|
|
}
|
|
|
|
void MessageDigestHelperTest::testDigestFilename()
|
|
{
|
|
CPPUNIT_ASSERT_EQUAL(std::string("608cabc0f2fa18c260cafd974516865c772363d5"),
|
|
MessageDigestHelper::digest("sha1", "4096chunk.txt"));
|
|
}
|
|
|
|
void MessageDigestHelperTest::testDigestData()
|
|
{
|
|
std::string data = "aria2";
|
|
CPPUNIT_ASSERT_EQUAL(std::string("f36003f22b462ffa184390533c500d8989e9f681"),
|
|
MessageDigestHelper::digest("sha1", data.c_str(), data.size()));
|
|
}
|
|
|
|
} // namespace aria2
|