llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Ebuka Ezike (da-viper) <details> <summary>Changes</summary> Add unittest for `DataBreakpointInfoArguments` --- Full diff: https://github.com/llvm/llvm-project/pull/162845.diff 2 Files Affected: - (modified) lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp (+1-1) - (modified) lldb/unittests/DAP/ProtocolTypesTest.cpp (+25) ``````````diff diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp index b455112cd37d9..b9393356b4e01 100644 --- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp +++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp @@ -461,7 +461,7 @@ bool fromJSON(const json::Value &Params, DataBreakpointInfoArguments &DBIA, json::Path P) { json::ObjectMapper O(Params, P); return O && O.map("variablesReference", DBIA.variablesReference) && - O.map("name", DBIA.name) && O.map("frameId", DBIA.frameId) && + O.map("name", DBIA.name) && O.mapOptional("frameId", DBIA.frameId) && O.map("bytes", DBIA.bytes) && O.map("asAddress", DBIA.asAddress) && O.map("mode", DBIA.mode); } diff --git a/lldb/unittests/DAP/ProtocolTypesTest.cpp b/lldb/unittests/DAP/ProtocolTypesTest.cpp index 0989a5becc8fe..44e96e1643d30 100644 --- a/lldb/unittests/DAP/ProtocolTypesTest.cpp +++ b/lldb/unittests/DAP/ProtocolTypesTest.cpp @@ -1101,3 +1101,28 @@ TEST(ProtocolTypesTest, MemoryEventBody) { })"; EXPECT_EQ(json, pp(body)); } + +TEST(ProtocolTypesTest, DataBreakpointInfoArguments) { + llvm::Expected<DataBreakpointInfoArguments> expected = + parse<DataBreakpointInfoArguments>(R"({ + "name": "data", + "variablesReference": 8, + "frameId": 9, + "bytes": 10, + "asAddress": false, + "mode": "source" + })"); + ASSERT_THAT_EXPECTED(expected, llvm::Succeeded()); + EXPECT_EQ(expected->name, "data"); + EXPECT_EQ(expected->variablesReference, 8); + EXPECT_EQ(expected->frameId, 9u); + EXPECT_EQ(expected->bytes, 10); + EXPECT_EQ(expected->asAddress, false); + EXPECT_EQ(expected->mode, "source"); + + // Check required keys. + EXPECT_THAT_EXPECTED(parse<DataBreakpointInfoArguments>(R"({})"), + FailedWithMessage("missing value at (root).name")); + EXPECT_THAT_EXPECTED(parse<DataBreakpointInfoArguments>(R"({"name":"data"})"), + llvm::Succeeded()); +} \ No newline at end of file `````````` </details> https://github.com/llvm/llvm-project/pull/162845 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
