#include <stdio.h>
#include "test.h"
-#define sfail(k,p) if (s->str [p] != k) { g_string_free (s,TRUE); return result ("Got %s, Failed at %d, expected '%c'", s->str, p, k);}
+#define sfail(k,p) if (s->str [p] != k) { g_string_free (s,TRUE); return FAILED("Got %s, Failed at %d, expected '%c'", s->str, p, k);}
-char *
+RESULT
test_gstring ()
{
GString *s = g_string_new_len ("My stuff", 2);
if (s->str [2] != 0)
return "Null as not copied";
if (strncmp (s->str+4, "Relala", 6) != 0){
- return result("Did not copy correctly, got: %s", s->str+4);
+ return FAILED("Did not copy correctly, got: %s", s->str+4);
}
g_string_free (s, TRUE);
g_string_append (s, "x");
}
if (strlen (s->str) != 1024){
- return result("Incorrect string size, got: %s %d", s->str, strlen (s->str));
+ return FAILED("Incorrect string size, got: %s %d", s->str, strlen (s->str));
}
g_string_free (s, TRUE);
g_string_append_c (s, 'x');
}
if (strlen (s->str) != 1024){
- return result("Incorrect string size, got: %s %d\n", s->str, strlen (s->str));
+ return FAILED("Incorrect string size, got: %s %d\n", s->str, strlen (s->str));
}
g_string_free (s, TRUE);
s = g_string_new ("hola");
g_string_sprintfa (s, "%s%d", ", bola", 5);
if (strcmp (s->str, "hola, bola5") != 0){
- return result("Incorrect data, got: %s\n", s->str);
+ return FAILED("Incorrect data, got: %s\n", s->str);
}
g_string_free (s, TRUE);
sfail ('2', 5);
g_string_free (s, TRUE);
- return NULL;
+ return OK;
}
static Test string_tests [] = {