summaryrefslogtreecommitdiff
path: root/src/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test.c')
-rw-r--r--src/test.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/src/test.c b/src/test.c
index 249eb87..f9ab43b 100644
--- a/src/test.c
+++ b/src/test.c
@@ -25,13 +25,13 @@ main(int argc, char **argv)
"\n"
"item =/ header [ note ] *1( price )\n"
"\n"
-"header = *1star \"SP\" title %xA *( \"SP\" / %xA )\n"
+"header = star \"SP\" title %xA *( \"SP\" / %xA )\n"
"\n"
"title = 1*\"TEXT\"\n"
"\n"
"star = %x2A\n"
"\n"
-"note = \"note:\" note-content %xA *( \"SP\" / %xA )\n"
+"note = \"note:\" \"SP\" note-content %xA *( \"SP\" / %xA )\n"
"\n"
"note-content = 1*\"TEXT\"\n"
"\n"
@@ -58,7 +58,31 @@ main(int argc, char **argv)
return 1;
}
- unsigned char *input = malloc (sizeof(unsigned char) * 10 * 8);
+ /* int input_unenc[] = { 3, 0, 2, 1, 5, 0, 6, 1 }; */
+
+ /* int input_unenc[] = { 3, 0, 2, 2, 2, 2, 1, 5, 0,
+ * 6, 6, 6, 1, 3, 0, 2, 2, 2,
+ * 2, 1, 5, 0, 6, 6, 6, 1, 3,
+ * 0, 2, 2, 2, 2, 1, 5, 0, 6,
+ * 6, 6, 1, 4, 2, 2, 2, 2, 2,
+ * 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ * 2, 2, 1 }; */
+
+ int input_unenc[] = { 3, 0, 2, 1,
+ 5, 0, 6, 1,
+ 3, 0, 2, 1,
+ 5, 0, 6, 1,
+ 3, 0, 2, 1,
+ 5, 0, 6, 1,
+ 4, 0, 2, 1 };
+
+ int input_unenc_len = (int) (sizeof (input_unenc) /
+ sizeof(input_unenc[0]));
+
+ printf("input length = %d\n", input_unenc_len);
+
+ unsigned char *input = malloc (sizeof(unsigned char) *
+ input_unenc_len * 8);
if (input == NULL) {
clean_parser(parser);
@@ -67,14 +91,14 @@ main(int argc, char **argv)
return EXIT_FAILURE;
}
-
- int input_unenc[10] = { 3, 0, 2, 2, 2, 1, 5, 0, 6, 1 };
-
- for (int i = 0; i < 10; i++)
+
+ for (int i = 0; i < input_unenc_len; i++)
to_big_endian(input_unenc[i], input + (8 * i));
unsigned char input_len[8] = { 0 };
- input_len[7] = 8*10;
+ /* input_len[7] = 8*10; */
+
+ to_big_endian((uint64_t) (8 * input_unenc_len), input_len);
struct UnsignedVec input_vec =
(struct UnsignedVec) { input_len, NULL, input };