aboutsummaryrefslogtreecommitdiff
path: root/lldb/unittests/Core/Value.cpp
blob: d18a700c00ec07d23ce5c9a923139e796a128ff7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//===----------------------------------------------------------------------===//
//
// 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 "lldb/Core/Value.h"
#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "TestingSupport/SubsystemRAII.h"
#include "TestingSupport/Symbol/ClangTestUtils.h"

#include "lldb/Utility/DataExtractor.h"

#include "gtest/gtest.h"

using namespace lldb_private;
using namespace lldb_private::clang_utils;

TEST(ValueTest, GetValueAsData) {
  SubsystemRAII<FileSystem, HostInfo, PlatformMacOSX> subsystems;
  auto holder = std::make_unique<clang_utils::TypeSystemClangHolder>("test");
  auto *clang = holder->GetAST();

  Value v(Scalar(42));
  DataExtractor extractor;

  // no compiler type
  Status status = v.GetValueAsData(nullptr, extractor, nullptr);
  ASSERT_TRUE(status.Fail());

  // with compiler type
  v.SetCompilerType(clang->GetBasicType(lldb::BasicType::eBasicTypeChar));

  status = v.GetValueAsData(nullptr, extractor, nullptr);
  ASSERT_TRUE(status.Success());
}