2 * Copyright (C) 2004 by Volker Lendecke
4 * Test harness for asn1_write_*, inspired by Love Hornquist Astrand
9 static DATA_BLOB tests[] = {
10 {"\x02\x01\x00", 3, NULL},
11 {"\x02\x01\x7f", 3, NULL},
12 {"\x02\x02\x00\x80", 4, NULL},
13 {"\x02\x02\x01\x00", 4, NULL},
14 {"\x02\x01\x80", 3, NULL},
15 {"\x02\x02\xff\x7f", 4, NULL},
16 {"\x02\x01\xff", 3, NULL},
17 {"\x02\x02\xff\x01", 4, NULL},
18 {"\x02\x02\x00\xff", 4, NULL},
19 {"\x02\x04\x80\x00\x00\x00", 6, NULL},
20 {"\x02\x04\x7f\xff\xff\xff", 6, NULL},
24 static int values[] = {0, 127, 128, 256, -128, -129, -1, -255, 255,
25 0x80000000, 0x7fffffff};
33 for (i=0; tests[i].data != NULL; i++) {
37 data = asn1_init(talloc_tos());
42 asn1_write_Integer(data, values[i]);
44 if ((data->length != tests[i].length) ||
45 (memcmp(data>data, tests[i].data, data->length) != 0)) {
46 printf("Test for %d failed\n", values[i]);
50 blob.data = data->data;
51 blob.length = data->length;
52 asn1_load(data, blob);
53 if (!asn1_read_Integer(data, &val)) {
54 printf("Could not read our own Integer for %d\n",
58 if (val != values[i]) {
59 printf("%d -> ASN -> Int %d\n", values[i], val);