RESULT
test_strreverse ()
{
+ RESULT res = OK;
gchar *a = g_strdup ("onetwothree");
gchar *a_target = "eerhtowteno";
gchar *b = g_strdup ("onetwothre");
gchar *b_target = "erhtowteno";
+ gchar *c = g_strdup ("");
+ gchar *c_target = "";
g_strreverse (a);
if (strcmp (a, a_target)) {
- g_free (b);
- g_free (a);
- return FAILED("strreverse failed. Expecting: '%s' and got '%s'\n", a, a_target);
+ res = FAILED("strreverse failed. Expecting: '%s' and got '%s'\n", a, a_target);
+ goto cleanup;
}
g_strreverse (b);
if (strcmp (b, b_target)) {
- g_free (b);
- g_free (a);
- return FAILED("strreverse failed. Expecting: '%s' and got '%s'\n", b, b_target);
+ res = FAILED("strreverse failed. Expecting: '%s' and got '%s'\n", b, b_target);
+ goto cleanup;
}
+
+ g_strreverse (c);
+ if (strcmp (c, c_target)) {
+ res = FAILED("strreverse failed. Expecting: '%s' and got '%s'\n", b, b_target);
+ goto cleanup;
+ }
+
+cleanup:
+ g_free (c);
g_free (b);
g_free (a);
- return OK;
+ return res;
}
RESULT
return OK;
}
+RESULT
+test_strdupv ()
+{
+ gchar **one;
+ gchar **two;
+ gint len;
+
+ one = g_strdupv (NULL);
+ if (one)
+ return FAILED ("Should have been NULL");
+
+ one = g_malloc (sizeof (gchar *));
+ *one = NULL;
+ two = g_strdupv (one);
+ if (!two)
+ FAILED ("Should have been not NULL");
+ len = g_strv_length (two);
+ if (len)
+ FAILED ("Should have been 0");
+ g_strfreev (two);
+ g_strfreev (one);
+ return NULL;
+}
+
static Test strutil_tests [] = {
{"g_strfreev", test_strfreev},
{"g_strconcat", test_concat},
{"g_strescape", test_strescape},
{"g_ascii_strncasecmp", test_ascii_strncasecmp },
{"g_ascii_strdown", test_ascii_strdown },
+ {"g_strdupv", test_strdupv },
{NULL, NULL}
};