gplate/tests/test-util-functions.c
author Gary Kramlich <grim@reaperworld.com>
Sat Jun 26 15:25:18 2010 -0500 (23 months ago)
changeset 388 301bcc8bdad0
parent 364 tests/test-util.c@bbab7cbd784c
child 394 ad26d98e20e6
permissions -rw-r--r--
moving more testing stuff to it's new home and implementation
     1 #include <gplate/gplate.h>
     2 
     3 static void
     4 gplate_util_test_quoted_string_helper(const gchar *string,
     5 									  const gchar *contents, gboolean value)
     6 {
     7 	gboolean r = FALSE;
     8 	gchar *c = NULL;
     9 
    10 	r = gplate_util_is_quoted_string(string, &c);
    11 	g_assert_cmpint(r, ==, value);
    12 
    13 	if(contents)
    14 		g_assert_cmpstr(c, ==, contents);
    15 	
    16 	g_free(c);
    17 }
    18 
    19 static void
    20 gplate_util_test_quoted_string(void) {
    21 	gplate_util_test_quoted_string_helper("\"abc\"", "abc", TRUE);
    22 	gplate_util_test_quoted_string_helper("\"abc def\"", "abc def", TRUE);
    23 	gplate_util_test_quoted_string_helper("\"abc\tdef\bghi\"", "abc\tdef\bghi", TRUE);
    24 	gplate_util_test_quoted_string_helper("abc \"def\"", NULL, FALSE);
    25 	gplate_util_test_quoted_string_helper("\"abc\" def", NULL, FALSE);
    26 	gplate_util_test_quoted_string_helper("'abc'", "abc", TRUE);
    27 	gplate_util_test_quoted_string_helper("'abc def'", "abc def", TRUE);
    28 	gplate_util_test_quoted_string_helper("'abc\tdef\bghi'", "abc\tdef\bghi", TRUE);
    29 	gplate_util_test_quoted_string_helper("abc 'def'", NULL, FALSE);
    30 	gplate_util_test_quoted_string_helper("'abc' def", NULL, FALSE);
    31 	gplate_util_test_quoted_string_helper("'abc\"", NULL, FALSE);
    32 	gplate_util_test_quoted_string_helper("\"abc'", NULL, FALSE);
    33 }
    34 
    35 gint
    36 main(gint argc, gchar **argv) {
    37 	g_test_init(&argc, &argv, NULL);
    38 
    39 	g_test_add_func("/util/quoted_string", gplate_util_test_quoted_string);
    40 
    41 	return g_test_run();
    42 }
    43