Add 64-bit integer support to ASN.1 compiler
ASN.1 INTEGERs will now compile to C int64_t or uint64_t, depending on whether the constraint ranges include numbers that cannot be represented in 32-bit ints and whether they include negative numbers. Template backend support included. check-template is now built with --template, so we know we're testing it. Tests included.
This commit is contained in:

committed by
Nicolas Williams

parent
0e7437ba2e
commit
19d378f44d
@@ -53,6 +53,38 @@ cmp_dummy (void *a, void *b)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
test_uint64(void)
|
||||
{
|
||||
struct test_case tests[] = {
|
||||
{ NULL, 3, "\x02\x01\x00", "uint64 0" },
|
||||
{ NULL, 7, "\x02\x05\x01\xff\xff\xff\xff", "uint64 0" },
|
||||
{ NULL, 7, "\x02\x05\x02\x00\x00\x00\x00", "uint64 0" },
|
||||
{ NULL, 9, "\x02\x07\x7f\xff\xff\xff\xff\xff\xff", "uint64 0" },
|
||||
{ NULL, 10, "\x02\x08\x00\x80\x00\x00\x00\x00\x00\x00", "uint64 0" },
|
||||
{ NULL, 10, "\x02\x08\x7f\xff\xff\xff\xff\xff\xff\xff", "uint64 0" },
|
||||
{ NULL, 11, "\x02\x09\x00\xff\xff\xff\xff\xff\xff\xff\xff", "uint64 0" }
|
||||
};
|
||||
|
||||
size_t i;
|
||||
int ret = 0, ntests = sizeof(tests) / sizeof(*tests);
|
||||
TESTuint64 values[] = { 0, 8589934591LL, 8589934592LL,
|
||||
36028797018963967LL, 36028797018963968LL,
|
||||
9223372036854775807LL, 18446744073709551615ULL };
|
||||
|
||||
for (i = 0; i < ntests; i++)
|
||||
tests[i].val = &values[i];
|
||||
|
||||
ret += generic_test (tests, ntests, sizeof(TESTuint64),
|
||||
(generic_encode)encode_TESTuint64,
|
||||
(generic_length)length_TESTuint64,
|
||||
(generic_decode)decode_TESTuint64,
|
||||
(generic_free)free_TESTuint64,
|
||||
cmp_dummy,
|
||||
NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
test_seqofseq(void)
|
||||
{
|
||||
@@ -246,6 +278,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret += test_uint64();
|
||||
ret += test_seqofseq();
|
||||
ret += test_seqofseq2();
|
||||
ret += test_seqof2();
|
||||
|
Reference in New Issue
Block a user