| 115 | }; |
| 116 | |
| 117 | bool 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 | |
| 139 | namespace SC |
| 140 | { |