mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:08:12 +00:00
CppLanguageServer: Add test for "get_parameters_hint"
This commit is contained in:
parent
f26f764c7d
commit
2af5bb9083
2 changed files with 40 additions and 0 deletions
|
@ -42,6 +42,7 @@ static void test_complete_local_vars();
|
|||
static void test_complete_type();
|
||||
static void test_find_variable_definition();
|
||||
static void test_complete_includes();
|
||||
static void test_parameters_hint();
|
||||
|
||||
int run_tests()
|
||||
{
|
||||
|
@ -50,6 +51,7 @@ int run_tests()
|
|||
test_complete_type();
|
||||
test_find_variable_definition();
|
||||
test_complete_includes();
|
||||
test_parameters_hint();
|
||||
return s_some_test_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
|
@ -122,6 +124,7 @@ void test_find_variable_definition()
|
|||
PASS;
|
||||
FAIL("wrong declaration location");
|
||||
}
|
||||
|
||||
void test_complete_includes()
|
||||
{
|
||||
I_TEST(Complete Type)
|
||||
|
@ -147,3 +150,32 @@ void test_complete_includes()
|
|||
|
||||
PASS;
|
||||
}
|
||||
|
||||
void test_parameters_hint()
|
||||
{
|
||||
I_TEST(Function Parameters hint)
|
||||
FileDB filedb;
|
||||
filedb.set_project_root(TESTS_ROOT_DIR);
|
||||
add_file(filedb, "parameters_hint1.cpp");
|
||||
CppComprehensionEngine engine(filedb);
|
||||
|
||||
auto result = engine.get_function_params_hint("parameters_hint1.cpp", { 4, 9 });
|
||||
if (!result.has_value())
|
||||
FAIL("failed to get parameters hint (1)");
|
||||
if (result->params != Vector<String> { "int x", "char y" } || result->current_index != 0)
|
||||
FAIL("bad result (1)");
|
||||
|
||||
result = engine.get_function_params_hint("parameters_hint1.cpp", { 5, 15 });
|
||||
if (!result.has_value())
|
||||
FAIL("failed to get parameters hint (2)");
|
||||
if (result->params != Vector<String> { "int x", "char y" } || result->current_index != 1)
|
||||
FAIL("bad result (2)");
|
||||
|
||||
result = engine.get_function_params_hint("parameters_hint1.cpp", { 6, 8 });
|
||||
if (!result.has_value())
|
||||
FAIL("failed to get parameters hint (3)");
|
||||
if (result->params != Vector<String> { "int x", "char y" } || result->current_index != 0)
|
||||
FAIL("bad result (3)");
|
||||
|
||||
PASS;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue