| 65 | }; |
| 66 | |
| 67 | TEST_F(NavigationTest, StringKey) |
| 68 | { |
| 69 | const std::string jsonText = R"({ |
| 70 | "key1" : "value1", |
| 71 | "key2" : "value2", |
| 72 | "keyLong" : "Value very very long", |
| 73 | "k" : "V" |
| 74 | })"; |
| 75 | |
| 76 | m_testData.input = jsonText; |
| 77 | m_testData.output = { |
| 78 | {R"(key1 : "value1")", Position {.nLine = 1, .nColumn = 5, .nKeyLength = 4}}, |
| 79 | {R"(key2 : "value2")", Position {.nLine = 2, .nColumn = 5, .nKeyLength = 4}}, |
| 80 | {R"(keyLong : "Value very very long")", Position {.nLine = 3, .nColumn = 5, .nKeyLength = 7}}, |
| 81 | {R"(k : "V")", Position {.nLine = 4, .nColumn = 5, .nKeyLength = 1}}, |
| 82 | }; |
| 83 | |
| 84 | m_pTSS = std::make_shared<TrackingStream>(jsonText); |
| 85 | m_pHandler = std::make_unique<RapidJsonHandler>(&m_TreeHandler, nullptr, m_pTSS); |
| 86 | rapidjson::StringBuffer sb; |
| 87 | |
| 88 | Result res = m_jsonHandler.ParseJson<flgBaseReader>(jsonText, sb, *m_pHandler, m_pTSS); |
| 89 | ASSERT_TRUE(res.success); |
| 90 | |
| 91 | for (const auto& each : m_testData.output) |
| 92 | { |
| 93 | const auto pos = m_TreeHandler.GetPosition(each.first); |
| 94 | ASSERT_TRUE(pos.has_value()) << "For key: " << each.first << std::endl; |
| 95 | |
| 96 | auto posValue = pos.value(); |
| 97 | ASSERT_EQ(posValue.nLine, each.second.nLine) << "For key: " << each.first << std::endl; |
| 98 | ASSERT_EQ(posValue.nColumn, each.second.nColumn) << "For key: " << each.first << std::endl; |
| 99 | ASSERT_EQ(posValue.nKeyLength, each.second.nKeyLength) << "For key: " << each.first << std::endl; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | TEST_F(NavigationTest, StringKeyCompressed) |
| 104 | { |
nothing calls this directly
no test coverage detected