mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed util tests
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6046 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7e19517451
commit
d1752bbdcb
@ -27,6 +27,7 @@
|
||||
|
||||
|
||||
#include "util/rsdir.h"
|
||||
#include "util/utest.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
@ -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)
|
||||
|
@ -27,7 +27,8 @@
|
||||
|
||||
|
||||
#include "util/rsdir.h"
|
||||
#include "../common/argstream.h"
|
||||
#include "util/utest.h"
|
||||
#include <common/argstream.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
@ -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() ;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user