MCPcopy Create free account
hub / github.com/NPP-JSONViewer/JSON-Viewer / TreeHandlerTest

Class TreeHandlerTest

tests/UnitTest/NavigationTest.cpp:13–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11
12
13class TreeHandlerTest : public TreeHandler
14{
15 std::unordered_map<std::string, Position> m_mapKeyPosition;
16
17public:
18 virtual ~TreeHandlerTest() = default;
19
20
21 // Inherited via TreeHandler
22 HTREEITEM InsertToTree(HTREEITEM /*parent*/, const std::string& text) override
23 {
24 m_mapKeyPosition[text] = {};
25 return HTREEITEM();
26 }
27
28 HTREEITEM InsertToTree(HTREEITEM /*parent*/, const std::string& text, const Position& pos) override
29 {
30 m_mapKeyPosition[text] = pos;
31 return HTREEITEM();
32 }
33
34 void AppendNodeCount(HTREEITEM /*node*/, unsigned /*elementCount*/, bool /*bArray*/) override {}
35
36 auto GetPosition(const std::string& text) const -> std::optional<Position>
37 {
38 auto find = m_mapKeyPosition.find(text);
39
40 std::optional<Position> retVal = std::nullopt;
41 if (find != m_mapKeyPosition.cend())
42 retVal = find->second;
43
44 return retVal;
45 }
46};
47
48namespace JsonNavigation
49{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected