~singpolyma/biboumi

ref: 3c1889fbd0d7b96aae16f3479ac8aae70a7e15f7 biboumi/tests/config.cpp -rw-r--r-- 525 bytes
3c1889fb — Florent Le Coz Use Catch for our test suite 7 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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);
}