From f0d9273da61ce154dbe460cf58c98de851d30615 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sun, 10 Nov 2013 20:47:11 +0100 Subject: Add a Config module, and use it to get the password from a file --- src/test.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/test.cpp') diff --git a/src/test.cpp b/src/test.cpp index 674be98..99454a5 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -10,6 +10,8 @@ #include #include +#include + #include int main() @@ -49,7 +51,7 @@ int main() * XML parsing */ XmppParser xml; - const std::string doc = "innertail"; + const std::string doc = "innertail"; xml.add_stanza_callback([](const Stanza& stanza) { assert(stanza.get_name() == "stream_ns:stanza"); @@ -62,5 +64,27 @@ int main() assert(stanza.get_child("child2_ns:child2")->get_tail() == "tail"); }); xml.feed(doc.data(), doc.size(), true); + + /** + * Config + */ + Config::filename = "test.cfg"; + Config::file_must_exist = false; + Config::set("coucou", "bonjour"); + 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); return 0; } -- cgit v1.2.3