diff options
author | 2019-05-12 20:55:09 +0000 | |
---|---|---|
committer | 2019-05-12 20:55:09 +0000 | |
commit | ce5d4185eabdf030e01d03de9284c6e4db24a0a0 (patch) | |
tree | 3e7ab0679c85f4c01e506448ad0161d49e63d8bd | |
parent | Move us from old ftp(1) to Sunil's new ftp(1). The necessary modifications (diff) | |
download | wireguard-openbsd-ce5d4185eabdf030e01d03de9284c6e4db24a0a0.tar.xz wireguard-openbsd-ce5d4185eabdf030e01d03de9284c6e4db24a0a0.zip |
Add test cases for enum, and an additional test for null.
-rw-r--r-- | regress/lib/libutil/ber/ber_test.c | 48 |
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 |