brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · d18a700 Raw
40 lines · cpp
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-exception6//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 19using namespace lldb_private;20using namespace lldb_private::clang_utils;21 22TEST(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 type31  Status status = v.GetValueAsData(nullptr, extractor, nullptr);32  ASSERT_TRUE(status.Fail());33 34  // with compiler type35  v.SetCompilerType(clang->GetBasicType(lldb::BasicType::eBasicTypeChar));36 37  status = v.GetValueAsData(nullptr, extractor, nullptr);38  ASSERT_TRUE(status.Success());39}40