[Lldb-commits] [lldb] [lldb-dap] Add unit tests for protocol types (PR #139502)
John Harrison via lldb-commits
lldb-commits at lists.llvm.org
Mon May 12 13:16:44 PDT 2025
================
@@ -0,0 +1,62 @@
+//===-- ProtocolTypesTest.cpp -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "Protocol/ProtocolTypes.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+
+template <typename T> static llvm::Expected<T> roundtrip(const T &input) {
+ llvm::json::Value value = toJSON(input);
+ llvm::json::Path::Root root;
+ T output;
+ if (!fromJSON(value, output, root))
+ return root.getError();
+ return output;
+}
+
+TEST(ProtocolTypesTest, ExceptionBreakpointsFilter) {
+ ExceptionBreakpointsFilter filter;
+ filter.filter = "testFilter";
+ filter.label = "Test Filter";
+ filter.description = "This is a test filter";
+ filter.defaultState = true;
+ filter.supportsCondition = true;
+ filter.conditionDescription = "Condition for test filter";
+
+ llvm::Expected<ExceptionBreakpointsFilter> deserialized_filter =
+ roundtrip(filter);
+ ASSERT_THAT_EXPECTED(deserialized_filter, llvm::Succeeded());
+
+ EXPECT_EQ(filter.filter, deserialized_filter->filter);
+ EXPECT_EQ(filter.label, deserialized_filter->label);
+ EXPECT_EQ(filter.description, deserialized_filter->description);
+ EXPECT_EQ(filter.defaultState, deserialized_filter->defaultState);
+ EXPECT_EQ(filter.supportsCondition, deserialized_filter->supportsCondition);
+ EXPECT_EQ(filter.conditionDescription,
+ deserialized_filter->conditionDescription);
----------------
ashgti wrote:
Yea, your right
https://github.com/llvm/llvm-project/pull/139502
More information about the lldb-commits
mailing list