/* This file is part of xdgcfg. */
#include <exception>
#include <string>
#include <catch.hpp>
#include "xdgcfg.hpp"
using std::string;
SCENARIO ("A config file can be written and then read.")
{
bool exception = false;
WHEN ("Writing config")
xdgcfg config("test.cfg", "xdgcfg");
libconfig::Config &cfg = config.get_cfg();
libconfig::Setting &root = cfg.getRoot();
try
root.add("Hello", libconfig::Setting::TypeString) = "World! 🙂";
config.write();
}
catch (const std::exception &e)
exception = true;
THEN ("No exception is thrown")
REQUIRE_FALSE(exception);
WHEN ("Reading config")
string value;
value = root["Hello"].c_str();
AND_THEN ("Value is correct")
REQUIRE(value == "World! 🙂");