Test that comments are handled properly. (#309263, Mikael Magnusson)
authorMatthias Clasen <mclasen@redhat.com>
Fri, 1 Jul 2005 15:56:03 +0000 (15:56 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 1 Jul 2005 15:56:03 +0000 (15:56 +0000)
2005-07-01  Matthias Clasen  <mclasen@redhat.com>

* tests/keyfile-test.c (test_comments): Test that comments are
handled properly.  (#309263, Mikael Magnusson)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-8
tests/keyfile-test.c

index 253972e..d8be059 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-07-01  Matthias Clasen  <mclasen@redhat.com>
+
+       * tests/keyfile-test.c (test_comments): Test that comments are
+       handled properly.  (#309263, Mikael Magnusson)
+
 2005-06-30  Matthias Clasen  <mclasen@redhat.com>
 
        * configure.in: Bump version
index 253972e..d8be059 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-01  Matthias Clasen  <mclasen@redhat.com>
+
+       * tests/keyfile-test.c (test_comments): Test that comments are
+       handled properly.  (#309263, Mikael Magnusson)
+
 2005-06-30  Matthias Clasen  <mclasen@redhat.com>
 
        * configure.in: Bump version
index 253972e..d8be059 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-01  Matthias Clasen  <mclasen@redhat.com>
+
+       * tests/keyfile-test.c (test_comments): Test that comments are
+       handled properly.  (#309263, Mikael Magnusson)
+
 2005-06-30  Matthias Clasen  <mclasen@redhat.com>
 
        * configure.in: Bump version
index 253972e..d8be059 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-01  Matthias Clasen  <mclasen@redhat.com>
+
+       * tests/keyfile-test.c (test_comments): Test that comments are
+       handled properly.  (#309263, Mikael Magnusson)
+
 2005-06-30  Matthias Clasen  <mclasen@redhat.com>
 
        * configure.in: Bump version
index 1df71d3..730bba4 100644 (file)
@@ -367,6 +367,49 @@ test_whitespace (void)
   g_key_file_free (keyfile);
 }
 
+/* check handling of comments
+ */
+static void
+test_comments (void)
+{
+  GKeyFile *keyfile;
+  gchar **names;
+  gsize len;
+  GError *error = NULL;
+
+  const gchar *data = 
+    "# comment 1\n"
+    "# second line\n"
+    "[group1]\n"
+    "key1 = value1\n"
+    "#comment 2\n"
+    "key2 = value2\n"
+    "# comment 3\r\n"
+    "key3 = value3\n"
+    "key4 = value4\n";
+  
+  keyfile = load_data (data, 0);
+
+  check_string_value (keyfile, "group1", "key1", "value1");
+  check_string_value (keyfile, "group1", "key2", "value2");
+  check_string_value (keyfile, "group1", "key3", "value3");
+  check_string_value (keyfile, "group1", "key4", "value4");
+
+  names = g_key_file_get_keys (keyfile, "group1", &len, &error);
+  check_no_error (&error);
+
+  check_length ("keys", g_strv_length (names), len, 4);
+  check_name ("key", names[0], "key1", 0);
+  check_name ("key", names[1], "key2", 1);
+  check_name ("key", names[2], "key3", 2);
+  check_name ("key", names[3], "key4", 3);
+
+  g_strfreev (names);
+
+  g_key_file_free (keyfile);
+}
+
+
 /* check key and group listing */
 static void
 test_listing (void)
@@ -783,6 +826,7 @@ main (int argc, char *argv[])
 {
   test_line_ends ();
   test_whitespace ();
+  test_comments ();
   test_listing ();
   test_string ();
   test_boolean ();