@@ -854,62 +854,62 @@ TEST_SUITE("xutils_handler"){
854854}
855855#endif
856856
857- // TEST_SUITE("complete_request")
858- // {
859- // TEST_CASE("completion_test")
860- // {
861- // #if defined(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
862- // std::vector<const char*> Args = {
863- // "-v",
864- // "-Xclang", "-iwithsysroot/include/compat"
865- // };
866- // #else
867- // std::vector<const char*> Args = {/*"-v", "resource-dir", "....."*/};
868- // #endif
869- // xcpp::interpreter interpreter((int)Args.size(), Args.data());
870- // std::string code1 = "#include <iostream>";
871- // nl::json user_expressions = nl::json::object();
872- // xeus::execute_request_config config;
873- // config.silent = false;
874- // config.store_history = false;
875- // config.allow_stdin = false;
876- // nl::json header = nl::json::object();
877- // xeus::xrequest_context::guid_list id = {};
878- // xeus::xrequest_context context(header, id);
857+ TEST_SUITE (" complete_request" )
858+ {
859+ TEST_CASE (" completion_test" )
860+ {
861+ #if defined(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
862+ std::vector<const char *> Args = {
863+ " -v" ,
864+ " -Xclang" , " -iwithsysroot/include/compat"
865+ };
866+ #else
867+ std::vector<const char *> Args = {/* "-v", "resource-dir", "....."*/ };
868+ #endif
869+ xcpp::interpreter interpreter ((int )Args.size (), Args.data ());
870+ std::string code1 = " #include <iostream>" ;
871+ nl::json user_expressions = nl::json::object ();
872+ xeus::execute_request_config config;
873+ config.silent = false ;
874+ config.store_history = false ;
875+ config.allow_stdin = false ;
876+ nl::json header = nl::json::object ();
877+ xeus::xrequest_context::guid_list id = {};
878+ xeus::xrequest_context context (header, id);
879879
880- // std::promise<nl::json> promise;
881- // std::future<nl::json> future = promise.get_future();
882- // auto callback = [&promise](nl::json result) {
883- // promise.set_value(result);
884- // };
880+ std::promise<nl::json> promise;
881+ std::future<nl::json> future = promise.get_future ();
882+ auto callback = [&promise](nl::json result) {
883+ promise.set_value (result);
884+ };
885885
886- // interpreter.execute_request(
887- // std::move(context),
888- // std::move(callback),
889- // code1,
890- // std::move(config),
891- // user_expressions
892- // );
893- // nl::json execute = future.get();
886+ interpreter.execute_request (
887+ std::move (context),
888+ std::move (callback),
889+ code1,
890+ std::move (config),
891+ user_expressions
892+ );
893+ nl::json execute = future.get ();
894894
895- // REQUIRE(execute["status"] == "ok");
895+ REQUIRE (execute[" status" ] == " ok" );
896896
897- // std::string code2 = "st";
898- // int cursor_pos = 2;
899- // nl::json result = interpreter.complete_request(code2, cursor_pos);
897+ std::string code2 = " st" ;
898+ int cursor_pos = 2 ;
899+ nl::json result = interpreter.complete_request (code2, cursor_pos);
900900
901- // REQUIRE(result["cursor_start"] == 0);
902- // REQUIRE(result["cursor_end"] == 2);
903- // REQUIRE(result["status"] == "ok");
904- // size_t found = 0;
905- // for (auto& r : result["matches"]) {
906- // if (r == "static" || r == "struct") {
907- // found++;
908- // }
909- // }
910- // REQUIRE(found == 2);
911- // }
912- // }
901+ REQUIRE (result[" cursor_start" ] == 0 );
902+ REQUIRE (result[" cursor_end" ] == 2 );
903+ REQUIRE (result[" status" ] == " ok" );
904+ size_t found = 0 ;
905+ for (auto & r : result[" matches" ]) {
906+ if (r == " static" || r == " struct" ) {
907+ found++;
908+ }
909+ }
910+ REQUIRE (found == 2 );
911+ }
912+ }
913913
914914TEST_SUITE (" xinspect" ){
915915 TEST_CASE (" class_member_predicate_get_filename" ){
0 commit comments