Browse Source

Fix remaining test warnings (#1001)

* Use portable way to encode ESC

'\e' is a GNU extension

* Use length specifier for size_t
Gregor Jasny 4 years ago
parent
commit
9f2064a8ed
1 changed files with 3 additions and 3 deletions
  1. 3 3
      test/test.cc

+ 3 - 3
test/test.cc

@@ -3293,14 +3293,14 @@ TEST(ServerRequestParsingTest, TrimWhitespaceFromHeaderValues) {
   // Only space and horizontal tab are whitespace. Make sure other whitespace-
   // Only space and horizontal tab are whitespace. Make sure other whitespace-
   // like characters are not treated the same - use vertical tab and escape.
   // like characters are not treated the same - use vertical tab and escape.
   const std::string req = "GET /validate-ws-in-headers HTTP/1.1\r\n"
   const std::string req = "GET /validate-ws-in-headers HTTP/1.1\r\n"
-                          "foo: \t \v bar \e\t \r\n"
+                          "foo: \t \v bar \x1B\t \r\n"
                           "Connection: close\r\n"
                           "Connection: close\r\n"
                           "\r\n";
                           "\r\n";
 
 
   ASSERT_TRUE(send_request(5, req));
   ASSERT_TRUE(send_request(5, req));
   svr.stop();
   svr.stop();
   t.join();
   t.join();
-  EXPECT_EQ(header_value, "\v bar \e");
+  EXPECT_EQ(header_value, "\v bar \x1B");
 }
 }
 
 
 // Sends a raw request and verifies that there isn't a crash or exception.
 // Sends a raw request and verifies that there isn't a crash or exception.
@@ -3452,7 +3452,7 @@ TEST(ServerStopTest, StopServerWithChunkedTransmission) {
     res.set_chunked_content_provider("text/event-stream", [](size_t offset,
     res.set_chunked_content_provider("text/event-stream", [](size_t offset,
                                                              DataSink &sink) {
                                                              DataSink &sink) {
       char buffer[27];
       char buffer[27];
-      auto size = static_cast<size_t>(sprintf(buffer, "data:%ld\n\n", offset));
+      auto size = static_cast<size_t>(sprintf(buffer, "data:%zd\n\n", offset));
       auto ret = sink.write(buffer, size);
       auto ret = sink.write(buffer, size);
       EXPECT_TRUE(ret);
       EXPECT_TRUE(ret);
       std::this_thread::sleep_for(std::chrono::seconds(1));
       std::this_thread::sleep_for(std::chrono::seconds(1));