| 1 | //===-- unittests/Runtime/Ragged.cpp ----------------------------*- C++ -*-===// |
| 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 "flang/Runtime/ragged.h" |
| 10 | #include "gtest/gtest.h" |
| 11 | |
| 12 | using namespace Fortran::runtime; |
| 13 | |
| 14 | TEST(Ragged, RaggedArrayAllocateDeallocateTest) { |
| 15 | struct ; |
| 16 | unsigned rank = 2; |
| 17 | int64_t *extents = reinterpret_cast<int64_t *>(malloc(size: 2 * sizeof(int64_t))); |
| 18 | extents[0] = 10; |
| 19 | extents[1] = 100; |
| 20 | RaggedArrayHeader *ret = (RaggedArrayHeader *)_FortranARaggedArrayAllocate( |
| 21 | &header, false, rank, 32, extents); |
| 22 | EXPECT_TRUE(ret != nullptr); |
| 23 | EXPECT_TRUE(ret->bufferPointer != nullptr); |
| 24 | EXPECT_EQ(extents, ret->extentPointer); |
| 25 | EXPECT_EQ(10, ret->extentPointer[0]); |
| 26 | EXPECT_EQ(100, ret->extentPointer[1]); |
| 27 | EXPECT_EQ(rank, ret->flags >> 1); |
| 28 | EXPECT_FALSE(ret->flags & 1); |
| 29 | |
| 30 | _FortranARaggedArrayDeallocate(ret); |
| 31 | EXPECT_EQ(0u, ret->flags); |
| 32 | } |
| 33 | |