Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
TestLinearOffsetMap.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7
8#include <gtest/gtest.h>
9
10#include "arcane/utils/LinearOffsetMap.h"
11
12/*---------------------------------------------------------------------------*/
13/*---------------------------------------------------------------------------*/
14
15using namespace Arcane;
16
17TEST(TestLinearOffsetMap, Misc)
18{
19 {
22 ASSERT_EQ(v1.size(), 0);
23 }
24 {
26 v2.add(25, 4);
28 ASSERT_EQ(v2.getAndRemoveOffset(20), 4);
29 ASSERT_EQ(v2.getAndRemoveOffset(5), 24);
30 ASSERT_EQ(v2.size(), 0);
31 }
32
33 {
35 v3.add(25, 4);
36 v3.add(25, 30);
37 ASSERT_EQ(v3.getAndRemoveOffset(18), 4);
38 ASSERT_EQ(v3.getAndRemoveOffset(25), 30);
39 ASSERT_EQ(v3.size(), 1);
40 ASSERT_EQ(v3.getAndRemoveOffset(4), 22);
41 ASSERT_EQ(v3.size(), 1);
42 ASSERT_EQ(v3.getAndRemoveOffset(3), 26);
43 ASSERT_EQ(v3.size(), 0);
44 }
45}
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
#define ASSERT_TRUE(condition)
Checks that condition is true.
Definition Assertion.h:128
List of linear offsets.
void add(DataType size, DataType offset)
Adds an offset offset of size size.
Int32 size() const
Number of elements in the table.
DataType getAndRemoveOffset(DataType size)
Retrieves a sufficient offset for an element of size size.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --