gplate/tests/test-gplate-utility-functions.c
author Gary Kramlich <grim@reaperworld.com>
Sun Jul 04 03:34:39 2010 -0500 (22 months ago)
changeset 400 0938cb5d076b
parent 394 gplate/tests/test-util-functions.c@ad26d98e20e6
permissions -rw-r--r--
the start of the test name standardization

refs #15
     1 /*
     2  * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
     3  * * This program is free software: you can redistribute it and/or modify
     4  * it under the terms of the GNU General Public License as published by
     5  * the Free Software Foundation, either version 3 of the License, or
     6  * (at your option) any later version.
     7  *
     8  * This program is distributed in the hope that it will be useful,
     9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  * GNU General Public License for more details.
    12  *
    13  * You should have received a copy of the GNU General Public License
    14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    15  */
    16 #include <gplate/gplate.h>
    17 
    18 static void
    19 gplate_util_test_quoted_string_helper(const gchar *string,
    20 									  const gchar *contents, gboolean value)
    21 {
    22 	gboolean r = FALSE;
    23 	gchar *c = NULL;
    24 
    25 	r = gplate_util_is_quoted_string(string, &c);
    26 	g_assert_cmpint(r, ==, value);
    27 
    28 	if(contents)
    29 		g_assert_cmpstr(c, ==, contents);
    30 	
    31 	g_free(c);
    32 }
    33 
    34 static void
    35 gplate_util_test_quoted_string(void) {
    36 	gplate_util_test_quoted_string_helper("\"abc\"", "abc", TRUE);
    37 	gplate_util_test_quoted_string_helper("\"abc def\"", "abc def", TRUE);
    38 	gplate_util_test_quoted_string_helper("\"abc\tdef\bghi\"", "abc\tdef\bghi", TRUE);
    39 	gplate_util_test_quoted_string_helper("abc \"def\"", NULL, FALSE);
    40 	gplate_util_test_quoted_string_helper("\"abc\" def", NULL, FALSE);
    41 	gplate_util_test_quoted_string_helper("'abc'", "abc", TRUE);
    42 	gplate_util_test_quoted_string_helper("'abc def'", "abc def", TRUE);
    43 	gplate_util_test_quoted_string_helper("'abc\tdef\bghi'", "abc\tdef\bghi", TRUE);
    44 	gplate_util_test_quoted_string_helper("abc 'def'", NULL, FALSE);
    45 	gplate_util_test_quoted_string_helper("'abc' def", NULL, FALSE);
    46 	gplate_util_test_quoted_string_helper("'abc\"", NULL, FALSE);
    47 	gplate_util_test_quoted_string_helper("\"abc'", NULL, FALSE);
    48 }
    49 
    50 gint
    51 main(gint argc, gchar **argv) {
    52 	g_test_init(&argc, &argv, NULL);
    53 
    54 	g_test_add_func("/util/quoted_string", gplate_util_test_quoted_string);
    55 
    56 	return g_test_run();
    57 }
    58