xmltest.cpp File Reference

A unitary test for the XmlConfig class. Needs the files sample1.xml, sample2.xml and sample3.xml. More...

#include "xmlconfig.hpp"

Go to the source code of this file.

Functions

void printHash (cryptoTools::SHAx *hash)
 Prints the output of a hasfunction when given the empty array as a parameter.
void parseAndPrint (std::string path)
 Parses an xml file and outputs its content.
int main (void)
 Tests that XmlConfig works fine by parsing several sample config file and outputing their content.

Detailed Description

A unitary test for the XmlConfig class. Needs the files sample1.xml, sample2.xml and sample3.xml.

Author
Léo Perrin
Date
Time-stamp: <2012-08-26 00:10:46 leo>
See Also
verifierUtils::XmlConfig

Definition in file xmltest.cpp.

Function Documentation

int main ( void  )

Tests that XmlConfig works fine by parsing several sample config file and outputing their content.

The sample files are sample1.xml, sample2.xml and sample3.xml. They have to be in the same folder as the executable file resulting from the compilation of this one.

Definition at line 71 of file xmltest.cpp.

{
std::string path1("sample1.xml");
parseAndPrint(path1);
std::string path2("sample2.xml");
parseAndPrint(path2);
std::string path3("sample3.xml");
parseAndPrint(path3);
return 0;
}
void parseAndPrint ( std::string  path)

Parses an xml file and outputs its content.

The integer value fields are just printed on the screen but others have a more complicated treatement:

  • The RoHash attribute is actually "asked" to compute the hash of the empty string.
Parameters
pathThe path to the config file to parse.

Definition at line 43 of file xmltest.cpp.

{
XmlConfig conf(path);
std::cout<<"nopart: "<<std::dec<<conf.getNopart()
<<std::endl;
std::cout<<"thres: "<<conf.getThres() <<std::endl;
std::cout<<"maxciph: "<<conf.getMaxciph() <<std::endl;
std::cout<<"vbitlenro: "<<conf.getVbitlenro()<<std::endl;
std::cout<<"statdist: "<<conf.getStatdist()<<std::endl;
std::cout<<"cbitlenro: "<<conf.getCbitlenro()<<std::endl;
std::cout<<"rohash: ";
printHash(conf.getRohash());
std::cout<<std::endl;
std::cout<<"prghash: ";
printHash(conf.getPrghash());
std::cout<<std::endl;
std::cout<<conf.getPgroup()->toByteTree()->toString()<<std::endl;
}
void printHash ( cryptoTools::SHAx hash)

Prints the output of a hasfunction when given the empty array as a parameter.

Parameters
hashThe hash function to test.

Definition at line 22 of file xmltest.cpp.

{
std::vector<unsigned char> hashTest;
hash->hash(hashTest);
std::cout<<hash->getType()<<", "<<std::hex;
for (unsigned int i=0; i<hash->getHashLength()/8; i++)
std::cout<<(int)hash->getHash()[i];
}