Skip to content

Commit 33ad76a

Browse files
tharun571vgvassilev
authored andcommitted
Add test for xinterpreter
1 parent e4a86ec commit 33ad76a

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

test/test_interpreter.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,4 +645,32 @@ TEST_SUITE("xutils_handler"){
645645
}
646646
}
647647
}
648-
#endif
648+
#endif
649+
650+
TEST_SUITE("complete_request")
651+
{
652+
TEST_CASE("completion_test")
653+
{
654+
std::vector<const char*> Args = {/*"-v", "resource-dir", "....."*/};
655+
xcpp::interpreter interpreter((int)Args.size(), Args.data());
656+
657+
nl::json execute = interpreter.execute_request("#include <iostream>", false, false, nl::json::object(), false);
658+
659+
REQUIRE(execute["status"] == "ok");
660+
661+
std::string code = "st";
662+
int cursor_pos = 2;
663+
nl::json result = interpreter.complete_request(code, cursor_pos);
664+
665+
REQUIRE(result["cursor_start"] == 0);
666+
REQUIRE(result["cursor_end"] == 2);
667+
REQUIRE(result["status"] == "ok");
668+
size_t found = 0;
669+
for (auto& r : result["matches"]) {
670+
if (r == "static" || r == "struct") {
671+
found++;
672+
}
673+
}
674+
REQUIRE(found == 2);
675+
}
676+
}

0 commit comments

Comments
 (0)