diff options
author | Florent Le Coz <louiz@louiz.org> | 2014-05-26 03:59:42 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2014-05-28 17:40:45 +0200 |
commit | a350caf6e0fb95263e929fde7dd4f58931f0825c (patch) | |
tree | af83d15021a5ba5054b386362dceada699e34ca8 /src/test.cpp | |
parent | d9d30dd782870b2ab6584fb54b7c19a2a9ae4c78 (diff) | |
download | biboumi-a350caf6e0fb95263e929fde7dd4f58931f0825c.tar.gz biboumi-a350caf6e0fb95263e929fde7dd4f58931f0825c.tar.bz2 biboumi-a350caf6e0fb95263e929fde7dd4f58931f0825c.tar.xz biboumi-a350caf6e0fb95263e929fde7dd4f58931f0825c.zip |
Move the logging + config test on first position
Diffstat (limited to 'src/test.cpp')
-rw-r--r-- | src/test.cpp | 66 |
1 files 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("[m"); 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; } |