Move the logging + config test on first position

This commit is contained in:
Florent Le Coz
2014-05-28 17:40:45 +02:00
parent d9d30dd782
commit a350caf6e0
+34 -32
View File
@@ -27,6 +27,40 @@ static const std::string reset("");
int main() int main()
{ {
/**
* Config
*/
std::cout << color << "Testing config…" << reset << std::endl;
Config::filename = "test.cfg";
Config::file_must_exist = false;
Config::set("coucou", "bonjour", true);
Config::close();
bool error = false;
try
{
Config::file_must_exist = true;
assert(Config::get("coucou", "") == "bonjour");
assert(Config::get("does not exist", "default") == "default");
Config::close();
}
catch (const std::ios::failure& e)
{
error = true;
}
assert(error == false);
Config::set("log_level", "2");
Config::set("log_file", "");
std::cout << color << "Testing logging…" << reset << std::endl;
log_debug("If you see this, the test FAILED.");
log_info("If you see this, the test FAILED.");
log_warning("You wust see this message. And the next one too.");
log_error("It’s not an error, don’t worry, the test passed.");
/** /**
* Timed events * Timed events
*/ */
@@ -229,37 +263,5 @@ int main()
std::cout << correctjid2 << std::endl; std::cout << correctjid2 << std::endl;
assert(correctjid2 == "zigougou@poez.io"); assert(correctjid2 == "zigougou@poez.io");
/**
* Config
*/
std::cout << color << "Testing config…" << reset << std::endl;
Config::filename = "test.cfg";
Config::file_must_exist = false;
Config::set("coucou", "bonjour", true);
Config::close();
bool error = false;
try
{
Config::file_must_exist = true;
assert(Config::get("coucou", "") == "bonjour");
assert(Config::get("does not exist", "default") == "default");
Config::close();
}
catch (const std::ios::failure& e)
{
error = true;
}
assert(error == false);
Config::set("log_level", "2");
Config::set("log_file", "");
std::cout << color << "Testing logging…" << reset << std::endl;
log_debug("If you see this, the test FAILED.");
log_info("If you see this, the test FAILED.");
log_warning("You wust see this message. And the next one too.");
log_error("It’s not an error, don’t worry, the test passed.");
return 0; return 0;
} }