Valentin Clement ad3bb7c7da
[flang] Simplify RaggedArrayHeader and make it plain C struct
- Join indirection and rank into a single value `flags`
- Make the struct a plain C struct.

Reviewed By: schweitz

Differential Revision: https://reviews.llvm.org/D115464
2021-12-09 22:28:06 +01:00

33 lines
1.1 KiB
C++

//===-- flang/unittests/Runtime/Ragged.cpp ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "flang/Runtime/ragged.h"
#include "gtest/gtest.h"
using namespace Fortran::runtime;
TEST(Ragged, RaggedArrayAllocateDeallocateTest) {
struct RaggedArrayHeader header;
unsigned rank = 2;
int64_t *extents = new int64_t[2];
extents[0] = 10;
extents[1] = 100;
RaggedArrayHeader *ret = (RaggedArrayHeader *)_FortranARaggedArrayAllocate(
&header, false, rank, 32, extents);
EXPECT_TRUE(ret != nullptr);
EXPECT_TRUE(ret->bufferPointer != nullptr);
EXPECT_EQ(extents, ret->extentPointer);
EXPECT_EQ(10, ret->extentPointer[0]);
EXPECT_EQ(100, ret->extentPointer[1]);
EXPECT_EQ(rank, ret->flags >> 1);
EXPECT_FALSE(ret->flags & 1);
_FortranARaggedArrayDeallocate(ret);
EXPECT_EQ(0u, ret->flags);
}