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

Function TEST

valdi/test/runtime/LinkedList_tests.cpp:10–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8class TestNode : public LinkedListNode {};
9
10TEST(LinkedList, canInsertAtBeginning) {
11 LinkedList<TestNode> list;
12
13 auto node1 = makeShared<TestNode>();
14 auto node2 = makeShared<TestNode>();
15 auto node3 = makeShared<TestNode>();
16
17 ASSERT_TRUE(list.empty());
18 ASSERT_TRUE(list.head() == nullptr);
19 ASSERT_TRUE(list.tail() == nullptr);
20
21 list.insert(list.begin(), node1);
22
23 ASSERT_FALSE(list.empty());
24 ASSERT_EQ(node1, list.head());
25 ASSERT_EQ(node1, list.tail());
26 ASSERT_EQ(nullptr, node1->prev());
27 ASSERT_EQ(nullptr, node1->prev());
28
29 list.insert(list.begin(), node2);
30
31 ASSERT_FALSE(list.empty());
32 ASSERT_EQ(node2, list.head());
33 ASSERT_EQ(node1, list.tail());
34 ASSERT_EQ(nullptr, node2->prev());
35 ASSERT_EQ(node1.get(), node2->next());
36 ASSERT_EQ(node2.get(), node1->prev());
37 ASSERT_EQ(nullptr, node1->next());
38
39 list.insert(list.begin(), node3);
40
41 ASSERT_FALSE(list.empty());
42 ASSERT_EQ(node3, list.head());
43 ASSERT_EQ(node1, list.tail());
44 ASSERT_EQ(nullptr, node3->prev());
45 ASSERT_EQ(node2.get(), node3->next());
46 ASSERT_EQ(node3.get(), node2->prev());
47 ASSERT_EQ(node1.get(), node2->next());
48 ASSERT_EQ(node2.get(), node1->prev());
49 ASSERT_EQ(nullptr, node1->next());
50}
51
52TEST(LinkedList, canInsertAtEnd) {
53 LinkedList<TestNode> list;

Callers

nothing calls this directly

Calls 15

prevMethod · 0.80
lastMethod · 0.80
use_countMethod · 0.80
headMethod · 0.65
insertMethod · 0.65
getMethod · 0.65
nextMethod · 0.65
endMethod · 0.65
removeMethod · 0.65
emptyMethod · 0.45
beginMethod · 0.45
insertAfterMethod · 0.45

Tested by

no test coverage detected