1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:17:44 +00:00

CppLanguageServer: Add test case for auto-completing include paths

This commit is contained in:
Itamar 2021-05-22 12:28:52 +03:00 committed by Andreas Kling
parent b9021f8631
commit 6738a966ec
3 changed files with 35 additions and 0 deletions

View file

@ -41,6 +41,7 @@ static void test_complete_local_args();
static void test_complete_local_vars();
static void test_complete_type();
static void test_find_variable_definition();
static void test_complete_includes();
int run_tests()
{
@ -48,6 +49,7 @@ int run_tests()
test_complete_local_vars();
test_complete_type();
test_find_variable_definition();
test_complete_includes();
return s_some_test_failed ? 1 : 0;
}
@ -120,3 +122,28 @@ void test_find_variable_definition()
PASS;
FAIL("wrong declaration location");
}
void test_complete_includes()
{
I_TEST(Complete Type)
FileDB filedb;
filedb.set_project_root(TESTS_ROOT_DIR);
add_file(filedb, "complete_includes.cpp");
add_file(filedb, "sample_header.h");
CppComprehensionEngine autocomplete(filedb);
auto suggestions = autocomplete.get_suggestions("complete_includes.cpp", { 0, 23 });
if (suggestions.size() != 1)
FAIL(project include - bad size);
if (suggestions[0].completion != "sample_header.h")
FAIL("project include - wrong results");
suggestions = autocomplete.get_suggestions("complete_includes.cpp", { 1, 19 });
if (suggestions.size() != 1)
FAIL(global include - bad size);
if (suggestions[0].completion != "cdefs.h")
FAIL("global include - wrong results");
PASS;
}