MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / arenaMapSnippet

Method arenaMapSnippet

Tests/Libraries/Containers/ArenaMapTest.cpp:117–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115};
116
117bool SC::ArenaMapTest::arenaMapSnippet()
118{
119 //! [ArenaMapSnippet]
120 ArenaMap<String> map;
121 SC_TRY(not map.insert("ASD").isValid());
122 SC_TRY(map.resize(3));
123 ArenaMap<String>::Key keys[3];
124 keys[0] = map.insert("ASD");
125 SC_TRY(map.size() == 1);
126 SC_TRY(not map.resize(4)); // cannot resize unless is empty
127 keys[1] = map.insert("DSA");
128 keys[2] = map.insert("BDA");
129 SC_TRY(map.size() == 3);
130 SC_TRY(not map.insert("123").isValid()); // Arena is full
131
132 SC_TRY(map.get(keys[0])->view() == "ASD"); // Get first element
133 SC_TRY(map.get(keys[1])->view() == "DSA"); // Get second element
134 SC_TRY(map.get(keys[2])->view() == "BDA"); // Get third element
135 //! [ArenaMapSnippet]
136 return true;
137}
138
139namespace SC
140{

Callers

nothing calls this directly

Calls 6

isValidMethod · 0.45
insertMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45
viewMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected