diff --git a/tests/leb128.c b/tests/leb128.c index 6994a436..47b57c0d 100644 --- a/tests/leb128.c +++ b/tests/leb128.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "../libdw/libdwP.h" #include "../libdw/memory-access.h" @@ -26,10 +27,16 @@ #define FAIL 1 static const unsigned char v0[] = { 0x0 }; +static const unsigned char v1[] = { 0x1 }; static const unsigned char v23[] = { 23 }; +static const unsigned char vm_1[] = { 0x7f }; static const unsigned char vm_2[] = { 0x7e }; +static const unsigned char s127[] = { 0xff, 0x00 }; static const unsigned char v128[] = { 0x80, 0x01 }; +static const unsigned char v129[] = { 0x81, 0x01 }; +static const unsigned char vm_127[] = { 0x81, 0x7f }; static const unsigned char vm_128[] = { 0x80, 0x7f }; +static const unsigned char vm_129[] = { 0xff, 0x7e }; static const unsigned char vhuge[] = { 0xff, 0xff, 0xff, 0xff, 0xff, @@ -50,6 +57,16 @@ static const unsigned char minus_one[] = 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f }; +static const unsigned char int64_max_m1[] = + { + 0xfe, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x00 + }; +static const unsigned char int64_min_p1[] = + { + 0x81, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x7f + }; static int test_one_sleb (const unsigned char *data, size_t len, int64_t expect) @@ -78,14 +95,22 @@ test_sleb (void) return FAIL; TEST (v0, 0); + TEST (v1, 1); TEST (v23, 23); + TEST (vm_1, -1); TEST (vm_2, -2); + TEST (s127, 127); TEST (v128, 128); + TEST (v129, 129); + TEST (vm_127, -127); TEST (vm_128, -128); + TEST (vm_129, -129); TEST (vhuge, 9223372036854775807ll); TEST (most_positive, 4611686018427387903ll); TEST (most_negative, -4611686018427387904ll); TEST (minus_one, -1); + TEST (int64_max_m1, INT64_MAX - 1); + TEST (int64_min_p1, INT64_MIN + 1); #undef TEST @@ -119,14 +144,22 @@ test_uleb (void) return FAIL; TEST (v0, 0); + TEST (v1, 1); TEST (v23, 23); + TEST (vm_1, 127); TEST (vm_2, 126); + TEST (s127, 127); TEST (v128, 128); + TEST (v129, 129); + TEST (vm_127, 16257); TEST (vm_128, 16256); + TEST (vm_129, 16255); TEST (vhuge, 9223372036854775807ull); TEST (most_positive, 4611686018427387903ull); TEST (most_negative, 4611686018427387904ull); TEST (minus_one, 9223372036854775807ull); + TEST (int64_max_m1, INT64_MAX - 1); + TEST (int64_min_p1, INT64_MIN + 1); #undef TEST