MCPcopy Create free account
hub / github.com/chen3feng/toft / TEST

Function TEST

encoding/varint_test.cpp:12–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10namespace toft {
11
12TEST(VarintTest, Varint32) {
13 std::string s;
14 for (uint32_t i = 0; i < (32 * 32); i++) {
15 uint32_t v = (i / 32) << (i % 32);
16 Varint::Put32(&s, v);
17 }
18
19 const char* p = s.data();
20 const char* limit = p + s.size();
21 for (uint32_t i = 0; i < (32 * 32); i++) {
22 uint32_t expected = (i / 32) << (i % 32);
23 uint32_t actual;
24 const char* start = p;
25 p = Varint::Decode32(p, limit, &actual);
26 ASSERT_TRUE(p != NULL);
27 ASSERT_EQ(expected, actual);
28 ASSERT_EQ(Varint::EncodedLength(actual), p - start);
29 }
30 ASSERT_EQ(p, s.data() + s.size());
31}
32
33TEST(VarintTest, Varint64) {
34 // Construct the list of values to check

Callers

nothing calls this directly

Calls 5

StringPieceClass · 0.85
dataMethod · 0.80
push_backMethod · 0.80
as_stringMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected