line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "test.h" |
2
|
|
|
|
|
|
|
#include |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
using namespace panda; |
5
|
|
|
|
|
|
|
|
6
|
19
|
|
|
|
|
|
TEST_CASE("varint encode", "[varint]") { |
7
|
1
|
50
|
|
|
|
|
CHECK(varint_encode(0) == string("\0")); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8
|
1
|
50
|
|
|
|
|
CHECK(varint_encode(1) == string("\1")); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
9
|
1
|
50
|
|
|
|
|
CHECK(varint_encode(127) == string("\x7f")); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
50
|
|
|
|
|
CHECK(varint_encode(128) == string("\x80\1")); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
12
|
1
|
50
|
|
|
|
|
CHECK(varint_encode(129) == string("\x81\1")); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
13
|
1
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
19
|
|
|
|
|
|
TEST_CASE("varint decode", "[varint]") { |
16
|
1
|
50
|
|
|
|
|
CHECK(varint_decode(string("\0")) == 0); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
17
|
1
|
50
|
|
|
|
|
CHECK(varint_decode(string("\1")) == 1); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
18
|
1
|
50
|
|
|
|
|
CHECK(varint_decode(string("\x7f")) == 127); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
50
|
|
|
|
|
CHECK(varint_decode(string("\x80\1")) == 128); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
21
|
1
|
50
|
|
|
|
|
CHECK(varint_decode(string("\x81\1")) == 129); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
22
|
1
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
19
|
|
|
|
|
|
TEST_CASE("varint cross check", "[varint]") { |
25
|
257
|
100
|
|
|
|
|
for (uint32_t i = 0; i < 256; ++i) { |
26
|
256
|
50
|
|
|
|
|
if (varint_decode(varint_encode(i)) != i) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
FAIL(i); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
17243
|
100
|
|
|
|
|
for (uint32_t i = 0; i < 500000; i+=29) { |
31
|
17242
|
50
|
|
|
|
|
if (varint_decode(varint_encode(i)) != i) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
FAIL(i); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
1
|
50
|
|
|
|
|
REQUIRE(true); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
36
|
1
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
19
|
|
|
|
|
|
TEST_CASE("varint_s cross check", "[varint]") { |
39
|
1
|
50
|
|
|
|
|
for (int i = 256; i < 256; ++i) { |
40
|
0
|
0
|
|
|
|
|
if (varint_decode_s(varint_encode_s(i)) != i) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
FAIL(i); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
34484
|
100
|
|
|
|
|
for (int i = -500000; i < 500000; i+=29) { |
45
|
34483
|
50
|
|
|
|
|
int res = varint_decode_s(varint_encode_s(i)); |
|
|
50
|
|
|
|
|
|
46
|
34483
|
50
|
|
|
|
|
if (res != i) { |
47
|
0
|
0
|
|
|
|
|
INFO(res); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
FAIL(i); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
1
|
50
|
|
|
|
|
REQUIRE(true); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
52
|
1
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
19
|
|
|
|
|
|
TEST_CASE("VarIntStack", "[varint]") { |
55
|
2
|
50
|
|
|
|
|
VarIntStack stack; |
56
|
1
|
50
|
|
|
|
|
stack.push(300); |
57
|
1
|
50
|
|
|
|
|
stack.push(400); |
58
|
1
|
50
|
|
|
|
|
CHECK(stack.top() == 400); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
59
|
1
|
50
|
|
|
|
|
stack.pop(); |
60
|
1
|
50
|
|
|
|
|
CHECK(stack.top() == 300); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
61
|
73
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|