1 //===-- flang/unittests/Runtime/Ragged.cpp ----------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "flang/Runtime/ragged.h"
10 #include "gtest/gtest.h"
12 using namespace Fortran::runtime
;
14 TEST(Ragged
, RaggedArrayAllocateDeallocateTest
) {
15 struct RaggedArrayHeader header
;
17 int64_t *extents
= new int64_t[2];
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);
30 _FortranARaggedArrayDeallocate(ret
);
31 EXPECT_EQ(0u, ret
->flags
);