================ @@ -56,40 +84,88 @@ bool fromJSON(const llvm::json::Value &V, JSONTestType &T, llvm::json::Path P) { } // namespace TEST_F(HTTPDelimitedJSONTransportTest, MalformedRequests) { - std::string malformed_header = "COnTent-LenGth: -1{}\r\n\r\nnotjosn"; + std::string malformed_header = + "COnTent-LenGth: -1\r\nContent-Type: text/json\r\n\r\nnotjosn"; ASSERT_THAT_EXPECTED( input.Write(malformed_header.data(), malformed_header.size()), Succeeded()); - ASSERT_THAT_EXPECTED( - transport->Read<JSONTestType>(std::chrono::milliseconds(1)), - FailedWithMessage( - "expected 'Content-Length: ' and got 'COnTent-LenGth: '")); + RunOnce<JSONTestType>([&](llvm::Expected<JSONTestType> message) { + ASSERT_THAT_EXPECTED(message, + FailedWithMessage("invalid content length: -1")); + }); } TEST_F(HTTPDelimitedJSONTransportTest, Read) { std::string json = R"json({"str": "foo"})json"; + std::string message = + formatv("Content-Length: {0}\r\nContent-type: text/json\r\n\r\n{1}", + json.size(), json) + .str(); + ASSERT_THAT_EXPECTED(input.Write(message.data(), message.size()), + Succeeded()); + RunOnce<JSONTestType>([&](llvm::Expected<JSONTestType> message) { + ASSERT_THAT_EXPECTED(message, HasValue(testing::FieldsAre(/*str=*/"foo"))); + }); ---------------- labath wrote:
```suggestion ASSERT_THAT_EXPECTED(RunOnce<JSONTestType>(), HasValue(testing::FieldsAre(/*str=*/"foo"))); ``` i.e., make the function return the result instead of invoking a callback. It's shorter, and the ASSERT macros are not completely effective (they don't terminate the rest of the test) when not at top level. https://github.com/llvm/llvm-project/pull/148300 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits