Commit 2b127d43 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Polish this to bring it closer to style(9) and how the

rest of our test-programs are structured.
parent cccb533f
......@@ -59,4 +59,5 @@ vjsn_test_CFLAGS = -DVJSN_TEST @SAN_CFLAGS@
vjsn_test_LDADD = libvarnish.a @SAN_LDFLAGS@
vsb_test_SOURCES = vsb_test.c vsb.c vas.c
vsb_test_CFLAGS = -DVSB_TEST
vsb_test_LDADD = libvarnish.a
#ifdef VSB_TEST
#include <stdio.h>
#include <string.h>
......@@ -11,16 +14,34 @@ struct tc {
const char *out;
};
struct tc tcs[] = {
{ VSB_QUOTE_GLOB, "abcdefghijklmnopqrstvwxyz", "abcdefghijklmnopqrstvwxyz" },
{ VSB_QUOTE_GLOB, "ABCDEFGHIJKLMNOPQRSTVWXYZ", "ABCDEFGHIJKLMNOPQRSTVWXYZ" },
{ VSB_QUOTE_GLOB, "01234567789", "01234567789"},
{ VSB_QUOTE_GLOB, "abcde[f-g]{h,i,j}\\l?*xyz", "abcde\\[f-g\\]\\{h,i,j\\}\\\\l\\?\\*xyz"},
{ VSB_QUOTE_GLOB, "0123\t \"\r\v\n'", "0123\\\\t \\\"\\\\r\\\\v\\\\n'"},
{0, NULL, NULL}
static struct tc tcs[] = {
{
VSB_QUOTE_GLOB,
"abcdefghijklmnopqrstvwxyz",
"abcdefghijklmnopqrstvwxyz"
}, {
VSB_QUOTE_GLOB,
"ABCDEFGHIJKLMNOPQRSTVWXYZ",
"ABCDEFGHIJKLMNOPQRSTVWXYZ"
}, {
VSB_QUOTE_GLOB,
"01234567789",
"01234567789"
}, {
VSB_QUOTE_GLOB,
"abcde[f-g]{h,i,j}\\l?*xyz",
"abcde\\[f-g\\]\\{h,i,j\\}\\\\l\\?\\*xyz"
}, {
VSB_QUOTE_GLOB,
"0123\t \"\r\v\n'",
"0123\\\\t \\\"\\\\r\\\\v\\\\n'"
}, {
0, NULL, NULL
}
};
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
int err = 0;
struct tc *tc;
......@@ -33,7 +54,7 @@ int main(int argc, char *argv[])
for (tc = tcs; tc->in; tc++) {
VSB_quote(vsb, tc->in, -1, tc->how);
VSB_finish(vsb);
assert(VSB_finish(vsb) == 0);
printf("%s -> %s", tc->in, VSB_data(vsb));
if (strcmp(VSB_data(vsb), tc->out)) {
......@@ -47,3 +68,5 @@ int main(int argc, char *argv[])
printf("error is %i\n", err);
return (err);
}
#endif /* VSB_TEST */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment