diff --git a/src/test/CxxParserTestSuite.h b/src/test/CxxParserTestSuite.h index a74acb22..4cff6c8b 100644 --- a/src/test/CxxParserTestSuite.h +++ b/src/test/CxxParserTestSuite.h @@ -2527,6 +2527,27 @@ public: TS_ASSERT_EQUALS(client->errors[0], "use of undeclared identifier \'b\' <1:9 1:9>"); } + void test_cxx_parser_finds_location_of_line_comment() + { + std::shared_ptr client = parseCode( + "// this is a line comment\n" + ); + + TS_ASSERT_EQUALS(client->comments.size(), 1); + TS_ASSERT_EQUALS(client->comments[0], "comment <1:1 1:26>"); + } + + void test_cxx_parser_finds_location_of_block_comment() + { + std::shared_ptr client = parseCode( + "/* this is a\n" + "block comment */\n" + ); + + TS_ASSERT_EQUALS(client->comments.size(), 1); + TS_ASSERT_EQUALS(client->comments[0], "comment <1:1 2:17>"); + } + // void ___test_TEST() // { // std::shared_ptr client = parseCode( @@ -2840,6 +2861,12 @@ private: return 0; } + virtual Id onCommentParsed(const ParseLocation& location) + { + comments.push_back(addLocationSuffix("comment", location)); + return 0; + + } std::vector errors; @@ -2870,6 +2897,8 @@ private: std::vector files; std::vector includes; + std::vector comments; + private: void addTypeUse(const ParseTypeUsage& use) {