From d1752bbdcbec4f4177dea9cbcfdd5849795c35cb Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 27 Dec 2012 15:58:55 +0000 Subject: [PATCH] fixed util tests git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6046 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/tests/util/dirtest.cc | 7 +++++++ libretroshare/src/tests/util/sha1_test.cc | 21 ++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/libretroshare/src/tests/util/dirtest.cc b/libretroshare/src/tests/util/dirtest.cc index b8857b71b..862a77913 100644 --- a/libretroshare/src/tests/util/dirtest.cc +++ b/libretroshare/src/tests/util/dirtest.cc @@ -27,6 +27,7 @@ #include "util/rsdir.h" +#include "util/utest.h" #include #include @@ -34,6 +35,8 @@ bool testRsDirUtils(std::string path); +INITTEST() ; + int main() { @@ -62,6 +65,10 @@ int main() { testRsDirUtils(*it); } + + FINALREPORT("dirtest"); + + return TESTRESULT() ; } bool testRsDirUtils(std::string path) diff --git a/libretroshare/src/tests/util/sha1_test.cc b/libretroshare/src/tests/util/sha1_test.cc index 1b8b5293b..bd95dc12d 100644 --- a/libretroshare/src/tests/util/sha1_test.cc +++ b/libretroshare/src/tests/util/sha1_test.cc @@ -27,7 +27,8 @@ #include "util/rsdir.h" -#include "../common/argstream.h" +#include "util/utest.h" +#include #include #include @@ -40,6 +41,8 @@ void printHelp(int argc,char *argv[]) std::cerr << "Usage: " << argv[0] << " [test file]" << std::endl ; } +INITTEST() ; + int main(int argc,char *argv[]) { std::string inputfile ; @@ -55,11 +58,7 @@ int main(int argc,char *argv[]) FILE *f = RsDirUtil::rs_fopen(inputfile.c_str(),"r") ; - if(f == NULL) - { - std::cerr << "Cannot open file " << inputfile << " for read !" << std::endl; - return -1 ; - } + CHECK(f != NULL) ; std::cerr << "Testing sha1" << std::endl; uint32_t SIZE = 1024*1024 ; @@ -79,13 +78,11 @@ int main(int argc,char *argv[]) RsDirUtil::getFileHash(inputfile.c_str(),hash,size) ; std::cerr << "Old method : " << hash << std::endl; - if(hash != sum.toStdString()) - return -1 ; + CHECK(hash == sum.toStdString()) ; Sha1CheckSum H(hash) ; std::cerr << "Hashed transformed: " << H.toStdString() << std::endl; - if(hash != H.toStdString()) - return -1 ; + CHECK(hash == H.toStdString()) ; std::cerr << "Computing all chunk hashes:" << std::endl; @@ -100,6 +97,8 @@ int main(int argc,char *argv[]) } fclose(f) ; - return 0 ; + + FINALREPORT("Sha1Test") ; + return TESTRESULT() ; }