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