2013-01-08 07:32:57 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2024-10-18 17:19:01 +00:00
|
|
|
#include <stdlib.h>
|
2013-01-08 07:32:57 +00:00
|
|
|
#include <string.h>
|
2021-03-21 07:13:03 +00:00
|
|
|
#include "QF/plist.h"
|
2024-10-18 17:19:01 +00:00
|
|
|
#include "QF/quakeio.h"
|
|
|
|
#include "QF/sys.h"
|
2013-01-08 07:32:57 +00:00
|
|
|
|
|
|
|
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"
|
2020-02-17 03:58:23 +00:00
|
|
|
"the \302\354\341\343\353\240\307\341\364\345 in the caves below\n"
|
2013-01-08 07:32:57 +00:00
|
|
|
"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);
|
2023-03-12 06:17:28 +00:00
|
|
|
PL_Release (item);
|
2021-03-02 06:05:19 +00:00
|
|
|
item = PL_GetPropertyList (saved, 0);
|
2013-01-08 07:32:57 +00:00
|
|
|
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;
|
|
|
|
|
2024-10-18 17:19:01 +00:00
|
|
|
if (argc > 1) {
|
|
|
|
int64_t start = Sys_LongTime ();
|
|
|
|
QFile *file = Qopen (argv[1], "rbz");
|
|
|
|
size_t len = Qfilesize (file);
|
|
|
|
char *buf = malloc (len + 1);
|
|
|
|
char *txt = buf;
|
|
|
|
if (argc > 2) {
|
|
|
|
txt += atoi (argv[2]);
|
|
|
|
}
|
|
|
|
Qread (file, buf, len);
|
|
|
|
buf[len] = 0;
|
|
|
|
int64_t read = Sys_LongTime ();
|
|
|
|
plitem_t *item = PL_GetPropertyList (txt, nullptr);
|
|
|
|
printf ("%p %d\n", item, PL_Type (item));
|
|
|
|
free (buf);
|
|
|
|
int64_t parse = Sys_LongTime ();
|
|
|
|
PL_Release (item);
|
|
|
|
int64_t end = Sys_LongTime ();
|
|
|
|
printf ("total:%g read:%g parse:%g free:%g\n",
|
|
|
|
(end - start) / 1000.0,
|
|
|
|
(read - start) / 1000.0,
|
|
|
|
(parse - read) / 1000.0,
|
|
|
|
(end - parse) / 1000.0);
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < num_string_tests; i ++) {
|
|
|
|
if (!test_string_io (test_strings[i]))
|
|
|
|
res = 1;
|
|
|
|
}
|
2013-01-08 07:32:57 +00:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|