MCPcopy Create free account
hub / github.com/Snapchat/Valdi / TEST

Function TEST

valdi/test/runtime/ValdiArchive_tests.cpp:9–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7namespace ValdiTest {
8
9TEST(ValdiArchive, supportsPadding) {
10 auto key = STRING_LITERAL("1");
11 auto data = STRING_LITERAL("!?");
12
13 ValdiArchiveBuilder builder;
14 builder.addEntry(ValdiArchiveEntry(key, data));
15
16 auto archiveBytes = builder.build();
17
18 // Data layout with padding support:
19 // 4 bytes magic | 4 bytes data length | 4 bytes file name length | 1 byte file name | 3 bytes padding | 4 bytes
20 // data length | 2 bytes data | 2 bytes padding
21 ASSERT_EQ(
22 static_cast<size_t>(sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t) + 1 + 3 + sizeof(uint32_t) + 2 + 2),
23 archiveBytes->size());
24
25 ValdiArchive archive(archiveBytes->begin(), archiveBytes->end());
26
27 auto result = archive.getEntries();
28
29 ASSERT_TRUE(result) << result.description();
30
31 const auto& entries = result.value();
32
33 ASSERT_EQ(static_cast<size_t>(1), entries.size());
34
35 const auto& entry = entries[0];
36 auto dataStr = std::string_view(reinterpret_cast<const char*>(entry.data), entry.dataLength);
37
38 ASSERT_EQ(STRING_LITERAL("1"), entry.filePath);
39 ASSERT_EQ("!?", dataStr);
40}
41
42} // namespace ValdiTest

Callers

nothing calls this directly

Calls 9

addEntryMethod · 0.80
descriptionMethod · 0.80
endMethod · 0.65
valueMethod · 0.65
ValdiArchiveEntryClass · 0.50
buildMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
getEntriesMethod · 0.45

Tested by

no test coverage detected