MCPcopy Create free account
hub / github.com/apache/brpc / ExpectListContentsForDirection

Function ExpectListContentsForDirection

test/linked_list_unittest.cc:37–49  ·  view source on GitHub ↗

Checks that when iterating |list| (either from head to tail, or from tail to head, as determined by |forward|), we get back |node_ids|, which is an array of size |num_nodes|.

Source from the content-addressed store, hash-verified

35// tail to head, as determined by |forward|), we get back |node_ids|,
36// which is an array of size |num_nodes|.
37void ExpectListContentsForDirection(const LinkedList<Node>& list,
38 int num_nodes, const int* node_ids, bool forward) {
39 int i = 0;
40 for (const LinkNode<Node>* node = (forward ? list.head() : list.tail());
41 node != list.end();
42 node = (forward ? node->next() : node->previous())) {
43 ASSERT_LT(i, num_nodes);
44 int index_of_id = forward ? i : num_nodes - i - 1;
45 EXPECT_EQ(node_ids[index_of_id], node->value()->id());
46 ++i;
47 }
48 EXPECT_EQ(num_nodes, i);
49}
50
51void ExpectListContents(const LinkedList<Node>& list,
52 int num_nodes,

Callers 1

ExpectListContentsFunction · 0.85

Calls 7

headMethod · 0.80
tailMethod · 0.80
previousMethod · 0.80
endMethod · 0.45
nextMethod · 0.45
idMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected