diff options
author | Joshua Haberman <joshua@reverberate.org> | 2009-07-08 12:06:47 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2009-07-08 12:06:47 -0700 |
commit | 462b26c1cc041a8fa26deb62cf12f1f351a5b2f6 (patch) | |
tree | de5a58f8d66d11c13b349448a970f84d57d16cad /tests.c | |
parent | c7ee14f8ef38a8bc90c0f1db1ad47b2e06612fa3 (diff) |
Directory restructuring.
Diffstat (limited to 'tests.c')
-rw-r--r-- | tests.c | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/tests.c b/tests.c deleted file mode 100644 index 7bc5dde..0000000 --- a/tests.c +++ /dev/null @@ -1,72 +0,0 @@ - -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#include "descriptor.c" -#include "upb_enum.c" -#include "upb_parse.c" -#include "upb_context.c" -#include "upb_msg.c" -#include "upb_table.c" - -void test_get_v_uint64_t() -{ - upb_status_t status; - - uint8_t zero[] = {0x00}; - void *zero_buf = zero; - uint64_t zero_val = 0; - status = get_v_uint64_t(&zero_buf, zero + sizeof(zero), &zero_val); - assert(status == UPB_STATUS_OK); - assert(zero_val == 0); - assert(zero_buf == zero + sizeof(zero)); - - uint8_t one[] = {0x01}; - void *one_buf = one; - uint64_t one_val = 0; - status = get_v_uint64_t(&one_buf, one + sizeof(one), &one_val); - assert(status == UPB_STATUS_OK); - assert(one_val == 1); - assert(one_buf == one + sizeof(one)); - - uint8_t twobyte[] = {0xAC, 0x02}; - void *twobyte_buf = twobyte; - uint64_t twobyte_val = 0; - status = get_v_uint64_t(&twobyte_buf, twobyte + sizeof(twobyte), &twobyte_val); - assert(status == UPB_STATUS_OK); - assert(twobyte_val == 300); - assert(twobyte_buf == twobyte + sizeof(twobyte)); - - uint8_t tenbyte[] = {0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x7F}; - void *tenbyte_buf = tenbyte; - uint64_t tenbyte_val = 0; - status = get_v_uint64_t(&tenbyte_buf, tenbyte + sizeof(tenbyte), &tenbyte_val); - assert(status == UPB_STATUS_OK); - assert(tenbyte_val == 0x89101c305080c101); - assert(tenbyte_buf == tenbyte + sizeof(tenbyte)); - - uint8_t elevenbyte[] = {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01}; - void *elevenbyte_buf = elevenbyte; - uint64_t elevenbyte_val = 0; - status = get_v_uint64_t(&elevenbyte_buf, elevenbyte + sizeof(elevenbyte), &elevenbyte_val); - assert(status == UPB_ERROR_UNTERMINATED_VARINT); - status = get_v_uint64_t(&elevenbyte_buf, elevenbyte + sizeof(elevenbyte)-1, &elevenbyte_val); - /* Byte 10 is 0x80, so we know it's unterminated. */ - assert(status == UPB_ERROR_UNTERMINATED_VARINT); - status = get_v_uint64_t(&elevenbyte_buf, elevenbyte + sizeof(elevenbyte)-2, &elevenbyte_val); - assert(status == UPB_STATUS_NEED_MORE_DATA); -} - -void test_upb_context() { - struct upb_context c; - assert(upb_context_init(&c)); - upb_context_free(&c); -} - -int main() -{ - test_get_v_uint64_t(); - test_upb_context(); - printf("All tests passed.\n"); - return 0; -} |