aboutsummaryrefslogtreecommitdiffstats
path: root/skeletons/tests
diff options
context:
space:
mode:
Diffstat (limited to 'skeletons/tests')
-rw-r--r--skeletons/tests/check-INTEGER.c6
-rw-r--r--skeletons/tests/check-PER-INTEGER.c5
-rw-r--r--skeletons/tests/check-PER.c10
-rw-r--r--skeletons/tests/check-REAL.c16
-rw-r--r--skeletons/tests/check-XER.c8
-rw-r--r--skeletons/tests/check-length.c16
6 files changed, 32 insertions, 29 deletions
diff --git a/skeletons/tests/check-INTEGER.c b/skeletons/tests/check-INTEGER.c
index b58dd7bf..4ec9fd50 100644
--- a/skeletons/tests/check-INTEGER.c
+++ b/skeletons/tests/check-INTEGER.c
@@ -61,7 +61,7 @@ check(uint8_t *buf, int size, long check_long, int check_ret) {
assert(shared_scratch_start < scratch + sizeof(scratch));
assert(ret == 0);
ret = snprintf(verify, sizeof(verify), "%ld", check_long);
- assert(ret < sizeof(verify));
+ assert(ret < 0 || (size_t)ret < sizeof(verify));
ret = strcmp(scratch, verify);
printf(" [%s] vs [%s]: %d%s\n",
scratch, verify, ret,
@@ -170,7 +170,7 @@ check_xer(int tofail, char *xmldata, long orig_value) {
}
int
-main(int ac, char **av) {
+main() {
uint8_t buf1[] = { 1 };
uint8_t buf2[] = { 0xff };
uint8_t buf3[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
@@ -277,7 +277,7 @@ main(int ac, char **av) {
check_xer(-1, "<INTEGER>50223372036854775807</INTEGER>", 0);
check_xer(-1, "<INTEGER>100223372036854775807</INTEGER>", 0);
check_xer(-1, "<INTEGER>500223372036854775807</INTEGER>", 0);
- check_xer(0, "<INTEGER>-9223372036854775808</INTEGER>", -9223372036854775808);
+ check_xer(0, "<INTEGER>-9223372036854775808</INTEGER>", -9223372036854775807-1);
check_xer(-1, "<INTEGER>-9223372036854775809</INTEGER>", 0);
check_xer(-1, "<INTEGER>-10223372036854775807</INTEGER>", 0);
check_xer(-1, "<INTEGER>-50223372036854775807</INTEGER>", 0);
diff --git a/skeletons/tests/check-PER-INTEGER.c b/skeletons/tests/check-PER-INTEGER.c
index fc5106aa..640269b9 100644
--- a/skeletons/tests/check-PER-INTEGER.c
+++ b/skeletons/tests/check-PER-INTEGER.c
@@ -7,6 +7,9 @@
#include <per_support.h>
static int FailOut(const void *data, size_t size, void *op_key) {
+ (void)data;
+ (void)size;
+ (void)op_key;
assert(!"UNREACHABLE");
return 0;
}
@@ -89,7 +92,7 @@ check_per_encode_constrained(int lineno, int unsigned_, long value, long lbound,
recovered_value += cts.value.lower_bound;
assert((long)recovered_value == value);
}
- assert(po.nboff == ((bit_range == 32) ? 0 : (8 - (32 - bit_range))));
+ assert(po.nboff == (size_t)((bit_range == 32) ? 0 : (8 - (32 - bit_range))));
assert(po.nbits == 8 * (sizeof(po.tmpspace) - (po.buffer-po.tmpspace)));
assert(po.flushed_bytes == 0);
diff --git a/skeletons/tests/check-PER.c b/skeletons/tests/check-PER.c
index 8b55f23d..285bec07 100644
--- a/skeletons/tests/check-PER.c
+++ b/skeletons/tests/check-PER.c
@@ -178,6 +178,9 @@ check_per_decoding() {
}
static int Ignore(const void *data, size_t size, void *op_key) {
+ (void)data;
+ (void)size;
+ (void)op_key;
return 0;
}
@@ -299,7 +302,7 @@ check_per_encoding_auto() {
ASN_DEBUG("Putting %d + %d bits (%d/%d), got %d bytes and %d bits",
prior, next, (prior + next) / 8, (prior + next) % 8,
(int)(po.buffer - po.tmpspace), (int)po.nboff);
- assert((po.buffer - po.tmpspace) * 8 + po.nboff == prior + next);
+ assert((po.buffer - po.tmpspace) * 8 + po.nboff == (size_t)(prior + next));
for(i = 0; i < (po.buffer - po.tmpspace); i++)
assert(po.tmpspace[0] == (unsigned char)-1);
}
@@ -315,7 +318,6 @@ check_per_encoding_sweep_with(uint8_t buf[], int already_bits, int add_bits) {
int32_t d_add;
int32_t d_left;
int left_bits;
- int i;
memset(&pos, 0, sizeof(pos));
pos.buffer = buf;
@@ -345,10 +347,10 @@ check_per_encoding_sweep_with(uint8_t buf[], int already_bits, int add_bits) {
if(0 != memcmp(out.tmpspace, buf, buf_size)) {
printf("IN: ");
- for(i = 0; i < buf_size; i++)
+ for(size_t i = 0; i < buf_size; i++)
printf(" %02x", buf[i]);
printf("\nOUT:");
- for(i = 0; i < buf_size; i++)
+ for(size_t i = 0; i < buf_size; i++)
printf(" %02x", out.tmpspace[i]);
printf(" (out{nboff=%d,left=%d,%02x})\n", (int)out.nboff, left_bits, (int)d_left);
assert(0 == memcmp(out.tmpspace, buf, buf_size));
diff --git a/skeletons/tests/check-REAL.c b/skeletons/tests/check-REAL.c
index ba35244d..18bf8a59 100644
--- a/skeletons/tests/check-REAL.c
+++ b/skeletons/tests/check-REAL.c
@@ -22,12 +22,12 @@ callback(const void *buffer, size_t size, void *app_key) {
}
static char *
-d2s(double d, int canonical, const char *str) {
+d2s(double d, int canonical) {
ssize_t s;
reconstr_lens[canonical] = 0;
s = REAL__dump(d, canonical, callback, (void *)(ptrdiff_t)canonical);
- assert(s < sizeof(reconstructed[canonical]));
+ assert(s > 0 && (size_t)s < sizeof(reconstructed[canonical]));
assert(s == reconstr_lens[canonical]);
reconstructed[canonical][s] = '\0'; // ASCIIZ
return reconstructed[canonical];
@@ -41,8 +41,8 @@ static void
check_str_representation(double d, const char *sample, const char *canonical_sample, int lineno) {
char *s0, *s1;
- s0 = d2s(d, 0, sample);
- s1 = d2s(d, 1, canonical_sample);
+ s0 = d2s(d, 0);
+ s1 = d2s(d, 1);
if(sample) {
printf("%03d: Checking %f->[\"%s\"] against [\"%s\"]%s\n",
@@ -136,12 +136,12 @@ check_xer(int fuzzy, double orig_value) {
rc = xer_decode(0, &asn_DEF_REAL, (void **)newst0p,
reconstructed[0], reconstr_lens[0]);
assert(rc.code == RC_OK);
- assert(rc.consumed < reconstr_lens[0]);
+ assert(reconstr_lens[0] > 0 && rc.consumed < (size_t)reconstr_lens[0]);
rc = xer_decode(0, &asn_DEF_REAL, (void **)newst1p,
reconstructed[1], reconstr_lens[1]);
assert(rc.code == RC_OK);
- assert(rc.consumed == reconstr_lens[1]);
+ assert(rc.consumed == (size_t)reconstr_lens[1]);
ret = asn_REAL2double(newst0, &value0);
assert(ret == 0);
@@ -185,10 +185,10 @@ check_ber_buffer_twoway(double d, const char *sample, const char *canonical_samp
memset(&rn, 0, sizeof(rn));
ret = asn_double2REAL(&rn, d);
assert(ret == 0);
- if(rn.size != outsize) {
+ if((size_t)rn.size != outsize) {
printf("Encoded %f into %d expected %ld\n",
d, (int)rn.size, outsize);
- assert(rn.size == outsize);
+ assert((size_t)rn.size == outsize);
}
assert(memcmp(rn.buf, outbuf, rn.size) == 0);
diff --git a/skeletons/tests/check-XER.c b/skeletons/tests/check-XER.c
index 82cd0e4a..9084551c 100644
--- a/skeletons/tests/check-XER.c
+++ b/skeletons/tests/check-XER.c
@@ -31,7 +31,7 @@ check_next(char *xerbuf, int expected_chunk_size, pxer_chunk_type_e expected_chu
ch_type, (long)expected_chunk_type
);
- if(expected_chunk_type == -1) {
+ if(expected_chunk_type == PXER_WMORE) {
assert(ch_size == 0);
} else {
assert(ch_size == expected_chunk_size);
@@ -81,13 +81,13 @@ main() {
check("<tag attribute=\"value\"/>", "tag", XCT_BOTH);
check_next("<tag/>", -1, PXER_TAG);
- check_next("<tag", -1, -1);
+ check_next("<tag", -1, PXER_WMORE);
check_next("tag", -1, PXER_TEXT);
check_next("tag<s", 3, PXER_TEXT);
check_next("</a/>la", 5, PXER_TAG);
check_next("<!--blah", -1, PXER_COMMENT);
- check_next("<!--blah-", -1, -1);
- check_next("<!--blah--", -1, -1);
+ check_next("<!--blah-", -1, PXER_WMORE);
+ check_next("<!--blah--", -1, PXER_WMORE);
check_next("<!--blah-->", -1, PXER_COMMENT);
return 0;
diff --git a/skeletons/tests/check-length.c b/skeletons/tests/check-length.c
index 8c2b64b7..aa73b2c9 100644
--- a/skeletons/tests/check-length.c
+++ b/skeletons/tests/check-length.c
@@ -31,13 +31,12 @@ write_to_buf(const void *buffer, size_t size, void *key) {
static void
-check(int size) {
+check(size_t size) {
OCTET_STRING_t *os;
OCTET_STRING_t *nos = 0;
OCTET_STRING_t **nosp = &nos;
asn_enc_rval_t erval;
asn_dec_rval_t rval;
- int i;
os = OCTET_STRING_new_fromBuf(&asn_DEF_OCTET_STRING, 0, size);
assert(os);
@@ -47,14 +46,14 @@ check(int size) {
assert(os->buf);
os->size = size;
- for(i = 0; i < size; i++) {
+ for(size_t i = 0; i < size; i++) {
os->buf[i] = i;
}
buf_off = 0;
erval = der_encode(&asn_DEF_OCTET_STRING,
os, write_to_buf, 0);
- assert(erval.encoded == buf_off);
+ assert(erval.encoded >= 0 && (size_t)erval.encoded == buf_off);
assert(buf_off > size);
rval = ber_decode(0, &asn_DEF_OCTET_STRING, (void **)nosp, buf, buf_off);
@@ -63,13 +62,13 @@ check(int size) {
assert(os->size == nos->size);
- for(i = 0; i < size; i++) {
+ for(size_t i = 0; i < size; i++) {
assert(os->buf[i] == nos->buf[i]);
}
if(0) {
- fprintf(stderr, "new(%d):", size);
- for(i = 0; i < (buf_off<10?buf_off:10); i++)
+ fprintf(stderr, "new(%zd):", size);
+ for(size_t i = 0; i < (buf_off<10?buf_off:10); i++)
fprintf(stderr, " %02x", buf[i]);
printf("\n");
}
@@ -87,9 +86,8 @@ main() {
uint8_t buf4[] = { 0x89, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x04 };
ber_tlv_len_t tlv_len;
ssize_t ret;
- int i;
- for(i = 0; i < 66000; i++) {
+ for(size_t i = 0; i < 66000; i++) {
if(i == 4500) i = 64000; /* Jump */
check(i);
}