summaryrefslogtreecommitdiff
path: root/src/test.cpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-11-10 20:47:11 +0100
committerFlorent Le Coz <louiz@louiz.org>2013-11-10 20:47:11 +0100
commitf0d9273da61ce154dbe460cf58c98de851d30615 (patch)
treebbca8a7adca39ced153a7f4d04d3964692bd4f5d /src/test.cpp
parent10d528717723a72dd3240c634980a461cf9fa2df (diff)
downloadbiboumi-f0d9273da61ce154dbe460cf58c98de851d30615.tar.gz
biboumi-f0d9273da61ce154dbe460cf58c98de851d30615.tar.bz2
biboumi-f0d9273da61ce154dbe460cf58c98de851d30615.tar.xz
biboumi-f0d9273da61ce154dbe460cf58c98de851d30615.zip
Add a Config module, and use it to get the password from a file
Diffstat (limited to 'src/test.cpp')
-rw-r--r--src/test.cpp26
1 files changed, 25 insertions, 1 deletions
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 <utils/encoding.hpp>
#include <string.h>
+#include <config/config.hpp>
+
#include <xmpp/xmpp_parser.hpp>
int main()
@@ -49,7 +51,7 @@ int main()
* XML parsing
*/
XmppParser xml;
- const std::string doc = "<stream xmlns='stream_ns'><stanza b='c'>inner<child1/><child2 xmlns='child2_ns'/>tail</stanza></stream>";
+ const std::string doc = "<stream xmlns='stream_ns'><stanza b='c'>inner<child1><grandchild/></child1><child2 xmlns='child2_ns'/>tail</stanza></stream>";
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;
}