Create a test for octal chars in plist strings.

Both reading and writing.
This commit is contained in:
Bill Currie 2013-01-08 16:32:57 +09:00
parent 39ae720613
commit febb615580
2 changed files with 59 additions and 2 deletions

View file

@ -3,8 +3,8 @@ AUTOMAKE_OPTIONS= foreign
INCLUDES= -I$(top_srcdir)/include INCLUDES= -I$(top_srcdir)/include
check_PROGRAMS= \ check_PROGRAMS= \
test-dq test-half test-mat3 test-mat4 test-qfs test-quat test-set \ test-dq test-half test-mat3 test-mat4 test-plist test-qfs test-quat \
test-vrect test-set test-vrect
test_dq_SOURCES=test-dq.c test_dq_SOURCES=test-dq.c
test_dq_LDADD=$(top_builddir)/libs/util/libQFutil.la test_dq_LDADD=$(top_builddir)/libs/util/libQFutil.la
@ -22,6 +22,10 @@ test_mat4_SOURCES=test-mat4.c
test_mat4_LDADD=$(top_builddir)/libs/util/libQFutil.la test_mat4_LDADD=$(top_builddir)/libs/util/libQFutil.la
test_mat4_DEPENDENCIES=$(top_builddir)/libs/util/libQFutil.la test_mat4_DEPENDENCIES=$(top_builddir)/libs/util/libQFutil.la
test_plist_SOURCES=test-plist.c
test_plist_LDADD=$(top_builddir)/libs/util/libQFutil.la
test_plist_DEPENDENCIES=$(top_builddir)/libs/util/libQFutil.la
test_qfs_SOURCES=test-qfs.c test_qfs_SOURCES=test-qfs.c
test_qfs_LDADD=$(top_builddir)/libs/util/libQFutil.la test_qfs_LDADD=$(top_builddir)/libs/util/libQFutil.la
test_qfs_DEPENDENCIES=$(top_builddir)/libs/util/libQFutil.la test_qfs_DEPENDENCIES=$(top_builddir)/libs/util/libQFutil.la

View file

@ -0,0 +1,53 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#include "QF/qfplist.h"
static const char *test_strings[] = {
"Guarding the entrance to the Grendal\n"
"Gorge is the Shadow Gate, a small keep\n"
"and monastary which was once the home\n"
"of the Shadow cult.\n\n"
"For years the Shadow Gate existed in\n"
"obscurity but after the cult discovered\n"
"the \3023\354\341\343\353\240\307\341\364\345 in the caves below\n"
"the empire took notice.\n"
"A batallion of Imperial Knights were\n"
"sent to the gate to destroy the cult\n"
"and claim the artifact for the King.",
};
#define num_string_tests (sizeof (test_strings) / sizeof (test_strings[0]))
static int
test_string_io (const char *str)
{
plitem_t *item;
const char *res;
char *saved;
item = PL_NewString (str);
saved = PL_WritePropertyList (item);
PL_Free (item);
item = PL_GetPropertyList (saved);
res = PL_String (item);
if (!strcmp (str, res))
return 1;
printf ("expect: %s\n", str);
printf ("got : %s\n", res);
printf ("saved : %s\n", saved);
return 0;
}
int
main (int argc, const char **argv)
{
int res = 0;
size_t i;
for (i = 0; i < num_string_tests; i ++) {
if (!test_string_io (test_strings[i]))
res = 1;
}
return res;
}