mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-23 09:22:30 +00:00
CppLanguageServer: Add test for "get_parameters_hint"
This commit is contained in:
parent
f26f764c7d
commit
2af5bb9083
Notes:
sideshowbarker
2024-07-18 10:29:58 +09:00
Author: https://github.com/itamar8910
Commit: 2af5bb9083
Pull-request: https://github.com/SerenityOS/serenity/pull/8403
Reviewed-by: https://github.com/awesomekling
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_complete_type();
|
||||||
static void test_find_variable_definition();
|
static void test_find_variable_definition();
|
||||||
static void test_complete_includes();
|
static void test_complete_includes();
|
||||||
|
static void test_parameters_hint();
|
||||||
|
|
||||||
int run_tests()
|
int run_tests()
|
||||||
{
|
{
|
||||||
|
@ -50,6 +51,7 @@ int run_tests()
|
||||||
test_complete_type();
|
test_complete_type();
|
||||||
test_find_variable_definition();
|
test_find_variable_definition();
|
||||||
test_complete_includes();
|
test_complete_includes();
|
||||||
|
test_parameters_hint();
|
||||||
return s_some_test_failed ? 1 : 0;
|
return s_some_test_failed ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +124,7 @@ void test_find_variable_definition()
|
||||||
PASS;
|
PASS;
|
||||||
FAIL("wrong declaration location");
|
FAIL("wrong declaration location");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_complete_includes()
|
void test_complete_includes()
|
||||||
{
|
{
|
||||||
I_TEST(Complete Type)
|
I_TEST(Complete Type)
|
||||||
|
@ -147,3 +150,32 @@ void test_complete_includes()
|
||||||
|
|
||||||
PASS;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
void foo(int x, char y);
|
||||||
|
|
||||||
|
void bar()
|
||||||
|
{
|
||||||
|
foo();
|
||||||
|
foo(123, 'b');
|
||||||
|
foo(
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue