From a350caf6e0fb95263e929fde7dd4f58931f0825c Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Mon, 26 May 2014 03:59:42 +0200 Subject: Move the logging + config test on first position --- src/test.cpp | 66 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/src/test.cpp b/src/test.cpp index fe89b5a..2b9aca2 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -27,6 +27,40 @@ static const std::string reset(""); 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 */ @@ -229,37 +263,5 @@ int main() std::cout << correctjid2 << std::endl; 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; } -- cgit v1.2.3