mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
CppLanguageServer: Add test case for auto-completing include paths
This commit is contained in:
parent
b9021f8631
commit
6738a966ec
3 changed files with 35 additions and 0 deletions
|
@ -41,6 +41,7 @@ static void test_complete_local_args();
|
||||||
static void test_complete_local_vars();
|
static void test_complete_local_vars();
|
||||||
static void test_complete_type();
|
static void test_complete_type();
|
||||||
static void test_find_variable_definition();
|
static void test_find_variable_definition();
|
||||||
|
static void test_complete_includes();
|
||||||
|
|
||||||
int run_tests()
|
int run_tests()
|
||||||
{
|
{
|
||||||
|
@ -48,6 +49,7 @@ int run_tests()
|
||||||
test_complete_local_vars();
|
test_complete_local_vars();
|
||||||
test_complete_type();
|
test_complete_type();
|
||||||
test_find_variable_definition();
|
test_find_variable_definition();
|
||||||
|
test_complete_includes();
|
||||||
return s_some_test_failed ? 1 : 0;
|
return s_some_test_failed ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,3 +122,28 @@ void test_find_variable_definition()
|
||||||
PASS;
|
PASS;
|
||||||
FAIL("wrong declaration location");
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "sample_heade
|
||||||
|
#include <sys/cdef
|
||||||
|
|
||||||
|
void foo() {}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
int bar();
|
Loading…
Add table
Add a link
Reference in a new issue