mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-10-31 04:32:33 +00:00 
			
		
		
		
	Use indented TEST_SUITE
This commit is contained in:
		
							parent
							
								
									424c7b69db
								
							
						
					
					
						commit
						297ed1d13e
					
				| @ -3257,9 +3257,8 @@ int main(int argc, char** argv) { | |||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_SUITE("LexFunctionDeclaration"); | TEST_SUITE("LexFunctionDeclaration") { | ||||||
| 
 |   TEST_CASE("simple") { | ||||||
| TEST_CASE("simple") { |  | ||||||
|     std::string buffer_content = " void Foo(); "; |     std::string buffer_content = " void Foo(); "; | ||||||
|     lsPosition declaration = CharPos(buffer_content, 'F'); |     lsPosition declaration = CharPos(buffer_content, 'F'); | ||||||
|     std::string insert_text; |     std::string insert_text; | ||||||
| @ -3274,9 +3273,9 @@ TEST_CASE("simple") { | |||||||
|                           &insert_text, &newlines_after_name); |                           &insert_text, &newlines_after_name); | ||||||
|     REQUIRE(insert_text == "void Type::Foo() {\n}"); |     REQUIRE(insert_text == "void Type::Foo() {\n}"); | ||||||
|     REQUIRE(newlines_after_name == 0); |     REQUIRE(newlines_after_name == 0); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("ctor") { |   TEST_CASE("ctor") { | ||||||
|     std::string buffer_content = " Foo(); "; |     std::string buffer_content = " Foo(); "; | ||||||
|     lsPosition declaration = CharPos(buffer_content, 'F'); |     lsPosition declaration = CharPos(buffer_content, 'F'); | ||||||
|     std::string insert_text; |     std::string insert_text; | ||||||
| @ -3286,9 +3285,9 @@ TEST_CASE("ctor") { | |||||||
|                           &insert_text, &newlines_after_name); |                           &insert_text, &newlines_after_name); | ||||||
|     REQUIRE(insert_text == "Foo::Foo() {\n}"); |     REQUIRE(insert_text == "Foo::Foo() {\n}"); | ||||||
|     REQUIRE(newlines_after_name == 0); |     REQUIRE(newlines_after_name == 0); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("dtor") { |   TEST_CASE("dtor") { | ||||||
|     std::string buffer_content = " ~Foo(); "; |     std::string buffer_content = " ~Foo(); "; | ||||||
|     lsPosition declaration = CharPos(buffer_content, '~'); |     lsPosition declaration = CharPos(buffer_content, '~'); | ||||||
|     std::string insert_text; |     std::string insert_text; | ||||||
| @ -3298,9 +3297,9 @@ TEST_CASE("dtor") { | |||||||
|                           &insert_text, &newlines_after_name); |                           &insert_text, &newlines_after_name); | ||||||
|     REQUIRE(insert_text == "Foo::~Foo() {\n}"); |     REQUIRE(insert_text == "Foo::~Foo() {\n}"); | ||||||
|     REQUIRE(newlines_after_name == 0); |     REQUIRE(newlines_after_name == 0); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("complex return type") { |   TEST_CASE("complex return type") { | ||||||
|     std::string buffer_content = " std::vector<int> Foo(); "; |     std::string buffer_content = " std::vector<int> Foo(); "; | ||||||
|     lsPosition declaration = CharPos(buffer_content, 'F'); |     lsPosition declaration = CharPos(buffer_content, 'F'); | ||||||
|     std::string insert_text; |     std::string insert_text; | ||||||
| @ -3315,9 +3314,9 @@ TEST_CASE("complex return type") { | |||||||
|                           &insert_text, &newlines_after_name); |                           &insert_text, &newlines_after_name); | ||||||
|     REQUIRE(insert_text == "std::vector<int> Type::Foo() {\n}"); |     REQUIRE(insert_text == "std::vector<int> Type::Foo() {\n}"); | ||||||
|     REQUIRE(newlines_after_name == 0); |     REQUIRE(newlines_after_name == 0); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("extra complex return type") { |   TEST_CASE("extra complex return type") { | ||||||
|     std::string buffer_content = " std::function < int() > \n Foo(); "; |     std::string buffer_content = " std::function < int() > \n Foo(); "; | ||||||
|     lsPosition declaration = CharPos(buffer_content, 'F'); |     lsPosition declaration = CharPos(buffer_content, 'F'); | ||||||
|     std::string insert_text; |     std::string insert_text; | ||||||
| @ -3332,9 +3331,9 @@ TEST_CASE("extra complex return type") { | |||||||
|                           &insert_text, &newlines_after_name); |                           &insert_text, &newlines_after_name); | ||||||
|     REQUIRE(insert_text == "std::function < int() > \n Type::Foo() {\n}"); |     REQUIRE(insert_text == "std::function < int() > \n Type::Foo() {\n}"); | ||||||
|     REQUIRE(newlines_after_name == 0); |     REQUIRE(newlines_after_name == 0); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("parameters") { |   TEST_CASE("parameters") { | ||||||
|     std::string buffer_content = "void Foo(int a,\n\n    int b); "; |     std::string buffer_content = "void Foo(int a,\n\n    int b); "; | ||||||
|     lsPosition declaration = CharPos(buffer_content, 'F'); |     lsPosition declaration = CharPos(buffer_content, 'F'); | ||||||
|     std::string insert_text; |     std::string insert_text; | ||||||
| @ -3349,77 +3348,73 @@ TEST_CASE("parameters") { | |||||||
|                           &insert_text, &newlines_after_name); |                           &insert_text, &newlines_after_name); | ||||||
|     REQUIRE(insert_text == "void Type::Foo(int a,\n\n    int b) {\n}"); |     REQUIRE(insert_text == "void Type::Foo(int a,\n\n    int b) {\n}"); | ||||||
|     REQUIRE(newlines_after_name == 2); |     REQUIRE(newlines_after_name == 2); | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_SUITE_END(); | TEST_SUITE("LexWordAroundPos") { | ||||||
| 
 |   TEST_CASE("edges") { | ||||||
| TEST_SUITE("LexWordAroundPos"); |  | ||||||
| 
 |  | ||||||
| TEST_CASE("edges") { |  | ||||||
|     std::string content = "Foobar"; |     std::string content = "Foobar"; | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, 'F'), content) == "Foobar"); |     REQUIRE(LexWordAroundPos(CharPos(content, 'F'), content) == "Foobar"); | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, 'o'), content) == "Foobar"); |     REQUIRE(LexWordAroundPos(CharPos(content, 'o'), content) == "Foobar"); | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, 'b'), content) == "Foobar"); |     REQUIRE(LexWordAroundPos(CharPos(content, 'b'), content) == "Foobar"); | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, 'a'), content) == "Foobar"); |     REQUIRE(LexWordAroundPos(CharPos(content, 'a'), content) == "Foobar"); | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, 'r'), content) == "Foobar"); |     REQUIRE(LexWordAroundPos(CharPos(content, 'r'), content) == "Foobar"); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("simple") { |   TEST_CASE("simple") { | ||||||
|     std::string content = "  Foobar  "; |     std::string content = "  Foobar  "; | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, 'F'), content) == "Foobar"); |     REQUIRE(LexWordAroundPos(CharPos(content, 'F'), content) == "Foobar"); | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, 'o'), content) == "Foobar"); |     REQUIRE(LexWordAroundPos(CharPos(content, 'o'), content) == "Foobar"); | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, 'b'), content) == "Foobar"); |     REQUIRE(LexWordAroundPos(CharPos(content, 'b'), content) == "Foobar"); | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, 'a'), content) == "Foobar"); |     REQUIRE(LexWordAroundPos(CharPos(content, 'a'), content) == "Foobar"); | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, 'r'), content) == "Foobar"); |     REQUIRE(LexWordAroundPos(CharPos(content, 'r'), content) == "Foobar"); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("underscores and numbers") { |   TEST_CASE("underscores and numbers") { | ||||||
|     std::string content = "  _my_t5ype7  "; |     std::string content = "  _my_t5ype7  "; | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, '_'), content) == "_my_t5ype7"); |     REQUIRE(LexWordAroundPos(CharPos(content, '_'), content) == "_my_t5ype7"); | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, '5'), content) == "_my_t5ype7"); |     REQUIRE(LexWordAroundPos(CharPos(content, '5'), content) == "_my_t5ype7"); | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, 'e'), content) == "_my_t5ype7"); |     REQUIRE(LexWordAroundPos(CharPos(content, 'e'), content) == "_my_t5ype7"); | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, '7'), content) == "_my_t5ype7"); |     REQUIRE(LexWordAroundPos(CharPos(content, '7'), content) == "_my_t5ype7"); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("dot, dash, colon are skipped") { |   TEST_CASE("dot, dash, colon are skipped") { | ||||||
|     std::string content = "1. 2- 3:"; |     std::string content = "1. 2- 3:"; | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, '1'), content) == "1"); |     REQUIRE(LexWordAroundPos(CharPos(content, '1'), content) == "1"); | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, '2'), content) == "2"); |     REQUIRE(LexWordAroundPos(CharPos(content, '2'), content) == "2"); | ||||||
|     REQUIRE(LexWordAroundPos(CharPos(content, '3'), content) == "3"); |     REQUIRE(LexWordAroundPos(CharPos(content, '3'), content) == "3"); | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_SUITE_END(); | TEST_SUITE("FindIncludeLine") { | ||||||
| 
 |   TEST_CASE("in document") { | ||||||
| TEST_SUITE("FindIncludeLine"); |  | ||||||
| 
 |  | ||||||
| TEST_CASE("in document") { |  | ||||||
|     std::vector<std::string> lines = { |     std::vector<std::string> lines = { | ||||||
|         "#include <bbb>",  // 0
 |         "#include <bbb>",  // 0
 | ||||||
|         "#include <ddd>"   // 1
 |         "#include <ddd>"   // 1
 | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     REQUIRE(FindIncludeLine(lines, "#include <bbb>") == nullopt); |     REQUIRE(FindIncludeLine(lines, "#include <bbb>") == nullopt); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("insert before") { |   TEST_CASE("insert before") { | ||||||
|     std::vector<std::string> lines = { |     std::vector<std::string> lines = { | ||||||
|         "#include <bbb>",  // 0
 |         "#include <bbb>",  // 0
 | ||||||
|         "#include <ddd>"   // 1
 |         "#include <ddd>"   // 1
 | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     REQUIRE(FindIncludeLine(lines, "#include <aaa>") == 0); |     REQUIRE(FindIncludeLine(lines, "#include <aaa>") == 0); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("insert middle") { |   TEST_CASE("insert middle") { | ||||||
|     std::vector<std::string> lines = { |     std::vector<std::string> lines = { | ||||||
|         "#include <bbb>",  // 0
 |         "#include <bbb>",  // 0
 | ||||||
|         "#include <ddd>"   // 1
 |         "#include <ddd>"   // 1
 | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     REQUIRE(FindIncludeLine(lines, "#include <ccc>") == 1); |     REQUIRE(FindIncludeLine(lines, "#include <ccc>") == 1); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("insert after") { |   TEST_CASE("insert after") { | ||||||
|     std::vector<std::string> lines = { |     std::vector<std::string> lines = { | ||||||
|         "#include <bbb>",  // 0
 |         "#include <bbb>",  // 0
 | ||||||
|         "#include <ddd>",  // 1
 |         "#include <ddd>",  // 1
 | ||||||
| @ -3427,9 +3422,9 @@ TEST_CASE("insert after") { | |||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     REQUIRE(FindIncludeLine(lines, "#include <eee>") == 2); |     REQUIRE(FindIncludeLine(lines, "#include <eee>") == 2); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("ignore header") { |   TEST_CASE("ignore header") { | ||||||
|     std::vector<std::string> lines = { |     std::vector<std::string> lines = { | ||||||
|         "// FOOBAR",       // 0
 |         "// FOOBAR",       // 0
 | ||||||
|         "// FOOBAR",       // 1
 |         "// FOOBAR",       // 1
 | ||||||
| @ -3444,6 +3439,5 @@ TEST_CASE("ignore header") { | |||||||
|     REQUIRE(FindIncludeLine(lines, "#include <a>") == 5); |     REQUIRE(FindIncludeLine(lines, "#include <a>") == 5); | ||||||
|     REQUIRE(FindIncludeLine(lines, "#include <c>") == 6); |     REQUIRE(FindIncludeLine(lines, "#include <c>") == 6); | ||||||
|     REQUIRE(FindIncludeLine(lines, "#include <e>") == 7); |     REQUIRE(FindIncludeLine(lines, "#include <e>") == 7); | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 |  | ||||||
| TEST_SUITE_END(); |  | ||||||
|  | |||||||
| @ -82,8 +82,6 @@ optional<std::string> ReadJsonRpcContentFrom( | |||||||
|   return content; |   return content; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_SUITE("FindIncludeLine"); |  | ||||||
| 
 |  | ||||||
| std::function<optional<char>()> MakeContentReader(std::string* content, | std::function<optional<char>()> MakeContentReader(std::string* content, | ||||||
|                                                   bool can_be_empty) { |                                                   bool can_be_empty) { | ||||||
|   return [content, can_be_empty]() -> optional<char> { |   return [content, can_be_empty]() -> optional<char> { | ||||||
| @ -97,7 +95,8 @@ std::function<optional<char>()> MakeContentReader(std::string* content, | |||||||
|   }; |   }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("ReadContentFromSource") { | TEST_SUITE("FindIncludeLine") { | ||||||
|  |   TEST_CASE("ReadContentFromSource") { | ||||||
|     auto parse_correct = [](std::string content) -> std::string { |     auto parse_correct = [](std::string content) -> std::string { | ||||||
|       auto reader = MakeContentReader(&content, false /*can_be_empty*/); |       auto reader = MakeContentReader(&content, false /*can_be_empty*/); | ||||||
|       auto got = ReadJsonRpcContentFrom(reader); |       auto got = ReadJsonRpcContentFrom(reader); | ||||||
| @ -118,10 +117,9 @@ TEST_CASE("ReadContentFromSource") { | |||||||
|     REQUIRE(parse_incorrect("Content-Length: 0\r\n") == optional<std::string>()); |     REQUIRE(parse_incorrect("Content-Length: 0\r\n") == optional<std::string>()); | ||||||
|     REQUIRE(parse_incorrect("Content-Length: 5\r\n\r\nab") == |     REQUIRE(parse_incorrect("Content-Length: 5\r\n\r\nab") == | ||||||
|             optional<std::string>()); |             optional<std::string>()); | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_SUITE_END(); |  | ||||||
| 
 |  | ||||||
| optional<char> ReadCharFromStdinBlocking() { | optional<char> ReadCharFromStdinBlocking() { | ||||||
|   // Bad stdin means parent process has probably exited. Either way, cquery
 |   // Bad stdin means parent process has probably exited. Either way, cquery
 | ||||||
|   // can no longer be communicated with so just exit.
 |   // can no longer be communicated with so just exit.
 | ||||||
|  | |||||||
| @ -213,32 +213,29 @@ bool SubstringMatch(const std::string& search, const std::string& content) { | |||||||
|   return false; |   return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_SUITE("Offset"); | TEST_SUITE("Offset") { | ||||||
| 
 |   TEST_CASE("past end") { | ||||||
| TEST_CASE("past end") { |  | ||||||
|     std::string content = "foo"; |     std::string content = "foo"; | ||||||
|     int offset = GetOffsetForPosition(lsPosition(10, 10), content); |     int offset = GetOffsetForPosition(lsPosition(10, 10), content); | ||||||
|     REQUIRE(offset <= content.size()); |     REQUIRE(offset <= content.size()); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("in middle of content") { |   TEST_CASE("in middle of content") { | ||||||
|     std::string content = "abcdefghijk"; |     std::string content = "abcdefghijk"; | ||||||
|     for (int i = 0; i < content.size(); ++i) { |     for (int i = 0; i < content.size(); ++i) { | ||||||
|       int offset = GetOffsetForPosition(lsPosition(0, i), content); |       int offset = GetOffsetForPosition(lsPosition(0, i), content); | ||||||
|       REQUIRE(i == offset); |       REQUIRE(i == offset); | ||||||
|     } |     } | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("at end of content") { |   TEST_CASE("at end of content") { | ||||||
|     REQUIRE(GetOffsetForPosition(lsPosition(0, 0), "") == 0); |     REQUIRE(GetOffsetForPosition(lsPosition(0, 0), "") == 0); | ||||||
|     REQUIRE(GetOffsetForPosition(lsPosition(0, 1), "a") == 1); |     REQUIRE(GetOffsetForPosition(lsPosition(0, 1), "a") == 1); | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_SUITE_END(); | TEST_SUITE("Substring") { | ||||||
| 
 |   TEST_CASE("match") { | ||||||
| TEST_SUITE("Substring"); |  | ||||||
| 
 |  | ||||||
| TEST_CASE("match") { |  | ||||||
|     // Sanity.
 |     // Sanity.
 | ||||||
|     REQUIRE(SubstringMatch("a", "aa")); |     REQUIRE(SubstringMatch("a", "aa")); | ||||||
|     REQUIRE(SubstringMatch("aa", "aa")); |     REQUIRE(SubstringMatch("aa", "aa")); | ||||||
| @ -266,6 +263,5 @@ TEST_CASE("match") { | |||||||
| 
 | 
 | ||||||
|     // Ordering.
 |     // Ordering.
 | ||||||
|     REQUIRE(!SubstringMatch("ad", "dcba")); |     REQUIRE(!SubstringMatch("ad", "dcba")); | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 |  | ||||||
| TEST_SUITE_END(); |  | ||||||
| @ -76,9 +76,8 @@ bool GroupMatch::IsMatch(const std::string& value, | |||||||
|   return true; |   return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_SUITE("Matcher"); | TEST_SUITE("Matcher") { | ||||||
| 
 |   TEST_CASE("sanity") { | ||||||
| TEST_CASE("sanity") { |  | ||||||
|     // Matcher m("abc");
 |     // Matcher m("abc");
 | ||||||
|     // TODO: check case
 |     // TODO: check case
 | ||||||
|     // CHECK(m.IsMatch("abc"));
 |     // CHECK(m.IsMatch("abc"));
 | ||||||
| @ -86,6 +85,5 @@ TEST_CASE("sanity") { | |||||||
|     // CHECK(m.IsMatch("abc"));
 |     // CHECK(m.IsMatch("abc"));
 | ||||||
|     // CHECK(m.IsMatch("abcfoo"));
 |     // CHECK(m.IsMatch("abcfoo"));
 | ||||||
|     // CHECK(m.IsMatch("11a11b11c11"));
 |     // CHECK(m.IsMatch("11a11b11c11"));
 | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 |  | ||||||
| TEST_SUITE_END(); |  | ||||||
|  | |||||||
| @ -87,15 +87,14 @@ void MakeDirectoryRecursive(std::string path) { | |||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_SUITE("Platform"); | TEST_SUITE("Platform") { | ||||||
| 
 |   TEST_CASE("Split strings") { | ||||||
| TEST_CASE("Split strings") { |  | ||||||
|     std::vector<std::string> actual = Split("/a/b/c/", '/'); |     std::vector<std::string> actual = Split("/a/b/c/", '/'); | ||||||
|     std::vector<std::string> expected{"a", "b", "c"}; |     std::vector<std::string> expected{"a", "b", "c"}; | ||||||
|     REQUIRE(actual == expected); |     REQUIRE(actual == expected); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("Mutex lock/unlock (single process)") { |   TEST_CASE("Mutex lock/unlock (single process)") { | ||||||
|     auto m1 = CreatePlatformMutex("indexer-platformmutexttest"); |     auto m1 = CreatePlatformMutex("indexer-platformmutexttest"); | ||||||
|     auto l1 = CreatePlatformScopedMutexLock(m1.get()); |     auto l1 = CreatePlatformScopedMutexLock(m1.get()); | ||||||
|     auto m2 = CreatePlatformMutex("indexer-platformmutexttest"); |     auto m2 = CreatePlatformMutex("indexer-platformmutexttest"); | ||||||
| @ -121,6 +120,5 @@ TEST_CASE("Mutex lock/unlock (single process)") { | |||||||
|     l1.reset(); |     l1.reset(); | ||||||
|     t.join(); |     t.join(); | ||||||
|     REQUIRE(value == 1); |     REQUIRE(value == 1); | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 |  | ||||||
| TEST_SUITE_END(); |  | ||||||
|  | |||||||
| @ -411,9 +411,8 @@ void Project::ForAllFilteredFiles( | |||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_SUITE("Project"); | TEST_SUITE("Project") { | ||||||
| 
 |   void CheckFlags(const std::string& directory, | ||||||
| void CheckFlags(const std::string& directory, |  | ||||||
|                   const std::string& file, |                   const std::string& file, | ||||||
|                   std::vector<std::string> raw, |                   std::vector<std::string> raw, | ||||||
|                   std::vector<std::string> expected) { |                   std::vector<std::string> expected) { | ||||||
| @ -443,14 +442,14 @@ void CheckFlags(const std::string& directory, | |||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     REQUIRE(result.args == expected); |     REQUIRE(result.args == expected); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| void CheckFlags(std::vector<std::string> raw, |   void CheckFlags(std::vector<std::string> raw, | ||||||
|                   std::vector<std::string> expected) { |                   std::vector<std::string> expected) { | ||||||
|     CheckFlags("/dir/", "file.cc", raw, expected); |     CheckFlags("/dir/", "file.cc", raw, expected); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("strip meta-compiler invocations") { |   TEST_CASE("strip meta-compiler invocations") { | ||||||
|     CheckFlags( |     CheckFlags( | ||||||
|         /* raw */ {"clang", "-lstdc++", "myfile.cc"}, |         /* raw */ {"clang", "-lstdc++", "myfile.cc"}, | ||||||
|         /* expected */ {"clang", "-lstdc++", "myfile.cc", "-xc++", "-std=c++11", |         /* expected */ {"clang", "-lstdc++", "myfile.cc", "-xc++", "-std=c++11", | ||||||
| @ -463,11 +462,11 @@ TEST_CASE("strip meta-compiler invocations") { | |||||||
|     CheckFlags(/* raw */ {"goma", "clang", "--foo"}, |     CheckFlags(/* raw */ {"goma", "clang", "--foo"}, | ||||||
|               /* expected */ {"clang", "--foo", "-xc++", "-std=c++11", |               /* expected */ {"clang", "--foo", "-xc++", "-std=c++11", | ||||||
|                               "-resource-dir=/w/resource_dir/"}); |                               "-resource-dir=/w/resource_dir/"}); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| // Checks flag parsing for a random chromium file in comparison to what
 |   // Checks flag parsing for a random chromium file in comparison to what
 | ||||||
| // YouCompleteMe fetches.
 |   // YouCompleteMe fetches.
 | ||||||
| TEST_CASE("ycm") { |   TEST_CASE("ycm") { | ||||||
|     CheckFlags( |     CheckFlags( | ||||||
|         "/w/c/s/out/Release", "../../ash/login/lock_screen_sanity_unittest.cc", |         "/w/c/s/out/Release", "../../ash/login/lock_screen_sanity_unittest.cc", | ||||||
| 
 | 
 | ||||||
| @ -807,10 +806,10 @@ TEST_CASE("ycm") { | |||||||
|         "-fvisibility-inlines-hidden", |         "-fvisibility-inlines-hidden", | ||||||
|         "-xc++", |         "-xc++", | ||||||
|         "-resource-dir=/w/resource_dir/"}); |         "-resource-dir=/w/resource_dir/"}); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| // Checks flag parsing for an example chromium file.
 |   // Checks flag parsing for an example chromium file.
 | ||||||
| TEST_CASE("chromium") { |   TEST_CASE("chromium") { | ||||||
|     CheckFlags( |     CheckFlags( | ||||||
|         "/w/c/s/out/Release", "../../apps/app_lifetime_monitor.cc", |         "/w/c/s/out/Release", "../../apps/app_lifetime_monitor.cc", | ||||||
|         /* raw */ |         /* raw */ | ||||||
| @ -1125,9 +1124,9 @@ TEST_CASE("chromium") { | |||||||
|         "-fvisibility-inlines-hidden", |         "-fvisibility-inlines-hidden", | ||||||
|         "-xc++", |         "-xc++", | ||||||
|         "-resource-dir=/w/resource_dir/"}); |         "-resource-dir=/w/resource_dir/"}); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("Directory extraction") { |   TEST_CASE("Directory extraction") { | ||||||
|     ProjectConfig config; |     ProjectConfig config; | ||||||
|     config.project_dir = "/w/c/s/"; |     config.project_dir = "/w/c/s/"; | ||||||
| 
 | 
 | ||||||
| @ -1167,9 +1166,9 @@ TEST_CASE("Directory extraction") { | |||||||
|         "&/base/q_relative2"}; |         "&/base/q_relative2"}; | ||||||
|     REQUIRE(config.angle_dirs == angle_expected); |     REQUIRE(config.angle_dirs == angle_expected); | ||||||
|     REQUIRE(config.quote_dirs == quote_expected); |     REQUIRE(config.quote_dirs == quote_expected); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("Entry inference") { |   TEST_CASE("Entry inference") { | ||||||
|     Project p; |     Project p; | ||||||
|     { |     { | ||||||
|       Project::Entry e; |       Project::Entry e; | ||||||
| @ -1207,9 +1206,9 @@ TEST_CASE("Entry inference") { | |||||||
|       REQUIRE(entry.has_value()); |       REQUIRE(entry.has_value()); | ||||||
|       REQUIRE(entry->args == std::vector<std::string>{"arg2"}); |       REQUIRE(entry->args == std::vector<std::string>{"arg2"}); | ||||||
|     } |     } | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("Entry inference prefers same file endings") { |   TEST_CASE("Entry inference prefers same file endings") { | ||||||
|     Project p; |     Project p; | ||||||
|     { |     { | ||||||
|       Project::Entry e; |       Project::Entry e; | ||||||
| @ -1263,6 +1262,5 @@ TEST_CASE("Entry inference prefers same file endings") { | |||||||
|       REQUIRE(entry.has_value()); |       REQUIRE(entry.has_value()); | ||||||
|       REQUIRE(entry->args == std::vector<std::string>{"arg3"}); |       REQUIRE(entry->args == std::vector<std::string>{"arg3"}); | ||||||
|     } |     } | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 |  | ||||||
| TEST_SUITE_END(); |  | ||||||
|  | |||||||
							
								
								
									
										28
									
								
								src/query.cc
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								src/query.cc
									
									
									
									
									
								
							| @ -823,17 +823,16 @@ void QueryDatabase::UpdateDetailedNames(size_t* qualified_name_index, | |||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_SUITE("query"); | TEST_SUITE("query") { | ||||||
| 
 |   IndexUpdate GetDelta(IndexFile previous, IndexFile current) { | ||||||
| IndexUpdate GetDelta(IndexFile previous, IndexFile current) { |  | ||||||
|     QueryDatabase db; |     QueryDatabase db; | ||||||
|     IdMap previous_map(&db, previous.id_cache); |     IdMap previous_map(&db, previous.id_cache); | ||||||
|     IdMap current_map(&db, current.id_cache); |     IdMap current_map(&db, current.id_cache); | ||||||
|     return IndexUpdate::CreateDelta(&previous_map, ¤t_map, &previous, |     return IndexUpdate::CreateDelta(&previous_map, ¤t_map, &previous, | ||||||
|                                     ¤t); |                                     ¤t); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("remove defs") { |   TEST_CASE("remove defs") { | ||||||
|     IndexFile previous("foo.cc"); |     IndexFile previous("foo.cc"); | ||||||
|     IndexFile current("foo.cc"); |     IndexFile current("foo.cc"); | ||||||
| 
 | 
 | ||||||
| @ -849,9 +848,9 @@ TEST_CASE("remove defs") { | |||||||
|     REQUIRE(update.types_removed == std::vector<Usr>{"usr1"}); |     REQUIRE(update.types_removed == std::vector<Usr>{"usr1"}); | ||||||
|     REQUIRE(update.funcs_removed == std::vector<Usr>{"usr2"}); |     REQUIRE(update.funcs_removed == std::vector<Usr>{"usr2"}); | ||||||
|     REQUIRE(update.vars_removed == std::vector<Usr>{"usr3"}); |     REQUIRE(update.vars_removed == std::vector<Usr>{"usr3"}); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("do not remove ref-only defs") { |   TEST_CASE("do not remove ref-only defs") { | ||||||
|     IndexFile previous("foo.cc"); |     IndexFile previous("foo.cc"); | ||||||
|     IndexFile current("foo.cc"); |     IndexFile current("foo.cc"); | ||||||
| 
 | 
 | ||||||
| @ -868,9 +867,9 @@ TEST_CASE("do not remove ref-only defs") { | |||||||
|     REQUIRE(update.types_removed == std::vector<Usr>{}); |     REQUIRE(update.types_removed == std::vector<Usr>{}); | ||||||
|     REQUIRE(update.funcs_removed == std::vector<Usr>{}); |     REQUIRE(update.funcs_removed == std::vector<Usr>{}); | ||||||
|     REQUIRE(update.vars_removed == std::vector<Usr>{}); |     REQUIRE(update.vars_removed == std::vector<Usr>{}); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("func callers") { |   TEST_CASE("func callers") { | ||||||
|     IndexFile previous("foo.cc"); |     IndexFile previous("foo.cc"); | ||||||
|     IndexFile current("foo.cc"); |     IndexFile current("foo.cc"); | ||||||
| 
 | 
 | ||||||
| @ -892,9 +891,9 @@ TEST_CASE("func callers") { | |||||||
|             Range(Position(1, 0))); |             Range(Position(1, 0))); | ||||||
|     REQUIRE(update.funcs_callers[0].to_add.size() == 1); |     REQUIRE(update.funcs_callers[0].to_add.size() == 1); | ||||||
|     REQUIRE(update.funcs_callers[0].to_add[0].loc.range == Range(Position(2, 0))); |     REQUIRE(update.funcs_callers[0].to_add[0].loc.range == Range(Position(2, 0))); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("type usages") { |   TEST_CASE("type usages") { | ||||||
|     IndexFile previous("foo.cc"); |     IndexFile previous("foo.cc"); | ||||||
|     IndexFile current("foo.cc"); |     IndexFile current("foo.cc"); | ||||||
| 
 | 
 | ||||||
| @ -913,9 +912,9 @@ TEST_CASE("type usages") { | |||||||
|     REQUIRE(update.types_uses[0].to_remove[0].range == Range(Position(1, 0))); |     REQUIRE(update.types_uses[0].to_remove[0].range == Range(Position(1, 0))); | ||||||
|     REQUIRE(update.types_uses[0].to_add.size() == 1); |     REQUIRE(update.types_uses[0].to_add.size() == 1); | ||||||
|     REQUIRE(update.types_uses[0].to_add[0].range == Range(Position(2, 0))); |     REQUIRE(update.types_uses[0].to_add[0].range == Range(Position(2, 0))); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("apply delta") { |   TEST_CASE("apply delta") { | ||||||
|     IndexFile previous("foo.cc"); |     IndexFile previous("foo.cc"); | ||||||
|     IndexFile current("foo.cc"); |     IndexFile current("foo.cc"); | ||||||
| 
 | 
 | ||||||
| @ -949,6 +948,5 @@ TEST_CASE("apply delta") { | |||||||
|     REQUIRE(db.funcs[0].callers.size() == 2); |     REQUIRE(db.funcs[0].callers.size() == 2); | ||||||
|     REQUIRE(db.funcs[0].callers[0].loc.range == Range(Position(4, 0))); |     REQUIRE(db.funcs[0].callers[0].loc.range == Range(Position(4, 0))); | ||||||
|     REQUIRE(db.funcs[0].callers[1].loc.range == Range(Position(5, 0))); |     REQUIRE(db.funcs[0].callers[1].loc.range == Range(Position(5, 0))); | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 |  | ||||||
| TEST_SUITE_END(); |  | ||||||
| @ -379,15 +379,14 @@ std::vector<CXUnsavedFile> WorkingFiles::AsUnsavedFiles() { | |||||||
|   return result; |   return result; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_SUITE("WorkingFile"); |  | ||||||
| 
 |  | ||||||
| lsPosition CharPos(const WorkingFile& file, | lsPosition CharPos(const WorkingFile& file, | ||||||
|                   char character, |                   char character, | ||||||
|                   int character_offset = 0) { |                   int character_offset = 0) { | ||||||
|   return CharPos(file.buffer_content, character, character_offset); |   return CharPos(file.buffer_content, character, character_offset); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("simple call") { | TEST_SUITE("WorkingFile") { | ||||||
|  |   TEST_CASE("simple call") { | ||||||
|     WorkingFile f("foo.cc", "abcd(1, 2"); |     WorkingFile f("foo.cc", "abcd(1, 2"); | ||||||
|     int active_param = 0; |     int active_param = 0; | ||||||
|     REQUIRE(f.FindClosestCallNameInBuffer(CharPos(f, '('), &active_param) == |     REQUIRE(f.FindClosestCallNameInBuffer(CharPos(f, '('), &active_param) == | ||||||
| @ -405,9 +404,9 @@ TEST_CASE("simple call") { | |||||||
|     REQUIRE(f.FindClosestCallNameInBuffer(CharPos(f, '2'), &active_param) == |     REQUIRE(f.FindClosestCallNameInBuffer(CharPos(f, '2'), &active_param) == | ||||||
|             "abcd"); |             "abcd"); | ||||||
|     REQUIRE(active_param == 1); |     REQUIRE(active_param == 1); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("nested call") { |   TEST_CASE("nested call") { | ||||||
|     WorkingFile f("foo.cc", "abcd(efg(), 2"); |     WorkingFile f("foo.cc", "abcd(efg(), 2"); | ||||||
|     int active_param = 0; |     int active_param = 0; | ||||||
|     REQUIRE(f.FindClosestCallNameInBuffer(CharPos(f, '('), &active_param) == |     REQUIRE(f.FindClosestCallNameInBuffer(CharPos(f, '('), &active_param) == | ||||||
| @ -434,17 +433,17 @@ TEST_CASE("nested call") { | |||||||
|     REQUIRE(f.FindClosestCallNameInBuffer(CharPos(f, ' '), &active_param) == |     REQUIRE(f.FindClosestCallNameInBuffer(CharPos(f, ' '), &active_param) == | ||||||
|             "abcd"); |             "abcd"); | ||||||
|     REQUIRE(active_param == 1); |     REQUIRE(active_param == 1); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("auto-insert )") { |   TEST_CASE("auto-insert )") { | ||||||
|     WorkingFile f("foo.cc", "abc()"); |     WorkingFile f("foo.cc", "abc()"); | ||||||
|     int active_param = 0; |     int active_param = 0; | ||||||
|     REQUIRE(f.FindClosestCallNameInBuffer(CharPos(f, ')'), &active_param) == |     REQUIRE(f.FindClosestCallNameInBuffer(CharPos(f, ')'), &active_param) == | ||||||
|             "abc"); |             "abc"); | ||||||
|     REQUIRE(active_param == 0); |     REQUIRE(active_param == 0); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("existing completion") { |   TEST_CASE("existing completion") { | ||||||
|     WorkingFile f("foo.cc", "zzz.asdf"); |     WorkingFile f("foo.cc", "zzz.asdf"); | ||||||
|     bool is_global_completion; |     bool is_global_completion; | ||||||
|     std::string existing_completion; |     std::string existing_completion; | ||||||
| @ -464,9 +463,9 @@ TEST_CASE("existing completion") { | |||||||
|     f.FindStableCompletionSource(CharPos(f, 'f', 1), &is_global_completion, |     f.FindStableCompletionSource(CharPos(f, 'f', 1), &is_global_completion, | ||||||
|                                 &existing_completion); |                                 &existing_completion); | ||||||
|     REQUIRE(existing_completion == "asdf"); |     REQUIRE(existing_completion == "asdf"); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| TEST_CASE("existing completion underscore") { |   TEST_CASE("existing completion underscore") { | ||||||
|     WorkingFile f("foo.cc", "ABC_DEF"); |     WorkingFile f("foo.cc", "ABC_DEF"); | ||||||
|     bool is_global_completion; |     bool is_global_completion; | ||||||
|     std::string existing_completion; |     std::string existing_completion; | ||||||
| @ -480,6 +479,5 @@ TEST_CASE("existing completion underscore") { | |||||||
|     f.FindStableCompletionSource(CharPos(f, 'D'), &is_global_completion, |     f.FindStableCompletionSource(CharPos(f, 'D'), &is_global_completion, | ||||||
|                                 &existing_completion); |                                 &existing_completion); | ||||||
|     REQUIRE(existing_completion == "ABC_"); |     REQUIRE(existing_completion == "ABC_"); | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 |  | ||||||
| TEST_SUITE_END(); |  | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								third_party/doctest
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										2
									
								
								third_party/doctest
									
									
									
									
										vendored
									
									
								
							| @ -1 +1 @@ | |||||||
| Subproject commit 11147357234d0166c9ec96c4d9e328464b884da3 | Subproject commit 79a379827251cd819c5286070834ccd0ac628af9 | ||||||
							
								
								
									
										2
									
								
								third_party/loguru
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										2
									
								
								third_party/loguru
									
									
									
									
										vendored
									
									
								
							| @ -1 +1 @@ | |||||||
| Subproject commit ac23215b4b9e878dfe5c2fd3d4afbf7a63cdad12 | Subproject commit 83b6f3c3d16e40453ec0d12d3baef42cd2f37c3b | ||||||
							
								
								
									
										2
									
								
								third_party/rapidjson
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										2
									
								
								third_party/rapidjson
									
									
									
									
										vendored
									
									
								
							| @ -1 +1 @@ | |||||||
| Subproject commit 0163a53f4a1c72e6a05848a63d80eee0d8e3f387 | Subproject commit 17ae6ffa857173c25708e61610121bc908c0a6cd | ||||||
							
								
								
									
										2
									
								
								third_party/sparsepp
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										2
									
								
								third_party/sparsepp
									
									
									
									
										vendored
									
									
								
							| @ -1 +1 @@ | |||||||
| Subproject commit b1d54fbe547cab3a13d181f16f1de758d6827f81 | Subproject commit bfb0de71ee7fa12a5f12c3ef61ce9f1d6d86d907 | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user