================ @@ -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); ---------------- JDevlieghere wrote:
That sounds appealing, but how would you get the second `json::Value`? If you write it by hand you're back to the original state of this PR, and if you serialize the deserialized object again, and you have a bug in your serializer, it wouldn't be caught, right? https://github.com/llvm/llvm-project/pull/139502 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits