From 119c4fdd9365e387c9c989d8d68f8f3c82ebdc5a Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Wed, 7 Jan 2015 15:05:38 -0800 Subject: [PATCH] win: various porting for http_body_test.cc - Wrap constants in FILE_PATH_LITERAL for L"". - dynamic allocation, as VS otherwise complains about lack of constant expression: d:\src\crashpad\crashpad\util\net\http_body_test.cc(182) : error C2057: expected constant expression d:\src\crashpad\crashpad\util\net\http_body_test.cc(182) : error C2466: cannot allocate an array of constant size 0 d:\src\crashpad\crashpad\util\net\http_body_test.cc(182) : error C2133: 'buf' : unknown size d:\src\crashpad\crashpad\util\net\http_body_test.cc(183) : error C2070: 'uint8_t []': illegal sizeof operand d:\src\crashpad\crashpad\util\net\http_body_test.cc(196) : error C2070: 'uint8_t []': illegal sizeof operand R=mark@chromium.org BUG=crashpad:1 Review URL: https://codereview.chromium.org/837293002 --- util/net/http_body_test.cc | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/util/net/http_body_test.cc b/util/net/http_body_test.cc index c59b6d6b..8dbd5a10 100644 --- a/util/net/http_body_test.cc +++ b/util/net/http_body_test.cc @@ -14,7 +14,6 @@ #include "util/net/http_body.h" -#include "base/memory/scoped_ptr.h" #include "gtest/gtest.h" #include "util/net/http_body_test_util.h" @@ -96,7 +95,8 @@ TEST(StringHTTPBodyStream, MultipleReads) { TEST(FileHTTPBodyStream, ReadASCIIFile) { // TODO(rsesek): Use a more robust mechanism to locate testdata // . - base::FilePath path = base::FilePath("util/net/testdata/ascii_http_body.txt"); + base::FilePath path = base::FilePath( + FILE_PATH_LITERAL("util/net/testdata/ascii_http_body.txt")); FileHTTPBodyStream stream(path); std::string contents = ReadStreamToString(&stream, 32); EXPECT_EQ("This is a test.\n", contents); @@ -115,8 +115,8 @@ TEST(FileHTTPBodyStream, ReadBinaryFile) { // HEX contents of file: |FEEDFACE A11A15|. // TODO(rsesek): Use a more robust mechanism to locate testdata // . - base::FilePath path = - base::FilePath("util/net/testdata/binary_http_body.dat"); + base::FilePath path = base::FilePath( + FILE_PATH_LITERAL("util/net/testdata/binary_http_body.dat")); // This buffer size was chosen so that reading the file takes multiple reads. uint8_t buf[4]; @@ -144,8 +144,8 @@ TEST(FileHTTPBodyStream, ReadBinaryFile) { } TEST(FileHTTPBodyStream, NonExistentFile) { - base::FilePath path = - base::FilePath("/var/empty/crashpad/util/net/http_body/null"); + base::FilePath path = base::FilePath( + FILE_PATH_LITERAL("/var/empty/crashpad/util/net/http_body/null")); FileHTTPBodyStream stream(path); uint8_t buf = 0xff; @@ -176,10 +176,9 @@ TEST_P(CompositeHTTPBodyStreamBufferSize, ThreeStringParts) { std::string string1("crashpad"); std::string string2("test"); std::string string3("foobar"); - const size_t all_strings_length = string1.length() + string2.length() + - string3.length(); - uint8_t buf[all_strings_length + 3]; - memset(buf, '!', sizeof(buf)); + const size_t all_strings_length = + string1.length() + string2.length() + string3.length(); + std::string buf(all_strings_length + 3, '!'); std::vector parts; parts.push_back(new StringHTTPBodyStream(string1)); @@ -191,8 +190,7 @@ TEST_P(CompositeHTTPBodyStreamBufferSize, ThreeStringParts) { std::string actual_string = ReadStreamToString(&stream, GetParam()); EXPECT_EQ(string1 + string2 + string3, actual_string); - ExpectBufferSet(buf + all_strings_length, '!', - sizeof(buf) - all_strings_length); + ExpectBufferSet(reinterpret_cast(&buf[all_strings_length]), '!', 3); } TEST_P(CompositeHTTPBodyStreamBufferSize, StringsAndFile) { @@ -201,8 +199,8 @@ TEST_P(CompositeHTTPBodyStreamBufferSize, StringsAndFile) { std::vector parts; parts.push_back(new StringHTTPBodyStream(string1)); - parts.push_back(new FileHTTPBodyStream( - base::FilePath("util/net/testdata/ascii_http_body.txt"))); + parts.push_back(new FileHTTPBodyStream(base::FilePath( + FILE_PATH_LITERAL("util/net/testdata/ascii_http_body.txt")))); parts.push_back(new StringHTTPBodyStream(string2)); CompositeHTTPBodyStream stream(parts);