Move lldb-dap's Transport class into lldb_private so the code can be shared between the "JSON with header" protocol used by DAP and the JSON RPC protocol used by MCP (see [1]). [1]: https://discourse.llvm.org/t/rfc-adding-mcp-support-to-lldb/86798
40 lines
1.2 KiB
C++
40 lines
1.2 KiB
C++
//===-- DAPTest.cpp -------------------------------------------------------===//
|
|
//
|
|
// 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 "DAP.h"
|
|
#include "Protocol/ProtocolBase.h"
|
|
#include "TestBase.h"
|
|
#include "Transport.h"
|
|
#include "llvm/Testing/Support/Error.h"
|
|
#include "gtest/gtest.h"
|
|
#include <chrono>
|
|
#include <memory>
|
|
#include <optional>
|
|
|
|
using namespace llvm;
|
|
using namespace lldb;
|
|
using namespace lldb_dap;
|
|
using namespace lldb_dap_tests;
|
|
using namespace lldb_dap::protocol;
|
|
|
|
class DAPTest : public TransportBase {};
|
|
|
|
TEST_F(DAPTest, SendProtocolMessages) {
|
|
DAP dap{
|
|
/*log=*/nullptr,
|
|
/*default_repl_mode=*/ReplMode::Auto,
|
|
/*pre_init_commands=*/{},
|
|
/*transport=*/*to_dap,
|
|
};
|
|
dap.Send(Event{/*event=*/"my-event", /*body=*/std::nullopt});
|
|
ASSERT_THAT_EXPECTED(
|
|
from_dap->Read<protocol::Message>(std::chrono::milliseconds(1)),
|
|
HasValue(testing::VariantWith<Event>(testing::FieldsAre(
|
|
/*event=*/"my-event", /*body=*/std::nullopt))));
|
|
}
|