8 #include <boost/test/unit_test.hpp>
10 #include "zypp/base/Logger.h"
11 #include "zypp/base/Exception.h"
12 #include "zypp/PathInfo.h"
13 #include "zypp/Digest.h"
15 using boost::unit_test::test_case;
19 using namespace zypp::filesystem;
23 * static std::string digest(const std::string& name, std::istream& is, size_t bufsize = 4096);
25 BOOST_AUTO_TEST_CASE(digest)
27 string data("I will test the checksum of this");
28 stringstream str1(data);
29 stringstream str2(data);
30 stringstream str3(data);
32 BOOST_CHECK_EQUAL( Digest::digest( "sha1", str1 ), "142df4277c326f3549520478c188cab6e3b5d042" );
33 BOOST_CHECK_EQUAL( Digest::digest( "md5", str2 ), "f139a810b84d82d1f29fc53c5e59beae" );
34 // FIXME i think it should throw
35 BOOST_CHECK_EQUAL( Digest::digest( "lalala", str3) , "" );