changeset 513:e412a39e2b7a

Add another test for configuration parsing.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 26 Dec 2019 09:10:07 +0200
parents 5c3bfe034915
children db3fc3d4969e
files cfg.test01 tests.c
diffstat 2 files changed, 34 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cfg.test01	Thu Dec 26 09:10:07 2019 +0200
@@ -0,0 +1,31 @@
+# Configuration written by th-libs unit tests 0.2
+
+general = {
+    # A comment that
+    # spans multiple
+    # lines automatically
+    a_string_setting = "v_str1" #test
+
+    # Hex triplet value setting
+    hexval="11223344"
+
+    # A boolean value
+    boolval = no
+
+    # A string list
+    string_list = "zoo",
+
+   "foo",
+"bar"
+}
+
+another_sect = {
+    # Another section
+    boolval = yes
+    inside_sect = {
+        # Section inside a section
+        intval
+= 112
+    }
+}
+
--- a/tests.c	Thu Dec 26 09:01:32 2019 +0200
+++ b/tests.c	Thu Dec 26 09:10:07 2019 +0200
@@ -434,7 +434,7 @@
 
 void test_config(void)
 {
-    static const char *filename = "tmp.config";
+    static const char *filename = "cfg.temp";
     test_ctx ctx;
     th_ioctx *fh = NULL;
     th_cfgitem_t *sect1, *sect2, *cfg = NULL, *item;
@@ -500,6 +500,8 @@
     // Test against written configuration file
     test_config_read(cfg, filename);
 
+    // Test against manually edited configuration file
+    test_config_read(cfg, "cfg.test01");
 
 out:
     // Free the data for v_str_list