grim/gplate
Clone
Summary
Browse
Changes
Graph
apparently the .SUFFIXES target is supposed to be a variable now..
2009-06-21, Gary Kramlich
11f7012c3517
apparently the .SUFFIXES target is supposed to be a variable now..
#include
<gplate/gplate.h>
#include
"test.h"
/******************************************************************************
* Quoted String Tests
*****************************************************************************/
static
void
test_quoted_string
(
const
gchar
*
string
,
const
gchar
*
contents
,
gboolean
value
)
{
gboolean
r
=
FALSE
;
gchar
*
c
=
NULL
;
r
=
gplate_util_is_quoted_string
(
string
,
&
c
);
fail_unless
(
r
==
value
,
TEST_EXPECTED_ACTUAL_MSG
,
(
value
)
?
"TRUE"
:
"FALSE"
,
(
r
)
?
"TRUE"
:
"FALSE"
);
if
(
contents
)
test_string
(
contents
,
c
);
g_free
(
c
);
}
START_TEST
(
test_double_quoted_string_simple
)
test_quoted_string
(
"
\"
abc
\"
"
,
"abc"
,
TRUE
);
END_TEST
START_TEST
(
test_double_quoted_string_spaces
)
test_quoted_string
(
"
\"
abc def
\"
"
,
"abc def"
,
TRUE
);
END_TEST
START_TEST
(
test_double_quoted_string_complex
)
test_quoted_string
(
"
\"
abc
\t
def
\b
ghi
\"
"
,
"abc
\t
def
\b
ghi"
,
TRUE
);
END_TEST
START_TEST
(
test_double_quoted_string_prefix
)
test_quoted_string
(
"abc
\"
def
\"
"
,
NULL
,
FALSE
);
END_TEST
START_TEST
(
test_double_quoted_string_suffix
)
test_quoted_string
(
"
\"
abc
\"
def"
,
NULL
,
FALSE
);
END_TEST
START_TEST
(
test_single_quoted_string_simple
)
test_quoted_string
(
"'abc'"
,
"abc"
,
TRUE
);
END_TEST
START_TEST
(
test_single_quoted_string_spaces
)
test_quoted_string
(
"'abc def'"
,
"abc def"
,
TRUE
);
END_TEST
START_TEST
(
test_single_quoted_string_complex
)
test_quoted_string
(
"'abc
\t
def
\b
ghi'"
,
"abc
\t
def
\b
ghi"
,
TRUE
);
END_TEST
START_TEST
(
test_single_quoted_string_prefix
)
test_quoted_string
(
"abc 'def'"
,
NULL
,
FALSE
);
END_TEST
START_TEST
(
test_single_quoted_string_suffix
)
test_quoted_string
(
"'abc' def"
,
NULL
,
FALSE
);
END_TEST
START_TEST
(
test_mixmatched_quoted_string_single_double
)
test_quoted_string
(
"'abc
\"
"
,
NULL
,
FALSE
);
END_TEST
START_TEST
(
test_mixmatched_quoted_string_double_single
)
test_quoted_string
(
"
\"
abc'"
,
NULL
,
FALSE
);
END_TEST
/******************************************************************************
* API
*****************************************************************************/
Suite
*
test_util_suite
(
void
)
{
Suite
*
s
=
suite_create
(
"Utility Suite"
);
TCase
*
tc
=
NULL
;
/* quoted string */
tc
=
tcase_create
(
"Quoted String"
);
tcase_add_test
(
tc
,
test_double_quoted_string_simple
);
tcase_add_test
(
tc
,
test_double_quoted_string_spaces
);
tcase_add_test
(
tc
,
test_double_quoted_string_complex
);
tcase_add_test
(
tc
,
test_double_quoted_string_prefix
);
tcase_add_test
(
tc
,
test_double_quoted_string_suffix
);
tcase_add_test
(
tc
,
test_single_quoted_string_simple
);
tcase_add_test
(
tc
,
test_single_quoted_string_spaces
);
tcase_add_test
(
tc
,
test_single_quoted_string_complex
);
tcase_add_test
(
tc
,
test_single_quoted_string_prefix
);
tcase_add_test
(
tc
,
test_single_quoted_string_suffix
);
tcase_add_test
(
tc
,
test_mixmatched_quoted_string_single_double
);
tcase_add_test
(
tc
,
test_mixmatched_quoted_string_double_single
);
suite_add_tcase
(
s
,
tc
);
/* first word */
return
s
;
}