From 83a1f5bc0032d1a4ee52781bf6813b09df72fd5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Tue, 5 Sep 2006 14:15:53 +0000 Subject: [PATCH] Add sequence tests. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18014 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/asn1/check-gen.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/lib/asn1/check-gen.c b/lib/asn1/check-gen.c index 814ca0733..32f404977 100644 --- a/lib/asn1/check-gen.c +++ b/lib/asn1/check-gen.c @@ -770,6 +770,51 @@ check_fail_choice(void) (generic_decode)decode_TESTChoice1); } +static int +check_seq(void) +{ + TESTSeqOf seq; + TESTInteger i; + int ret; + + seq.val = NULL; + seq.len = 0; + + ret = add_TESTSeqOf(&seq, &i); + if (ret) { printf("failed adding\n"); goto out; } + ret = add_TESTSeqOf(&seq, &i); + if (ret) { printf("failed adding\n"); goto out; } + ret = add_TESTSeqOf(&seq, &i); + if (ret) { printf("failed adding\n"); goto out; } + ret = add_TESTSeqOf(&seq, &i); + if (ret) { printf("failed adding\n"); goto out; } + + ret = remove_TESTSeqOf(&seq, seq.len - 1); + if (ret) { printf("failed removing\n"); goto out; } + ret = remove_TESTSeqOf(&seq, 2); + if (ret) { printf("failed removing\n"); goto out; } + ret = remove_TESTSeqOf(&seq, 0); + if (ret) { printf("failed removing\n"); goto out; } + ret = remove_TESTSeqOf(&seq, 0); + if (ret) { printf("failed removing\n"); goto out; } + ret = remove_TESTSeqOf(&seq, 0); + if (ret == 0) { + printf("can remove from empty list"); + return 1; + } + + if (seq.len != 0) { + printf("seq not empty!"); + return 1; + } + ret = 0; + +out: + + return ret; +} + + int main(int argc, char **argv) { @@ -792,5 +837,7 @@ main(int argc, char **argv) ret += check_fail_sequence(); ret += check_fail_choice(); + ret += check_seq(); + return ret; }