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

Function TEST

valdi/test/runtime/ReferenceTable_tests.cpp:14–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12namespace ValdiTest {
13
14TEST(ReferenceTable, canMakeRef) {
15 ReferenceTable table;
16
17 {
18 auto write = table.writeAccess();
19 auto id = write.makeRef("MyRef").id;
20
21 ASSERT_EQ(static_cast<uint32_t>(1), id.getSalt());
22 ASSERT_EQ(static_cast<uint32_t>(0), id.getIndex());
23
24 auto id2 = write.makeRef("MyRef").id;
25
26 ASSERT_EQ(static_cast<uint32_t>(2), id2.getSalt());
27 ASSERT_EQ(static_cast<uint32_t>(1), id2.getIndex());
28
29 auto id3 = write.makeRef("MyOtherRef").id;
30
31 ASSERT_EQ(static_cast<uint32_t>(3), id3.getSalt());
32 ASSERT_EQ(static_cast<uint32_t>(2), id3.getIndex());
33
34 ASSERT_EQ(static_cast<size_t>(1), write.getEntry(id).retainCount);
35 ASSERT_EQ(static_cast<size_t>(1), write.getEntry(id2).retainCount);
36 ASSERT_EQ(static_cast<size_t>(1), write.getEntry(id3).retainCount);
37 }
38
39 auto allReferences = table.readAccess().getAll();
40 ASSERT_EQ(static_cast<size_t>(3), allReferences.size());
41
42 ASSERT_EQ(ReferenceTableEntry(SequenceID(0, 1), 1, "MyRef"), allReferences[0]);
43 ASSERT_EQ(ReferenceTableEntry(SequenceID(1, 2), 1, "MyRef"), allReferences[1]);
44 ASSERT_EQ(ReferenceTableEntry(SequenceID(2, 3), 1, "MyOtherRef"), allReferences[2]);
45}
46
47TEST(ReferenceTable, canRetainRef) {
48 ReferenceTable table;

Callers

nothing calls this directly

Calls 15

ReferenceTableEntryClass · 0.85
SequenceIDClass · 0.85
makeRefMethod · 0.80
getSaltMethod · 0.80
retainRefMethod · 0.80
blockingWaitMethod · 0.80
enterMethod · 0.65
clearMethod · 0.65
writeAccessMethod · 0.45
getIndexMethod · 0.45
getEntryMethod · 0.45
getAllMethod · 0.45

Tested by

no test coverage detected