ACPI AML decompiler w/ CFG recovery and structured pseudocode
29

Configure Feed

Select the types of activity you want to include in your feed.

tobi / test / t_rd.c
1.2 kB 35 lines
1#include "t.h" 2 3#include "rd.h" 4 5int t_rd(void) { 6 uint8_t one[] = {0x3f}; 7 uint8_t two[] = {0x41, 0x12}; 8 uint8_t three[] = {0x82, 0x34, 0x12}; 9 uint8_t four[] = {0xc3, 0x56, 0x34, 0x12}; 10 tobi_rd r; 11 size_t len = 0; 12 size_t enc = 0; 13 tobi_rd_init(&r, one, sizeof(one), 0); 14 T_CHECK(tobi_rd_pkg_len(&r, &len, &enc) && len == 0x3f && enc == 1); 15 tobi_rd_init(&r, two, sizeof(two), 0); 16 T_CHECK(tobi_rd_pkg_len(&r, &len, &enc) && len == 0x121 && enc == 2); 17 tobi_rd_init(&r, three, sizeof(three), 0); 18 T_CHECK(tobi_rd_pkg_len(&r, &len, &enc) && len == 0x12342 && enc == 3); 19 tobi_rd_init(&r, four, sizeof(four), 0); 20 T_CHECK(tobi_rd_pkg_len(&r, &len, &enc) && len == 0x1234563 && enc == 4); 21 uint8_t trunc[] = {0x80}; 22 tobi_rd_init(&r, trunc, sizeof(trunc), 0); 23 T_CHECK(!tobi_rd_pkg_len(&r, &len, &enc)); 24 T_CHECK(r.pos == 0); 25 uint8_t b[] = {1, 2, 3}; 26 uint32_t v = 0; 27 tobi_rd_init(&r, b, sizeof(b), 0); 28 T_CHECK(!tobi_rd_u32(&r, &v)); 29 T_CHECK(r.pos == 0); 30 uint8_t x = 0; 31 T_CHECK(tobi_rd_u8(&r, &x) && x == 1); 32 T_CHECK(!tobi_rd_skip(&r, 99)); 33 T_CHECK(r.pos == 1); 34 return 0; 35}