[libsoup] Add test for soup_form_decode().
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] Add test for soup_form_decode().
- Date: Tue, 18 Jan 2011 22:48:11 +0000 (UTC)
commit 54cbf614d9b537a77fbcc9efbd2b947df3f2569e
Author: Sven Neumann <s neumann raumfeld com>
Date: Tue Jan 18 10:08:41 2011 -0500
Add test for soup_form_decode().
Add a test that checks how soup_form_decode() handles multiple values
with the same key.
tests/forms-test.c | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/tests/forms-test.c b/tests/forms-test.c
index d18ee59..6cdc6ad 100644
--- a/tests/forms-test.c
+++ b/tests/forms-test.c
@@ -228,6 +228,36 @@ do_md5_tests (const char *uri)
g_free (md5);
}
+
+static void
+do_form_decode_test (void)
+{
+ GHashTable *table;
+ const gchar *value;
+ gchar *tmp;
+
+ debug_printf (1, "\nDecode tests\n");
+
+ /* Test that the code handles multiple values with the same key. */
+ table = soup_form_decode ("foo=first&foo=second&foo=third");
+
+ /* Allocate some memory. We do this to test for a bug in
+ * soup_form_decode() that resulted in values from the hash
+ * table pointing to memory that is already released.
+ */
+ tmp = g_strdup ("other");
+
+ value = g_hash_table_lookup (table, "foo");
+ if (g_strcmp0 (value, "third") != 0) {
+ debug_printf (1, " ERROR: expected '%s', got '%s'\n",
+ "third", value ? value : "(null)");
+ errors++;
+ }
+
+ g_free (tmp);
+ g_hash_table_destroy (table);
+}
+
static void
hello_callback (SoupServer *server, SoupMessage *msg,
const char *path, GHashTable *query,
@@ -425,6 +455,8 @@ main (int argc, char **argv)
uri_str = g_strdup_printf ("http://127.0.0.1:%u/md5", port);
do_md5_tests (uri_str);
g_free (uri_str);
+
+ do_form_decode_test ();
} else {
printf ("Listening on port %d\n", port);
g_main_loop_run (loop);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]