aboutsummaryrefslogtreecommitdiffstats
path: root/asn1c/tests
diff options
context:
space:
mode:
authorLev Walkin <vlm@lionet.info>2007-11-06 02:35:13 +0000
committerLev Walkin <vlm@lionet.info>2007-11-06 02:35:13 +0000
commita105cbc3681329ae4fe916a2f7d8b7b0006275f0 (patch)
treea3ecf5486daead40ca9b7815b9cc77a0069846b8 /asn1c/tests
parent63b4126c098ac7bbd0f1a4bb90866179fa1bf21a (diff)
32-bit integer decode/encode in per
Diffstat (limited to 'asn1c/tests')
-rw-r--r--asn1c/tests/check-127.-fnative-types.-gen-PER.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/asn1c/tests/check-127.-fnative-types.-gen-PER.c b/asn1c/tests/check-127.-fnative-types.-gen-PER.c
new file mode 100644
index 00000000..9cca644b
--- /dev/null
+++ b/asn1c/tests/check-127.-fnative-types.-gen-PER.c
@@ -0,0 +1,69 @@
+#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>
+
+void
+verify(T_t *ti) {
+ asn_enc_rval_t er;
+ asn_dec_rval_t rv;
+ unsigned char buf[8];
+ T_t *to = 0;
+
+ fprintf(stderr, "IN: { %ld, %ld }\n",
+ ti->small32range, ti->full32range);
+
+ er = uper_encode_to_buffer(&asn_DEF_T, ti, buf, sizeof buf);
+ assert(er.encoded == 64);
+
+ rv = uper_decode(0, &asn_DEF_T, (void *)&to, buf, sizeof buf, 0, 0);
+ assert(rv.code == RC_OK);
+
+ fprintf(stderr, "ENC: %2x%2x%2x%2x %2x%2x%2x%2x\n",
+ buf[0], buf[1], buf[2], buf[3],
+ buf[4], buf[5], buf[6], buf[7]);
+ fprintf(stderr, "OUT: { %ld, %ld } vs { %ld, %ld }\n",
+ ti->small32range, ti->full32range,
+ to->small32range, to->full32range);
+ assert(ti->small32range == to->small32range);
+ assert(ti->full32range == to->full32range);
+
+ xer_fprint(stderr, &asn_DEF_T, ti);
+ xer_fprint(stderr, &asn_DEF_T, to);
+}
+
+int main() {
+ T_t ti;
+
+ ti.small32range = 0;
+ ti.full32range = 0;
+ verify(&ti);
+
+ ti.small32range = -1;
+ ti.full32range = -1;
+ verify(&ti);
+
+ ti.small32range = -2000000000;
+ ti.full32range = (-2147483647L - 1);
+ verify(&ti);
+
+ ti.small32range = -1999999999;
+ ti.full32range = (-2147483647L);
+ verify(&ti);
+
+ ti.small32range = 2000000000;
+ ti.full32range = 2147483647;
+ verify(&ti);
+
+ ti.small32range = 1999999999;
+ ti.full32range = 2147483647 - 1;
+ verify(&ti);
+
+ return 0;
+}