Skip to content

Commit 6f0768f

Browse files
committed
Add simple unit tests as an example
1 parent b0996a2 commit 6f0768f

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

lldb/tools/lldb-dap/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ set(LLVM_TARGET_DEFINITIONS Options.td)
55
tablegen(LLVM Options.inc -gen-opt-parser-defs)
66
add_public_tablegen_target(LLDBDAPOptionsTableGen)
77

8-
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
9-
include_directories(${CMAKE_CURRENT_BINARY_DIR})
10-
118
add_lldb_library(lldbDAP
129
Breakpoint.cpp
1310
BreakpointBase.cpp
@@ -79,6 +76,9 @@ add_lldb_library(lldbDAP
7976
Support
8077
)
8178

79+
target_include_directories(lldbDAP
80+
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR_DIR})
81+
8282
if(LLDB_DAP_WELCOME_MESSAGE)
8383
target_compile_definitions(lldbDAP
8484
PRIVATE

lldb/unittests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ endif()
5454
add_subdirectory(Breakpoint)
5555
add_subdirectory(Callback)
5656
add_subdirectory(Core)
57+
add_subdirectory(DAP)
5758
add_subdirectory(DataFormatter)
5859
add_subdirectory(Disassembler)
5960
add_subdirectory(Editline)

lldb/unittests/DAP/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
add_lldb_unittest(DAPTests
2+
JSONUtilsTest.cpp
3+
4+
LINK_LIBS
5+
lldbDAP
6+
LINK_COMPONENTS
7+
Support
8+
)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===-- JSONUtilsTest.cpp -------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "JSONUtils.h"
10+
#include "lldb/API/SBModule.h"
11+
#include "lldb/API/SBTarget.h"
12+
#include "gtest/gtest.h"
13+
14+
using namespace llvm;
15+
using namespace lldb;
16+
using namespace lldb_dap;
17+
18+
TEST(JSONUtilsTest, GetAsString) {
19+
StringRef str = "foo";
20+
json::Value value("foo");
21+
EXPECT_EQ(str, GetAsString(value));
22+
}
23+
24+
TEST(JSONUtilsTest, CreateModule) {
25+
SBTarget target;
26+
SBModule module;
27+
28+
json::Value value = CreateModule(target, module);
29+
json::Object *object = value.getAsObject();
30+
31+
ASSERT_NE(object, nullptr);
32+
EXPECT_EQ(object->size(), 0UL);
33+
}

0 commit comments

Comments
 (0)