MCPcopy Create free account
hub / github.com/comaps/comaps / UNIT_TEST

Function UNIT_TEST

libs/base/base_tests/linked_map_tests.cpp:8–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include <string>
7
8UNIT_TEST(LinkedMap_Smoke)
9{
10 base::LinkedMap<int, std::string, std::map> container;
11
12 TEST(container.IsEmpty(), ());
13
14 TEST(container.Emplace(1, "hello"), ());
15 TEST(container.Emplace(2, "world"), ());
16 TEST(container.Emplace(3, "!"), ());
17
18 TEST(!container.IsEmpty(), ());
19 TEST_EQUAL(container.Size(), 3, ());
20
21 TEST(!container.Emplace(2, "again"), ());
22
23 TEST_EQUAL(container.Size(), 3, ());
24
25 TEST(container.Contains(2), ());
26 auto const getResult = container.Get(2);
27 TEST_EQUAL(getResult, "world", ());
28
29 TEST_EQUAL(container.Front(), "hello", ());
30 container.PopFront();
31 TEST_EQUAL(container.Front(), "world", ());
32
33 TEST_EQUAL(container.Size(), 2, ());
34
35 TEST(!container.Contains(10), ());
36 TEST(!container.Erase(10), ());
37 TEST_EQUAL(container.Size(), 2, ());
38
39 TEST(container.Contains(3), ());
40 TEST(container.Erase(3), ());
41 TEST_EQUAL(container.Size(), 1, ());
42 TEST_EQUAL(container.Front(), "world", ());
43
44 decltype(container) otherContainer;
45 otherContainer.Swap(container);
46
47 TEST(container.IsEmpty(), ());
48 TEST_EQUAL(container.Size(), 0, ());
49 TEST(!otherContainer.IsEmpty(), ());
50 TEST_EQUAL(otherContainer.Size(), 1, ());
51 TEST_EQUAL(otherContainer.Front(), "world", ());
52}

Callers

nothing calls this directly

Calls 10

TESTFunction · 0.85
IsEmptyMethod · 0.45
EmplaceMethod · 0.45
SizeMethod · 0.45
ContainsMethod · 0.45
GetMethod · 0.45
FrontMethod · 0.45
PopFrontMethod · 0.45
EraseMethod · 0.45
SwapMethod · 0.45

Tested by

no test coverage detected