summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrob <rob@cvs.openbsd.org>2019-05-12 20:55:10 +0000
committerrob <rob@cvs.openbsd.org>2019-05-12 20:55:10 +0000
commit50182cab81f5ddf31d747927be6fe6f15ce2452c (patch)
tree21a280377a75d13510f0a2e2074477c13b41c5c8
parent1eaa8b73d1f244e688efd51a87194d3908391b45 (diff)
Add test cases for enum, and an additional test for null.
-rw-r--r--regress/lib/libutil/ber/ber_test.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/regress/lib/libutil/ber/ber_test.c b/regress/lib/libutil/ber/ber_test.c
index 4513498ab68..880aa62cef6 100644
--- a/regress/lib/libutil/ber/ber_test.c
+++ b/regress/lib/libutil/ber/ber_test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ber_test.c,v 1.12 2019/05/12 20:19:37 rob Exp $
+/* $OpenBSD: ber_test.c,v 1.13 2019/05/12 20:55:09 rob Exp $
*/
/*
* Copyright (c) Rob Pierce <rob@openbsd.org>
@@ -65,6 +65,24 @@ struct test_vector test_vectors[] = {
{
SUCCEED,
1,
+ "enum",
+ 3,
+ {
+ 0x0a, 0x01, 0x00
+ },
+ },
+ {
+ FAIL,
+ 0,
+ "enum (constructed - expected failure)",
+ 3,
+ {
+ 0x2a, 0x01, 0x00
+ },
+ },
+ {
+ SUCCEED,
+ 1,
"integer (zero)",
3,
{
@@ -72,6 +90,15 @@ struct test_vector test_vectors[] = {
},
},
{
+ FAIL,
+ 0,
+ "integer (constructed - expected failure)",
+ 3,
+ {
+ 0x22, 0x01, 0x01
+ },
+ },
+ {
SUCCEED,
1,
"positive integer",
@@ -136,6 +163,15 @@ struct test_vector test_vectors[] = {
},
},
{
+ FAIL,
+ 0,
+ "null (constructed - expected failure)",
+ 2,
+ {
+ 0x25, 0x00
+ },
+ },
+ {
SUCCEED,
1,
"object identifier",
@@ -351,6 +387,16 @@ test(int i)
return 1;
}
break;
+ case BER_TYPE_ENUMERATED:
+ if (ber_get_enumerated(elm, &val) == -1) {
+ printf("failed (enum) encoding check\n");
+ return 1;
+ }
+ if (ber_scanf_elements(elm, "E", &val) == -1) {
+ printf("failed (enum) ber_scanf_elements (E)\n");
+ return 1;
+ }
+ break;
/*
* the current ber.c does not support bit strings
* however, simply processing a bit string as an octet string seems