Commit 6db40f4c authored by Lev Walkin's avatar Lev Walkin

check OER in 32-bit and 64-bit modes

parent 8b6a8005
...@@ -27,6 +27,7 @@ TESTS += check-src/check-127.-gen-PER.c ...@@ -27,6 +27,7 @@ TESTS += check-src/check-127.-gen-PER.c
TESTS += check-src/check-131.-gen-PER.c TESTS += check-src/check-131.-gen-PER.c
TESTS += check-src/check-132.-gen-PER.c TESTS += check-src/check-132.-gen-PER.c
TESTS += check-src/check-133.-gen-PER.c TESTS += check-src/check-133.-gen-PER.c
TESTS += check-src/check-135.-gen-OER.c
TESTS += check-src/check-19.c TESTS += check-src/check-19.c
TESTS += check-src/check-22.-fwide-types.c TESTS += check-src/check-22.-fwide-types.c
TESTS += check-src/check-24.-fwide-types.c TESTS += check-src/check-24.-fwide-types.c
...@@ -58,7 +59,7 @@ TESTS += check-src/check-92.c ...@@ -58,7 +59,7 @@ TESTS += check-src/check-92.c
if TEST_64BIT if TEST_64BIT
TESTS += check-src/check64-134.-gen-PER.c TESTS += check-src/check64-134.-gen-PER.c
TESTS += check-src/check64-135.-gen-OER.c TESTS += check-src/check64-136.-gen-OER.c
endif endif
EXTRA_DIST = \ EXTRA_DIST = \
......
/*
* Verify OER with constrained INTEGER code gen.
*/
#undef NDEBUG
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <T.h>
int main() {
uint8_t tmpbuf[128];
T_t empty_t;
T_t *decoded_t = 0; /* "= 0" is important */
memset(&empty_t, 0, sizeof(empty_t));
/* Fill in complex INTEGER */
asn_long2INTEGER(&empty_t.unsigned33, 0);
asn_enc_rval_t er =
oer_encode_to_buffer(&asn_DEF_T, 0, &empty_t, tmpbuf, sizeof(tmpbuf));
assert(er.encoded != -1);
asn_dec_rval_t dr =
oer_decode(0, &asn_DEF_T, (void **)&decoded_t, tmpbuf, er.encoded);
assert(dr.code == RC_OK);
if(dr.consumed != er.encoded) {
ASN_DEBUG("Consumed %zu, expected %zu", dr.consumed, er.encoded);
assert(dr.consumed == er.encoded);
}
fprintf(stderr, "Original:\n");
xer_fprint(stderr, &asn_DEF_T, &empty_t);
fprintf(stderr, "Decoded:\n");
xer_fprint(stderr, &asn_DEF_T, decoded_t);
return 0;
}
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .135
ModuleOERShort
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 135 }
DEFINITIONS IMPLICIT TAGS ::=
BEGIN
-- Supported only on 64-bit platforms.
T ::= SEQUENCE {
unsigned8 [0] INTEGER (0..255), -- OER 1 byte
unsigned16 [1] INTEGER (0..65535), -- OER 2 bytes
unsigned16stack [2] INTEGER (0..32767)(0..255), -- OER 1 byte
unsigned16stack-ext [15] INTEGER (0..32767)(0..255,...), -- OER 2 bytes
...,
signed8 [10] INTEGER (-128..127) DEFAULT 3, -- OER 1 byte
signed16 [11] INTEGER (-32768..32767), -- OER 2 bytes
signed16stack [12] INTEGER (-32768..32767)(-128..127), -- OER 1 byte
signed16stack-ext [5] INTEGER (-32768..32767)(-128..127,...), -- OER 2 b
signed32 [7] INTEGER (-2000000000..2000000000), -- OER 4 bytes
...,
minmax [6] INTEGER (MIN..MAX) OPTIONAL
}
END
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .136
ModuleOERLong
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 136 }
DEFINITIONS IMPLICIT TAGS ::=
BEGIN
-- Supported only on 64-bit platforms.
T ::= SEQUENCE {
unsigned8 [0] INTEGER (0..255), -- OER 1 byte
unsigned16 [1] INTEGER (0..65535), -- OER 2 bytes
unsigned16stack [2] INTEGER (0..32767)(0..255), -- OER 1 byte
unsigned16stack-ext [15] INTEGER (0..32767)(0..255,...), -- OER 2 bytes
unsigned33 [3] INTEGER (0..5000000000), -- OER 8 bytes
...,
signed8 [10] INTEGER (-128..127) DEFAULT 3, -- OER 1 byte
signed16 [11] INTEGER (-32768..32767), -- OER 2 bytes
signed16stack [12] INTEGER (-32768..32767)(-128..127), -- OER 1 byte
signed16stack-ext [5] INTEGER (-32768..32767)(-128..127,...), -- OER 2 b
signed32 [7] INTEGER (-2000000000..2000000000), -- OER 4 bytes
signed33ext [8] INTEGER (-4000000000..4000000000,...),-- OER vrble
...,
minmax [6] INTEGER (MIN..MAX) OPTIONAL
}
END
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