Skip to content

Commit 96b896b

Browse files
committed
add a unittest
1 parent 8dc9c3b commit 96b896b

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

lldb/unittests/Core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ add_lldb_unittest(LLDBCoreTests
1515
SourceManagerTest.cpp
1616
TelemetryTest.cpp
1717
UniqueCStringMapTest.cpp
18+
Value.cpp
1819

1920
LINK_COMPONENTS
2021
Support

lldb/unittests/Core/Value.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//===----------------------------------------------------------------------===//
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 "lldb/Core/Value.h"
10+
#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
11+
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
12+
#include "TestingSupport/SubsystemRAII.h"
13+
#include "TestingSupport/Symbol/ClangTestUtils.h"
14+
15+
#include "lldb/Utility/DataExtractor.h"
16+
17+
#include "gtest/gtest.h"
18+
19+
using namespace lldb_private;
20+
using namespace lldb_private::clang_utils;
21+
22+
TEST(ValueTest, GetValueAsData) {
23+
SubsystemRAII<FileSystem, HostInfo, PlatformMacOSX> subsystems;
24+
auto holder = std::make_unique<clang_utils::TypeSystemClangHolder>("test");
25+
auto *clang = holder->GetAST();
26+
27+
Value v(Scalar(42));
28+
DataExtractor extractor;
29+
30+
// no compiler type
31+
Status status = v.GetValueAsData(nullptr, extractor, nullptr);
32+
ASSERT_TRUE(status.Fail());
33+
34+
// with compiler type
35+
v.SetCompilerType(clang->GetBasicType(lldb::BasicType::eBasicTypeChar));
36+
37+
status = v.GetValueAsData(nullptr, extractor, nullptr);
38+
ASSERT_TRUE(status.Success());
39+
}

0 commit comments

Comments
 (0)