Unverified Commit 70cd839e authored by Mouse's avatar Mouse Committed by GitHub

Merge pull request #149 from v0-e/jer-integer-fix

jer: INTEGER and ENUMERATED compliant decoding
parents 60f08896 7649fdbc
......@@ -35,7 +35,7 @@ asn_TYPE_operation_t asn_OP_ENUMERATED = {
0,
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
INTEGER_decode_jer,
ENUMERATED_decode_jer,
INTEGER_encode_jer,
#else
0,
......
......@@ -37,7 +37,7 @@ extern asn_TYPE_operation_t asn_OP_ENUMERATED;
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
#define ENUMERATED_decode_jer INTEGER_decode_jer
jer_type_decoder_f ENUMERATED_decode_jer;
#define ENUMERATED_encode_jer INTEGER_encode_jer
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
......
/*
* Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
* All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#include <asn_internal.h>
#include <ENUMERATED.h>
#include <INTEGER.h>
struct e2v_key {
const char *start;
const char *stop;
const asn_INTEGER_enum_map_t *vemap;
const unsigned int *evmap;
};
static int
ENUMERATED__jer_compar_enum2value(const void *kp, const void *am) {
const struct e2v_key *key = (const struct e2v_key *)kp;
const asn_INTEGER_enum_map_t *el = (const asn_INTEGER_enum_map_t *)am;
const char *ptr, *end, *name;
/* Remap the element (sort by different criterion) */
el = key->vemap + key->evmap[el - key->vemap];
/* Compare strings */
for(ptr = key->start, end = key->stop, name = el->enum_name;
ptr < end; ptr++, name++) {
if(*ptr != *name || !*name)
return *(const unsigned char *)ptr - *(const unsigned char *)name;
}
return name[0] ? -1 : 0;
}
static const asn_INTEGER_enum_map_t *
ENUMERATED_jer_map_enum2value(const asn_INTEGER_specifics_t *specs, const char *lstart,
const char *lstop) {
const asn_INTEGER_enum_map_t *el_found;
int count = specs ? specs->map_count : 0;
struct e2v_key key;
const char *lp;
if(!count) return NULL;
/* Guaranteed: assert(lstart < lstop); */
/* Figure out the tag name */
for(lstart++, lp = lstart; lp < lstop; lp++) {
switch(*lp) {
case 9: case 10: case 11: case 12: case 13: case 32: /* WSP */
case 0x22: /* '"' */
break;
default:
continue;
}
break;
}
if(lp == lstop) return NULL; /* No tag found */
lstop = lp;
key.start = lstart;
key.stop = lstop;
key.vemap = specs->value2enum;
key.evmap = specs->enum2value;
el_found = (asn_INTEGER_enum_map_t *)bsearch(&key,
specs->value2enum, count, sizeof(specs->value2enum[0]),
ENUMERATED__jer_compar_enum2value);
if(el_found) {
/* Remap enum2value into value2enum */
el_found = key.vemap + key.evmap[el_found - key.vemap];
}
return el_found;
}
static enum jer_pbd_rval
ENUMERATED__jer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
const void *chunk_buf, size_t chunk_size) {
INTEGER_t *st = (INTEGER_t *)sptr;
intmax_t dec_value;
const char *lp;
const char *lstart = (const char *)chunk_buf;
const char *lstop = lstart + chunk_size;
int decoded = 0;
for (lp = lstart; lp < lstop; ++lp) {
if (*lp == 0x22 /* '"' */) {
const asn_INTEGER_enum_map_t *el;
el = ENUMERATED_jer_map_enum2value(
(const asn_INTEGER_specifics_t *)
td->specifics, lstart, lstop);
if(el) {
ASN_DEBUG("Found \"%s\" => %ld",
el->enum_name, el->nat_value);
dec_value = el->nat_value;
decoded = 1;
lp = lstop - 1;
continue;
}
ASN_DEBUG("Unknown identifier for ENUMERATED");
} else {
continue;
}
}
if (!decoded) {
return JPBD_BROKEN_ENCODING;;
}
/*
* Convert the result of parsing of enumeration into a BER representation.
*/
if(asn_imax2INTEGER(st, dec_value)) {
ASN_DEBUG("ENUMERATED decode %s conversion failed", td->name);
return JPBD_SYSTEM_FAILURE;
}
return JPBD_BODY_CONSUMED;
}
asn_dec_rval_t
ENUMERATED_decode_jer(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td, void **sptr,
const char *opt_mname, const void *buf_ptr, size_t size) {
return jer_decode_primitive(opt_codec_ctx, td,
sptr, sizeof(INTEGER_t), opt_mname,
buf_ptr, size, ENUMERATED__jer_body_decode);
}
......@@ -17,63 +17,6 @@ struct je2v_key {
* Some static functions here are equivalent to XER's.
* Should be joined in the future.
*/
static int
INTEGER__jer_compar_enum2value(const void *kp, const void *am) {
const struct je2v_key *key = (const struct je2v_key *)kp;
const asn_INTEGER_enum_map_t *el = (const asn_INTEGER_enum_map_t *)am;
const char *ptr, *end, *name;
/* Remap the element (sort by different criterion) */
el = key->vemap + key->evmap[el - key->vemap];
/* Compare strings */
for(ptr = key->start, end = key->stop, name = el->enum_name;
ptr < end; ptr++, name++) {
if(*ptr != *name || !*name)
return *(const unsigned char *)ptr - *(const unsigned char *)name;
}
return name[0] ? -1 : 0;
}
static const asn_INTEGER_enum_map_t *
INTEGER_jer_map_enum2value(const asn_INTEGER_specifics_t *specs, const char *lstart,
const char *lstop) {
const asn_INTEGER_enum_map_t *el_found;
int count = specs ? specs->map_count : 0;
struct je2v_key key;
const char *lp;
if(!count) return NULL;
/* Guaranteed: assert(lstart < lstop); */
/* Figure out the tag name */
for(lstart++, lp = lstart; lp < lstop; lp++) {
switch(*lp) {
case 9: case 10: case 11: case 12: case 13: case 32: /* WSP */
case 0x22: /* '"' */
break;
default:
continue;
}
break;
}
if(lp == lstop) return NULL; /* No tag found */
lstop = lp;
key.start = lstart;
key.stop = lstop;
key.vemap = specs->value2enum;
key.evmap = specs->enum2value;
el_found = (asn_INTEGER_enum_map_t *)bsearch(&key,
specs->value2enum, count, sizeof(specs->value2enum[0]),
INTEGER__jer_compar_enum2value);
if(el_found) {
/* Remap enum2value into value2enum */
el_found = key.vemap + key.evmap[el_found - key.vemap];
}
return el_found;
}
static int
INTEGER_jer_st_prealloc(INTEGER_t *st, int min_size) {
void *p = MALLOC(min_size + 1);
......@@ -88,7 +31,7 @@ INTEGER_jer_st_prealloc(INTEGER_t *st, int min_size) {
}
}
/*
* Decode the chunk of XML text encoding INTEGER.
* Decode the chunk of JSON text encoding INTEGER.
*/
static enum jer_pbd_rval
INTEGER__jer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
......@@ -97,21 +40,15 @@ INTEGER__jer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
(const asn_INTEGER_specifics_t *)td->specifics;
INTEGER_t *st = (INTEGER_t *)sptr;
intmax_t dec_value;
intmax_t hex_value = 0;
const char *lp;
const char *lstart = (const char *)chunk_buf;
const char *lstop = lstart + chunk_size;
enum {
ST_LEADSPACE,
ST_SKIPSPHEX,
ST_WAITDIGITS,
ST_DIGITS,
ST_ZERO,
ST_DIGITS_TRAILSPACE,
ST_HEXDIGIT1,
ST_HEXDIGIT2,
ST_HEXDIGITS_TRAILSPACE,
ST_HEXCOLON,
ST_END_ENUM,
ST_UNEXPECTED
} state = ST_LEADSPACE;
const char *dec_value_start = 0; /* INVARIANT: always !0 in ST_DIGITS */
......@@ -135,16 +72,12 @@ INTEGER__jer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
switch(state) {
case ST_LEADSPACE:
case ST_DIGITS_TRAILSPACE:
case ST_HEXDIGITS_TRAILSPACE:
case ST_SKIPSPHEX:
continue;
case ST_DIGITS:
case ST_ZERO:
dec_value_end = lp;
state = ST_DIGITS_TRAILSPACE;
continue;
case ST_HEXCOLON:
state = ST_HEXDIGITS_TRAILSPACE;
continue;
default:
break;
}
......@@ -157,30 +90,26 @@ INTEGER__jer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
continue;
}
break;
case 0x2b: /* '+' */
if(state == ST_LEADSPACE) {
case 0x30: /* 0 */
switch(state) {
case ST_DIGITS: continue;
case ST_LEADSPACE:
case ST_WAITDIGITS:
dec_value = 0;
dec_value_start = lp;
state = ST_WAITDIGITS;
state = ST_ZERO;
continue;
case ST_ZERO: /* forbidden leading zero */
return JPBD_BROKEN_ENCODING;
default:
break;
}
break;
case 0x30: case 0x31: case 0x32: case 0x33: case 0x34:
/* [1-9] */
case 0x31: case 0x32: case 0x33: case 0x34:
case 0x35: case 0x36: case 0x37: case 0x38: case 0x39:
switch(state) {
case ST_DIGITS: continue;
case ST_SKIPSPHEX: /* Fall through */
case ST_HEXDIGIT1:
hex_value = (lv - 0x30) << 4;
state = ST_HEXDIGIT2;
continue;
case ST_HEXDIGIT2:
hex_value += (lv - 0x30);
state = ST_HEXCOLON;
st->buf[st->size++] = (uint8_t)hex_value;
continue;
case ST_HEXCOLON:
return JPBD_BROKEN_ENCODING;
case ST_LEADSPACE:
dec_value = 0;
dec_value_start = lp;
......@@ -188,70 +117,8 @@ INTEGER__jer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
case ST_WAITDIGITS:
state = ST_DIGITS;
continue;
default:
break;
}
break;
case 0x22: /* '<', start of XML encoded enumeration */
if(state == ST_LEADSPACE) {
const asn_INTEGER_enum_map_t *el;
el = INTEGER_jer_map_enum2value(
(const asn_INTEGER_specifics_t *)
td->specifics, lstart, lstop);
if(el) {
ASN_DEBUG("Found \"%s\" => %ld",
el->enum_name, el->nat_value);
dec_value = el->nat_value;
state = ST_END_ENUM;
lp = lstop - 1;
continue;
}
ASN_DEBUG("Unknown identifier for INTEGER");
}
return JPBD_BROKEN_ENCODING;
case 0x3a: /* ':' */
if(state == ST_HEXCOLON) {
/* This colon is expected */
state = ST_HEXDIGIT1;
continue;
} else if(state == ST_DIGITS) {
/* The colon here means that we have
* decoded the first two hexadecimal
* places as a decimal value.
* Switch decoding mode. */
ASN_DEBUG("INTEGER re-evaluate as hex form");
state = ST_SKIPSPHEX;
dec_value_start = 0;
lp = lstart - 1;
continue;
} else {
ASN_DEBUG("state %d at %ld", state, (long)(lp - lstart));
break;
}
/* [A-Fa-f] */
case 0x41:case 0x42:case 0x43:case 0x44:case 0x45:case 0x46:
case 0x61:case 0x62:case 0x63:case 0x64:case 0x65:case 0x66:
switch(state) {
case ST_SKIPSPHEX:
case ST_LEADSPACE: /* Fall through */
case ST_HEXDIGIT1:
hex_value = lv - ((lv < 0x61) ? 0x41 : 0x61);
hex_value += 10;
hex_value <<= 4;
state = ST_HEXDIGIT2;
continue;
case ST_HEXDIGIT2:
hex_value += lv - ((lv < 0x61) ? 0x41 : 0x61);
hex_value += 10;
st->buf[st->size++] = (uint8_t)hex_value;
state = ST_HEXCOLON;
continue;
case ST_DIGITS:
ASN_DEBUG("INTEGER re-evaluate as hex form");
state = ST_SKIPSPHEX;
dec_value_start = 0;
lp = lstart - 1;
continue;
case ST_ZERO: /* forbidden leading zero */
return JPBD_BROKEN_ENCODING;
default:
break;
}
......@@ -266,10 +133,8 @@ INTEGER__jer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
}
switch(state) {
case ST_END_ENUM:
/* Got a complete and valid enumeration encoded as a tag. */
break;
case ST_DIGITS:
case ST_ZERO:
dec_value_end = lstop;
/* FALL THROUGH */
case ST_DIGITS_TRAILSPACE:
......@@ -297,14 +162,6 @@ INTEGER__jer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
return JPBD_BROKEN_ENCODING;
}
break;
case ST_HEXCOLON:
case ST_HEXDIGITS_TRAILSPACE:
st->buf[st->size] = 0; /* Just in case termination */
return JPBD_BODY_CONSUMED;
case ST_HEXDIGIT1:
case ST_HEXDIGIT2:
case ST_SKIPSPHEX:
return JPBD_BROKEN_ENCODING;
case ST_LEADSPACE:
/* Content not found */
return JPBD_NOT_BODY_IGNORE;
......
......@@ -127,6 +127,7 @@ libasn1cskeletons_la_SOURCES = \
BOOLEAN_xer.c \
BOOLEAN_jer.c \
ENUMERATED_aper.c \
ENUMERATED_jer.c \
ENUMERATED_oer.c \
ENUMERATED_uper.c \
GeneralizedTime_ber.c \
......
......@@ -41,7 +41,7 @@ asn_TYPE_operation_t asn_OP_NativeEnumerated = {
0,
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
NativeInteger_decode_jer,
NativeEnumerated_decode_jer,
NativeEnumerated_encode_jer,
#else
0,
......
......@@ -13,6 +13,7 @@
#define _NativeEnumerated_H_
#include <NativeInteger.h>
#include <ENUMERATED.h>
#ifdef __cplusplus
extern "C" {
......@@ -42,7 +43,7 @@ xer_type_encoder_f NativeEnumerated_encode_xer;
#endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
#if !defined(ASN_DISABLE_JER_SUPPORT)
#define NativeEnumerated_decode_jer NativeInteger_decode_jer
jer_type_decoder_f NativeEnumerated_decode_jer;
jer_type_encoder_f NativeEnumerated_encode_jer;
#endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
......
......@@ -6,6 +6,51 @@
#include <asn_internal.h>
#include <NativeEnumerated.h>
/*
* Decode the chunk of JSON text encoding ENUMERATED.
*/
asn_dec_rval_t
NativeEnumerated_decode_jer(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td, void **sptr,
const char *opt_mname, const void *buf_ptr,
size_t size) {
const asn_INTEGER_specifics_t *specs =
(const asn_INTEGER_specifics_t *)td->specifics;
asn_dec_rval_t rval;
INTEGER_t st;
void *st_ptr = (void *)&st;
long *native = (long *)*sptr;
if(!native) {
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
if(!native) ASN__DECODE_FAILED;
}
memset(&st, 0, sizeof(st));
rval = ENUMERATED_decode_jer(opt_codec_ctx, td, &st_ptr,
opt_mname, buf_ptr, size);
if(rval.code == RC_OK) {
long l;
if((specs&&specs->field_unsigned)
? asn_INTEGER2ulong(&st, (unsigned long *)&l) /* sic */
: asn_INTEGER2long(&st, &l)) {
rval.code = RC_FAIL;
rval.consumed = 0;
} else {
*native = l;
}
} else {
/*
* Cannot restart from the middle;
* there is no place to save state in the native type.
* Request a continuation from the very beginning.
*/
rval.consumed = 0;
}
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &st);
return rval;
}
asn_enc_rval_t
NativeEnumerated_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
int ilevel, enum jer_encoder_flags_e flags,
......
......@@ -17,7 +17,7 @@ IA5String.h IA5String.c OCTET_STRING.h
INTEGER.h INTEGER.c
ISO646String.h ISO646String.c OCTET_STRING.h
NULL.h NULL.c
NativeEnumerated.h NativeEnumerated.c NativeInteger.h
NativeEnumerated.h NativeEnumerated.c NativeInteger.h ENUMERATED.h
NativeInteger.h NativeInteger.c INTEGER.h
NativeReal.h NativeReal.c REAL.h
NumericString.h NumericString.c OCTET_STRING.h
......@@ -253,6 +253,7 @@ ANY.h ANY_jer.c
BIT_STRING.h BIT_STRING_jer.c
BMPString.h BMPString_jer.c
BOOLEAN.h BOOLEAN_jer.c
ENUMERATED.h ENUMERATED_jer.c
GeneralizedTime.h GeneralizedTime_jer.c
INTEGER.h INTEGER_jer.c
NULL.h NULL_jer.c
......
......@@ -5,6 +5,7 @@
#include <INTEGER.h>
#define CHECK_XER(a,b,c) check_xer(__LINE__, a, b, c)
#define CHECK_JER(a,b,c) check_jer(__LINE__, a, b, c)
static char *shared_scratch_start;
......@@ -178,6 +179,39 @@ check_xer(int lineno, int tofail, char *xmldata, long orig_value) {
ASN_STRUCT_FREE(asn_DEF_INTEGER, st);
}
static void
check_jer(int lineno, int tofail, char *jsondata, long orig_value) {
INTEGER_t *st = 0;
asn_dec_rval_t rc;
long value;
int ret;
printf("%03d: [%s] vs %ld: ", lineno, jsondata, orig_value);
fflush(stdout);
rc = jer_decode(0, &asn_DEF_INTEGER, (void *)&st,
jsondata, strlen(jsondata));
if(rc.code != RC_OK) {
assert(tofail);
printf("\tfailed, as expected\n");
ASN_STRUCT_FREE(asn_DEF_INTEGER, st);
return;
}
if(tofail) {
printf("\tnot failed, as expected!\n");
assert(!tofail);
}
ret = asn_INTEGER2long(st, &value);
assert(ret == 0);
printf("\t%ld\n", value);
assert(value == orig_value);
ASN_STRUCT_FREE(asn_DEF_INTEGER, st);
}
static void
check_strtoimax() {
const intmax_t intmax_max = ((~(uintmax_t)0) >> 1);
......@@ -421,6 +455,91 @@ main() {
}
#endif
CHECK_JER(-1, "", 0);
CHECK_JER(-1, "{\"INTEGER\":}", 0);
CHECK_JER(-1, "{\"INTEGER\": }", 0);
CHECK_JER(-1, "{\"INTEGER\":-}", 0);
CHECK_JER(-1, "{\"INTEGER\":+}", 0);
CHECK_JER(-1, "{\"INTEGER\":+-}", 0);
CHECK_JER(-1, "{\"INTEGER\": -}", 0);
CHECK_JER(-1, "{\"INTEGER\": +}", 0);
CHECK_JER(-1, "{\"INTEGER\": +-}", 0);
CHECK_JER(-1, "{\"INTEGER\":- }", 0);
CHECK_JER(-1, "{\"INTEGER\":+ }", 0);
CHECK_JER(-1, "{\"INTEGER\":+- }", 0);
CHECK_JER(-1, "{\"INTEGER\": - }", 0);
CHECK_JER(-1, "{\"INTEGER\": + }", 0);
CHECK_JER(-1, "{\"INTEGER\": +- }", 0);
CHECK_JER(-1, "{\"INTEGER\":+0}", 0);
CHECK_JER(0, "{\"INTEGER\":-0}", 0);
CHECK_JER(-1, "{\"INTEGER\":+1}", 0);
CHECK_JER(0, "{\"INTEGER\":-1}", -1);
CHECK_JER(0, "{\"INTEGER\":1}", 1);
CHECK_JER(0, "{\"INTEGER\":-15}", -15);
CHECK_JER(-1, "{\"INTEGER\":+15}", 0);
CHECK_JER(0, "{\"INTEGER\":15}", 15);
CHECK_JER(0, "{\"INTEGER\": 15}", 15);
CHECK_JER(0, "{\"INTEGER\": 15 }", 15);
CHECK_JER(0, "{\"INTEGER\":15 }", 15);
CHECK_JER(-1, "{\"INTEGER\": +15 }", 0);
CHECK_JER(-1, "{\"INTEGER\": 015 }", 0);
CHECK_JER(-1, "{\"INTEGER\":015 }", 0);
CHECK_JER(-1, "{\"INTEGER\": 015}", 0);
CHECK_JER(-1, "{\"INTEGER\": 0 15}", 0);
CHECK_JER(-1, "{\"INTEGER\": 0 15 }", 0);
CHECK_JER(-1, "{\"INTEGER\":0 15}", 0);
CHECK_JER(-1, "{\"INTEGER\": +15 -}", 0);
CHECK_JER(-1, "{\"INTEGER\": +15 1}", 0);
CHECK_JER(-1, "{\"INTEGER\":+ 15}", 0);
CHECK_JER(-1, "{\"INTEGER\":12e34}", 0);
CHECK_JER(-1, "{\"INTEGER\":12 e34}", 0);
CHECK_JER(-1, "{\"INTEGER\":12 e}", 0);
CHECK_JER(0, "{\"INTEGER\":1234}", 1234);
CHECK_JER(-1, "{\"INTEGER\":1234 5678}", 0);
CHECK_JER(0, "{\"INTEGER\":-2147483647}", -2147483647);
CHECK_JER(0, "{\"INTEGER\":-2147483648}", -2147483647-1);
CHECK_JER(-1, "{\"INTEGER\":+2147483647}", 0);
CHECK_JER(0, "{\"INTEGER\":2147483647}", 2147483647);
if(sizeof(long) == 4) {
CHECK_JER( 0, "{\"INTEGER\":-2147483648}", -2147483648);
CHECK_JER(-1, "{\"INTEGER\":-2147483649}", 0);
CHECK_JER(-1, "{\"INTEGER\":2147483648}", 0);
CHECK_JER(-1, "{\"INTEGER\":2147483649}", 0);
CHECK_JER(-1, "{\"INTEGER\":3147483649}", 0);
CHECK_JER(-1, "{\"INTEGER\":4147483649}", 0);
CHECK_JER(-1, "{\"INTEGER\":5147483649}", 0); /* special */
CHECK_JER(-1, "{\"INTEGER\":9147483649}", 0);
CHECK_JER(-1, "{\"INTEGER\":9999999999}", 0);
CHECK_JER(-1, "{\"INTEGER\":-5147483649}", 0);/* special */
CHECK_JER(-1, "{\"INTEGER\":-9147483649}", 0);
CHECK_JER(-1, "{\"INTEGER\":-9999999999}", 0);
}
#ifdef TEST_64BIT
if(sizeof(long) == 8) {
CHECK_JER(0, "{\"INTEGER\":2147483648}", 2147483648);
CHECK_JER(0, "{\"INTEGER\":2147483649}", 2147483649);
CHECK_JER(0, "{\"INTEGER\":3147483649}", 3147483649);
CHECK_JER(0, "{\"INTEGER\":4147483649}", 4147483649);
CHECK_JER(0, "{\"INTEGER\":5147483649}", 5147483649);
CHECK_JER(0, "{\"INTEGER\":9147483649}", 9147483649);
CHECK_JER(0, "{\"INTEGER\":9999999999}", 9999999999);
CHECK_JER(0, "{\"INTEGER\":9223372036854775807}", 9223372036854775807);
CHECK_JER(-1, "{\"INTEGER\":9223372036854775808}", 0);
CHECK_JER(-1, "{\"INTEGER\":10223372036854775807}", 0);
CHECK_JER(-1, "{\"INTEGER\":50223372036854775807}", 0);
CHECK_JER(-1, "{\"INTEGER\":100223372036854775807}", 0);
CHECK_JER(-1, "{\"INTEGER\":500223372036854775807}", 0);
CHECK_JER(0, "{\"INTEGER\":-9223372036854775808}", -9223372036854775807-1);
CHECK_JER(-1, "{\"INTEGER\":-9223372036854775809}", 0);
CHECK_JER(-1, "{\"INTEGER\":-10223372036854775807}", 0);
CHECK_JER(-1, "{\"INTEGER\":-50223372036854775807}", 0);
CHECK_JER(-1, "{\"INTEGER\":-100223372036854775807}", 0);
CHECK_JER(-1, "{\"INTEGER\":-500223372036854775807}", 0);
} else {
assert(sizeof(long) == 8);
}
#endif
check_strtoimax();
check_strtoimax_span();
......
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