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

employ XER equivalence check

parent 2d747bdd
...@@ -14,17 +14,17 @@ ...@@ -14,17 +14,17 @@
int main() { int main() {
uint8_t tmpbuf[128]; uint8_t tmpbuf[128];
T_t empty_t; T_t source;
T_t *decoded_t = 0; /* "= 0" is important */ T_t *decoded = 0; /* "= 0" is important */
memset(&empty_t, 0, sizeof(empty_t)); memset(&source, 0, sizeof(source));
asn_enc_rval_t er = asn_enc_rval_t er =
oer_encode_to_buffer(&asn_DEF_T, 0, &empty_t, tmpbuf, sizeof(tmpbuf)); oer_encode_to_buffer(&asn_DEF_T, 0, &source, tmpbuf, sizeof(tmpbuf));
assert(er.encoded != -1); assert(er.encoded != -1);
asn_dec_rval_t dr = asn_dec_rval_t dr =
oer_decode(0, &asn_DEF_T, (void **)&decoded_t, tmpbuf, er.encoded); oer_decode(0, &asn_DEF_T, (void **)&decoded, tmpbuf, er.encoded);
assert(dr.code == RC_OK); assert(dr.code == RC_OK);
if(dr.consumed != er.encoded) { if(dr.consumed != er.encoded) {
...@@ -32,10 +32,9 @@ int main() { ...@@ -32,10 +32,9 @@ int main() {
assert(dr.consumed == er.encoded); assert(dr.consumed == er.encoded);
} }
fprintf(stderr, "Original:\n"); if(XEQ_SUCCESS != xer_equivalent(&asn_DEF_T, &source, decoded, stderr)) {
xer_fprint(stderr, &asn_DEF_T, &empty_t); return 1;
fprintf(stderr, "Decoded:\n"); }
xer_fprint(stderr, &asn_DEF_T, decoded_t);
return 0; return 0;
} }
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
int main() { int main() {
uint8_t tmpbuf[128]; uint8_t tmpbuf[128];
T_t source; T_t source;
T_t *decoded = 0; /* "= 0" is important */ T_t *decoded = 0; /* "= 0" is important */
memset(&source, 0, sizeof(source)); memset(&source, 0, sizeof(source));
...@@ -42,10 +42,9 @@ int main() { ...@@ -42,10 +42,9 @@ int main() {
assert(dr.consumed == er.encoded); assert(dr.consumed == er.encoded);
} }
fprintf(stderr, "Original:\n"); if(XEQ_SUCCESS != xer_equivalent(&asn_DEF_T, &source, decoded, stderr)) {
xer_fprint(stderr, &asn_DEF_T, &source); return 1;
fprintf(stderr, "Decoded:\n"); }
xer_fprint(stderr, &asn_DEF_T, decoded);
return 0; return 0;
} }
......
...@@ -14,20 +14,20 @@ ...@@ -14,20 +14,20 @@
int main() { int main() {
uint8_t tmpbuf[128]; uint8_t tmpbuf[128];
T_t empty_t; T_t source;
T_t *decoded_t = 0; /* "= 0" is important */ T_t *decoded = 0; /* "= 0" is important */
memset(&empty_t, 0, sizeof(empty_t)); memset(&source, 0, sizeof(source));
/* Fill in complex INTEGER */ /* Fill in complex INTEGER */
asn_long2INTEGER(&empty_t.unsigned33, 0); asn_long2INTEGER(&source.unsigned33, 0);
asn_enc_rval_t er = asn_enc_rval_t er =
oer_encode_to_buffer(&asn_DEF_T, 0, &empty_t, tmpbuf, sizeof(tmpbuf)); oer_encode_to_buffer(&asn_DEF_T, 0, &source, tmpbuf, sizeof(tmpbuf));
assert(er.encoded != -1); assert(er.encoded != -1);
asn_dec_rval_t dr = asn_dec_rval_t dr =
oer_decode(0, &asn_DEF_T, (void **)&decoded_t, tmpbuf, er.encoded); oer_decode(0, &asn_DEF_T, (void **)&decoded, tmpbuf, er.encoded);
assert(dr.code == RC_OK); assert(dr.code == RC_OK);
if(dr.consumed != er.encoded) { if(dr.consumed != er.encoded) {
...@@ -35,10 +35,9 @@ int main() { ...@@ -35,10 +35,9 @@ int main() {
assert(dr.consumed == er.encoded); assert(dr.consumed == er.encoded);
} }
fprintf(stderr, "Original:\n"); if(XEQ_SUCCESS != xer_equivalent(&asn_DEF_T, &source, decoded, stderr)) {
xer_fprint(stderr, &asn_DEF_T, &empty_t); return 1;
fprintf(stderr, "Decoded:\n"); }
xer_fprint(stderr, &asn_DEF_T, decoded_t);
return 0; return 0;
} }
......
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