Commit 54f34516 authored by Lev Walkin's avatar Lev Walkin

add failed test for INTEGER decode OER

parent 4558ad06
...@@ -5,11 +5,41 @@ ...@@ -5,11 +5,41 @@
#include <INTEGER.c> #include <INTEGER.c>
#include <INTEGER_oer.c> #include <INTEGER_oer.c>
#define CHECK_DECODE_OK(a, b, c) check_decode_ok(__LINE__, a, b, c)
void void
check_decode_ok(intmax_t control, uint8_t *buf, size_t size) { check_decode_ok(int lineno, intmax_t control, char *buf, size_t size) {
INTEGER_t *st = NULL;
asn_dec_rval_t ret;
ret = asn_DEF_INTEGER.oer_decoder(0, &asn_DEF_INTEGER, 0, (void **)&st, buf, size);
if(ret.code != RC_OK) {
/* Basic OER decode does not work */
fprintf(stderr, "%d: Failed oer_decode(ctl=%" PRIdMAX ", size=%zu)\n",
lineno, control, size);
assert(ret.code == RC_OK);
} else {
intmax_t outcome;
if(asn_INTEGER2imax(st, &outcome) != 0) {
/* Result of decode is structurally incorrect */
fprintf(stderr, "%d: Failed to convert INTEGER 2 imax\n",
lineno);
assert(!"Unreachable");
} else if(outcome != control) {
/* Decoded value is wrong */
fprintf(stderr,
"%d: Decode result %" PRIdMAX " is not expected %" PRIdMAX
"\n",
lineno, outcome, control);
assert(outcome == control);
}
}
fprintf(stderr, "%d: Decode result %" PRIdMAX "\n", lineno, control);
} }
int int
main() { main() {
check_decode_ok(0, "", 1); CHECK_DECODE_OK(0, "", 1);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment