================ @@ -0,0 +1,268 @@ +//===-- 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 "gtest/gtest.h" + +using namespace llvm; +using namespace lldb; +using namespace lldb_dap; +using namespace lldb_dap::protocol; + +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::json::Value value = toJSON(filter); + const json::Object *obj = value.getAsObject(); + ASSERT_NE(obj, nullptr); + + EXPECT_EQ(obj->getString("filter"), "testFilter"); + EXPECT_EQ(obj->getString("label"), "Test Filter"); + EXPECT_EQ(obj->getString("description"), "This is a test filter"); + EXPECT_EQ(obj->getBoolean("default"), true); + EXPECT_EQ(obj->getBoolean("supportsCondition"), true); + EXPECT_EQ(obj->getString("conditionDescription"), + "Condition for test filter"); +} + +TEST(ProtocolTypesTest, ColumnDescriptor) { + ColumnDescriptor column; + column.attributeName = "testAttribute"; + column.label = "Test Label"; + column.format = "testFormat"; + column.type = eColumnTypeString; + column.width = 20; + + llvm::json::Value value = toJSON(column); + const json::Object *obj = value.getAsObject(); + ASSERT_NE(obj, nullptr); + + EXPECT_EQ(obj->getString("attributeName"), "testAttribute"); + EXPECT_EQ(obj->getString("label"), "Test Label"); + EXPECT_EQ(obj->getString("format"), "testFormat"); + EXPECT_EQ(obj->getString("type"), "string"); + EXPECT_EQ(obj->getInteger("width"), 20); +} + +TEST(ProtocolTypesTest, BreakpointMode) { + BreakpointMode mode; + mode.mode = "testMode"; + mode.label = "Test Label"; + mode.description = "This is a test description"; + mode.appliesTo = {eBreakpointModeApplicabilitySource, + eBreakpointModeApplicabilityException}; + + llvm::json::Value value = toJSON(mode); + const json::Object *obj = value.getAsObject(); + ASSERT_NE(obj, nullptr); + + EXPECT_EQ(obj->getString("mode"), "testMode"); + EXPECT_EQ(obj->getString("label"), "Test Label"); + EXPECT_EQ(obj->getString("description"), "This is a test description"); + + const auto *appliesToArray = obj->getArray("appliesTo"); + ASSERT_NE(appliesToArray, nullptr); + ASSERT_EQ(appliesToArray->size(), 2UL); + EXPECT_EQ(appliesToArray->front().getAsString(), "source"); + EXPECT_EQ(appliesToArray->back().getAsString(), "exception"); +} + +TEST(ProtocolTypesTest, Capabilities) { + Capabilities capabilities; + capabilities.supportedFeatures = {eAdapterFeatureANSIStyling, + eAdapterFeatureTerminateRequest}; + capabilities.exceptionBreakpointFilters = { + {"filter1", "Filter 1", "Description 1", true, true, "Condition 1"}, + {"filter2", "Filter 2", "Description 2", false, false, "Condition 2"}}; + capabilities.completionTriggerCharacters = {"."}; + capabilities.additionalModuleColumns = { + {"attribute1", "Label 1", "Format 1", eColumnTypeString, 10}, + {"attribute2", "Label 2", "Format 2", eColumnTypeNumber, 20}}; + capabilities.supportedChecksumAlgorithms = {eChecksumAlgorithmMD5, + eChecksumAlgorithmSHA256}; + capabilities.breakpointModes = {{"mode1", + "Mode 1", + "Description 1", + {eBreakpointModeApplicabilitySource}}, + {"mode2", + "Mode 2", + "Description 2", + {eBreakpointModeApplicabilityException}}}; + capabilities.lldbExtVersion = "1.0.0"; + + llvm::json::Value value = toJSON(capabilities); + const json::Object *obj = value.getAsObject(); + ASSERT_NE(obj, nullptr); + + // Verify supported features. + EXPECT_EQ(obj->getBoolean("supportsANSIStyling"), true); + EXPECT_EQ(obj->getBoolean("supportsTerminateRequest"), true); + + // Verify exception breakpoint filters. + const auto *filtersArray = obj->getArray("exceptionBreakpointFilters"); + ASSERT_NE(filtersArray, nullptr); + ASSERT_EQ(filtersArray->size(), 2UL); + const auto *filter1 = filtersArray->front().getAsObject(); ---------------- da-viper wrote:
was referring to the auto in the function. 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