Increased robustness of 64-bit varint test.

pull/13171/head
Joshua Haberman 16 years ago
parent c419731462
commit 24c14a3ad0
  1. 16
      tests.c

@ -29,17 +29,17 @@ void test_get_v_uint64_t()
assert(status == UPB_STATUS_OK);
assert(twobyte_val == 300);
uint8_t ninebyte[] = {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x7F};
uint8_t *ninebyte_buf = ninebyte;
uint64_t ninebyte_val = 0;
status = get_v_uint64_t(&ninebyte_buf, &ninebyte_val);
assert(status == UPB_STATUS_OK);
assert(ninebyte_val == (1ULL<<63));
uint8_t tenbyte[] = {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01};
uint8_t tenbyte[] = {0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x7F};
uint8_t *tenbyte_buf = tenbyte;
uint64_t tenbyte_val = 0;
status = get_v_uint64_t(&tenbyte_buf, &tenbyte_val);
assert(status == UPB_STATUS_OK);
assert(tenbyte_val == 0x89101c305080c101);
uint8_t elevenbyte[] = {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01};
uint8_t *elevenbyte_buf = elevenbyte;
uint64_t elevenbyte_val = 0;
status = get_v_uint64_t(&elevenbyte_buf, &elevenbyte_val);
assert(status == UPB_ERROR_UNTERMINATED_VARINT);
}

Loading…
Cancel
Save