#include "tests.h" #include "msql_acces.h" #include #include #include void test_basic::setUp(){ this->conf=new config_reader("config"); this->data=new msql_acces(); } void test_basic::test_initial(){ std::string res; CPPUNIT_ASSERT(true==this->conf->get_param("port",res)); CPPUNIT_ASSERT("4433"==res); } void test_basic::pass_tests(){ CPPUNIT_NS::TestResult testresult; CPPUNIT_NS::TestResultCollector collectedresults; testresult.addListener (&collectedresults); CPPUNIT_NS::BriefTestProgressListener progress; testresult.addListener (&progress); CPPUNIT_NS::TestRunner testrunner; testrunner.addTest (CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest ()); testrunner.run(testresult); } void test_basic::hash_test(){ CPPUNIT_ASSERT(strcmp(data_acces::get_hash("test1") ,data_acces::get_hash("test1"))==0); CPPUNIT_ASSERT(strcmp(data_acces::get_hash("test1") ,data_acces::get_hash("test2"))!=0); } void test_basic::msql_loggin_test(){ std::string pass = this->data->get_passwd("test"); CPPUNIT_ASSERT(pass==std::string(data_acces::get_hash("ok"))); CPPUNIT_ASSERT(pass!=std::string(data_acces::get_hash("fail"))); } void test_basic::msql_package_test(){ data->write_install("p1","test"); CPPUNIT_ASSERT(data->get_package_exists("p1")); data->write_remove("p1"); CPPUNIT_ASSERT(!data->get_package_exists("p1")); }