Make WebRequest::Get::Param unit test more forgiving

The simple test added in 59a8f26b01 (Add a unit test for wxWebRequest
query using URL parameters, 2021-03-06) worked when using httpbin.org,
but not when running httpbin locally, as it doesn't pretty-print JSON by
default.

Skip optional whitespace to make it work in both cases.
This commit is contained in:
Vadim Zeitlin
2021-03-06 14:44:56 +01:00
parent bf8be6c58d
commit 8d01aaf783

View File

@@ -223,8 +223,21 @@ TEST_CASE_METHOD(RequestFixture,
// We ought to really parse the returned JSON object, but to keep things as
// simple as possible for now we just treat it as a string.
CHECK_THAT( request.GetResponse().AsString().ToStdString(),
Catch::Contains("\"pi\": \"3.14159265358979323\"") );
const wxString& response = request.GetResponse().AsString();
INFO("Response: " << response);
const char* expectedKey = "\"pi\":";
size_t pos = response.find(expectedKey);
REQUIRE( pos != wxString::npos );
pos += strlen(expectedKey);
// There may, or not, be a space after it.
while ( wxIsspace(response[pos]) )
pos++;
const char* expectedValue = "\"3.14159265358979323\"";
REQUIRE( response.compare(pos, strlen(expectedValue), expectedValue) == 0 );
}
TEST_CASE_METHOD(RequestFixture,