|
| 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