Commit 7f35fd8c authored by Lev Walkin's avatar Lev Walkin

more PER tests

parent bbc78f68
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#define EMIT_ASN_DEBUG 1
#include <per_support.c>
#include <per_support.h> #include <per_support.h>
static void static void
...@@ -69,6 +71,58 @@ check_per_decoding() { ...@@ -69,6 +71,58 @@ check_per_decoding() {
z = per_get_few_bits(&pos, 24); z = per_get_few_bits(&pos, 24);
assert(z == 14443711); assert(z == 14443711);
pos.buffer = "\001";
pos.nboff = 7;
pos.nbits = 7;
z = per_get_few_bits(&pos, 1);
assert(pos.nboff == 7);
assert(pos.nbits == 7);
assert(z == -1);
pos.buffer = "\001";
pos.nboff = 7;
pos.nbits = 8;
z = per_get_few_bits(&pos, 1);
assert(pos.nboff == 8);
assert(pos.nbits == 8);
assert(z == 1);
pos.buffer = "\000";
pos.nboff = 7;
pos.nbits = 8;
z = per_get_few_bits(&pos, 1);
assert(pos.nboff == 8);
assert(pos.nbits == 8);
assert(z == 0);
z = per_get_few_bits(&pos, 1);
assert(pos.nboff == 8);
assert(pos.nbits == 8);
assert(z == -1);
pos.buffer = "\000";
pos.nboff = 7;
pos.nbits = 9;
z = per_get_few_bits(&pos, 1);
assert(pos.nboff == 8);
assert(pos.nbits == 9);
assert(z == 0);
z = per_get_few_bits(&pos, 1);
assert(pos.nboff == 1);
assert(pos.nbits == 1);
assert(z == 0);
pos.buffer = "\001";
pos.nboff = 7;
pos.nbits = 9;
z = per_get_few_bits(&pos, 1);
assert(pos.nboff == 8);
assert(pos.nbits == 9);
assert(z == 1);
z = per_get_few_bits(&pos, 1);
assert(pos.nboff == 1);
assert(pos.nbits == 1);
assert(z == 0);
/* Get full 31-bit range */ /* Get full 31-bit range */
pos.buffer = buf; pos.buffer = buf;
pos.nboff = 7; pos.nboff = 7;
......
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