[NFC][Coroutines] Use structured binding with llvm::enumerate in CoroSplit (#116879)
[llvm-project.git] / lldb / unittests / Utility / DataBufferTest.cpp
blob548690354959e99dcf321a8947b8f29edec318f6
1 //===-- DataBufferTest.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 //===----------------------------------------------------------------------===//
9 #include "gtest/gtest.h"
11 #include "lldb/Utility/DataBuffer.h"
12 #include "lldb/Utility/DataBufferHeap.h"
13 #include "lldb/Utility/DataBufferLLVM.h"
15 #include "llvm/Support/Casting.h"
16 #include "llvm/Support/MemoryBuffer.h"
18 using namespace lldb_private;
19 using namespace lldb;
21 TEST(DataBufferTest, RTTI) {
23 DataBufferSP data_buffer_sp = std::make_shared<DataBufferHeap>();
24 DataBuffer *data_buffer = data_buffer_sp.get();
26 EXPECT_TRUE(llvm::isa<DataBuffer>(data_buffer));
27 EXPECT_TRUE(llvm::isa<WritableDataBuffer>(data_buffer));
28 EXPECT_TRUE(llvm::isa<DataBufferHeap>(data_buffer));
29 EXPECT_FALSE(llvm::isa<DataBufferLLVM>(data_buffer));
33 llvm::StringRef data;
34 DataBufferSP data_buffer_sp = std::make_shared<DataBufferLLVM>(
35 llvm::MemoryBuffer::getMemBufferCopy(data));
36 DataBuffer *data_buffer = data_buffer_sp.get();
38 EXPECT_TRUE(llvm::isa<DataBuffer>(data_buffer));
39 EXPECT_TRUE(llvm::isa<DataBufferLLVM>(data_buffer));
40 EXPECT_FALSE(llvm::isa<WritableDataBuffer>(data_buffer));
41 EXPECT_FALSE(llvm::isa<WritableDataBufferLLVM>(data_buffer));
42 EXPECT_FALSE(llvm::isa<DataBufferHeap>(data_buffer));
46 DataBufferSP data_buffer_sp = std::make_shared<WritableDataBufferLLVM>(
47 llvm::WritableMemoryBuffer::getNewMemBuffer(1));
48 DataBuffer *data_buffer = data_buffer_sp.get();
50 EXPECT_TRUE(llvm::isa<DataBuffer>(data_buffer));
51 EXPECT_TRUE(llvm::isa<WritableDataBuffer>(data_buffer));
52 EXPECT_TRUE(llvm::isa<WritableDataBufferLLVM>(data_buffer));
53 EXPECT_FALSE(llvm::isa<DataBufferLLVM>(data_buffer));
54 EXPECT_FALSE(llvm::isa<DataBufferHeap>(data_buffer));