- rework the testsuite after new boost in factory broke it.
[platform/upstream/libzypp.git] / tests / zypp / Digest_test.cc
1
2 #include <iostream>
3 #include <sstream>
4 #include <fstream>
5 #include <list>
6 #include <string>
7
8 #include <boost/test/unit_test.hpp>
9
10 #include "zypp/base/Logger.h"
11 #include "zypp/base/Exception.h"
12 #include "zypp/PathInfo.h"
13 #include "zypp/Digest.h"
14
15 using boost::unit_test::test_case;
16
17 using namespace std;
18 using namespace zypp;
19 using namespace zypp::filesystem;
20
21 /**
22  * Test case for
23  * static std::string digest(const std::string& name, std::istream& is, size_t bufsize = 4096);
24  */
25 BOOST_AUTO_TEST_CASE(digest)
26 {
27   string data("I will test the checksum of this");
28   stringstream str1(data);
29   stringstream str2(data);
30   stringstream str3(data);
31
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) , "" ); 
36 }