diff options
author | Florent Le Coz <louiz@louiz.org> | 2015-10-28 19:13:53 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2015-10-29 02:32:57 +0100 |
commit | 3c1889fbd0d7b96aae16f3479ac8aae70a7e15f7 (patch) | |
tree | 69c90435a43b906115b34d4542122000571b971e /tests/config.cpp | |
parent | 4e32fe213cccdc6cdc1dcba498fd74b8b97703ea (diff) | |
download | biboumi-3c1889fbd0d7b96aae16f3479ac8aae70a7e15f7.tar.gz biboumi-3c1889fbd0d7b96aae16f3479ac8aae70a7e15f7.tar.bz2 biboumi-3c1889fbd0d7b96aae16f3479ac8aae70a7e15f7.tar.xz biboumi-3c1889fbd0d7b96aae16f3479ac8aae70a7e15f7.zip |
Use Catch for our test suite
`make check` is also added to compile and run the tests
Catch is fetched with cmake automatically into the build directory when needed
Diffstat (limited to 'tests/config.cpp')
-rw-r--r-- | tests/config.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/config.cpp b/tests/config.cpp new file mode 100644 index 0000000..1419f0b --- /dev/null +++ b/tests/config.cpp @@ -0,0 +1,25 @@ +#include "catch.hpp" + +#include <config/config.hpp> + +TEST_CASE("Config basic") +{ + 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; + CHECK(Config::get("coucou", "") == "bonjour"); + CHECK(Config::get("does not exist", "default") == "default"); + Config::close(); + } + catch (const std::ios::failure& e) + { + error = true; + } + CHECK_FALSE(error); +} |