1010#include < gmock/gmock.h>
1111#include < gtest/gtest.h>
1212#include < memory>
13+ #include < quick-lint-js/boost-json.h>
1314#include < quick-lint-js/byte-buffer.h>
1415#include < quick-lint-js/change-detecting-filesystem.h>
1516#include < quick-lint-js/char8.h>
@@ -964,7 +965,7 @@ TEST_F(test_linting_lsp_server, editing_config_relints_many_open_js_files) {
964965 EXPECT_EQ (look_up (notification, " method" ),
965966 " textDocument/publishDiagnostics" );
966967 std::string uri (
967- std::string_view (look_up (notification, " params" , " uri" ).get_string ()));
968+ to_string_view (look_up (notification, " params" , " uri" ).get_string ()));
968969 if (uri ==
969970 to_string (this ->fs .file_uri_prefix_8 () + u8" quick-lint-js.config" )) {
970971 // Ignore.
@@ -1084,7 +1085,7 @@ TEST_F(test_linting_lsp_server, editing_config_relints_only_affected_js_files) {
10841085 EXPECT_EQ (look_up (notification, " method" ),
10851086 " textDocument/publishDiagnostics" );
10861087 std::string uri (
1087- std::string_view (look_up (notification, " params" , " uri" ).get_string ()));
1088+ to_string_view (look_up (notification, " params" , " uri" ).get_string ()));
10881089 if (uri == to_string (this ->fs .file_uri_prefix_8 () +
10891090 u8" dir-a/quick-lint-js.config" ) ||
10901091 uri == to_string (this ->fs .file_uri_prefix_8 () +
@@ -1464,7 +1465,7 @@ TEST_F(test_linting_lsp_server, opening_js_file_with_unreadable_config_lints) {
14641465 EXPECT_EQ (look_up (showMessageMessage, " params" , " type" ),
14651466 lsp_warning_message_type);
14661467 EXPECT_EQ (look_up (showMessageMessage, " params" , " message" ),
1467- std::string_view (this ->config_file_load_error_message (
1468+ to_boost_string_view (this ->config_file_load_error_message (
14681469 " test.js" , " quick-lint-js.config" )));
14691470}
14701471
@@ -1522,11 +1523,11 @@ TEST_F(test_linting_lsp_server,
15221523 EXPECT_EQ (look_up (showMessageMessage, " method" ), " window/showMessage" );
15231524 EXPECT_EQ (look_up (showMessageMessage, " params" , " type" ),
15241525 lsp_warning_message_type);
1525- EXPECT_EQ (
1526- look_up (showMessageMessage, " params " , " message " ),
1527- std::string_view ( " Problems found in the config file for " s +
1528- this ->fs .rooted (" test.js" ).c_str () + " (" +
1529- this ->fs .rooted (" quick-lint-js.config" ).c_str () + " )." ));
1526+ EXPECT_EQ (look_up (showMessageMessage, " params " , " message " ),
1527+ to_boost_string_view (
1528+ " Problems found in the config file for " s +
1529+ this ->fs .rooted (" test.js" ).c_str () + " (" +
1530+ this ->fs .rooted (" quick-lint-js.config" ).c_str () + " )." ));
15301531}
15311532
15321533TEST_F (test_linting_lsp_server, making_config_file_unreadable_relints) {
@@ -1595,7 +1596,7 @@ TEST_F(test_linting_lsp_server, making_config_file_unreadable_relints) {
15951596 EXPECT_EQ (look_up (showMessageMessage, " params" , " type" ),
15961597 lsp_warning_message_type);
15971598 EXPECT_EQ (look_up (showMessageMessage, " params" , " message" ),
1598- std::string_view (this ->config_file_load_error_message (
1599+ to_boost_string_view (this ->config_file_load_error_message (
15991600 " test.js" , " quick-lint-js.config" )));
16001601}
16011602
@@ -1620,9 +1621,9 @@ TEST_F(test_linting_lsp_server, opening_broken_config_file_shows_diagnostics) {
16201621 EXPECT_EQ (response[" method" ], " textDocument/publishDiagnostics" );
16211622 EXPECT_FALSE (response.contains (" error" ));
16221623 // LSP PublishDiagnosticsParams:
1623- EXPECT_EQ (
1624- look_up (response, " params " , " uri " ),
1625- to_string_view ( this -> fs . file_uri_prefix_8 () + u8" quick-lint-js.config" ));
1624+ EXPECT_EQ (look_up (response, " params " , " uri " ),
1625+ to_boost_string_view ( this -> fs . file_uri_prefix_8 () +
1626+ u8" quick-lint-js.config" ));
16261627 EXPECT_EQ (look_up (response, " params" , " version" ), 1 );
16271628 ::boost::json::array diagnostics =
16281629 look_up (response, " params" , " diagnostics" ).as_array ();
@@ -1678,9 +1679,9 @@ TEST_F(test_linting_lsp_server,
16781679 EXPECT_EQ (response[" method" ], " textDocument/publishDiagnostics" );
16791680 EXPECT_FALSE (response.contains (" error" ));
16801681 // LSP PublishDiagnosticsParams:
1681- EXPECT_EQ (
1682- look_up (response, " params " , " uri " ),
1683- to_string_view ( this -> fs . file_uri_prefix_8 () + u8" quick-lint-js.config" ));
1682+ EXPECT_EQ (look_up (response, " params " , " uri " ),
1683+ to_boost_string_view ( this -> fs . file_uri_prefix_8 () +
1684+ u8" quick-lint-js.config" ));
16841685 EXPECT_EQ (look_up (response, " params" , " version" ), 2 );
16851686 ::boost::json::array diagnostics =
16861687 look_up (response, " params" , " diagnostics" ).as_array ();
@@ -1907,8 +1908,8 @@ TEST_F(test_linting_lsp_server, showing_io_errors_shows_only_first) {
19071908 EXPECT_EQ (look_up (show_message_message, " method" ), " window/showMessage" );
19081909 EXPECT_EQ (look_up (show_message_message, " params" , " type" ),
19091910 lsp_warning_message_type);
1910- std::string message (
1911- look_up (show_message_message, " params" , " message" ).as_string ());
1911+ std::string message (to_string_view (
1912+ look_up (show_message_message, " params" , " message" ).as_string ())) ;
19121913 EXPECT_THAT (message, ::testing::HasSubstr (" /banana" ));
19131914 EXPECT_THAT (message, ::testing::Not (::testing::HasSubstr (" orange" )));
19141915}
@@ -1932,8 +1933,8 @@ TEST_F(test_linting_lsp_server, showing_io_errors_shows_only_first_ever) {
19321933
19331934 ASSERT_EQ (this ->client ->messages .size (), 1 );
19341935 ::boost::json::value show_message_message = this ->client ->messages [0 ];
1935- std::string message (
1936- look_up (show_message_message, " params" , " message" ).as_string ());
1936+ std::string message (to_string_view (
1937+ look_up (show_message_message, " params" , " message" ).as_string ())) ;
19371938 EXPECT_THAT (message, ::testing::HasSubstr (" /banana" ));
19381939 EXPECT_THAT (message, ::testing::Not (::testing::HasSubstr (" orange" )));
19391940}
@@ -1943,7 +1944,8 @@ void expect_error(::boost::json::value& response, int error_code,
19431944 EXPECT_FALSE (response.as_object ().contains (" method" ));
19441945 EXPECT_EQ (look_up (response, " jsonrpc" ), " 2.0" );
19451946 EXPECT_EQ (look_up (response, " error" , " code" ), error_code);
1946- EXPECT_EQ (look_up (response, " error" , " message" ), error_message);
1947+ EXPECT_EQ (look_up (response, " error" , " message" ),
1948+ to_boost_string_view (error_message));
19471949}
19481950
19491951TEST_F (test_linting_lsp_server, invalid_json_in_request) {
0 commit comments