Arcane  4.2.3.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
TestArrayCommon.h
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#ifndef TEST_ARCCORE_COLLECTIONS_TESTARRAYCOMMON_H
8#define TEST_ARCCORE_COLLECTIONS_TESTARRAYCOMMON_H
9/*---------------------------------------------------------------------------*/
10/*---------------------------------------------------------------------------*/
11
13
14#include <gtest/gtest.h>
15
16#include <iostream>
17
18/*---------------------------------------------------------------------------*/
19/*---------------------------------------------------------------------------*/
20
21namespace TestArccore
22{
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27using namespace Arccore;
28class IntSubClass
29{
30 public:
31
32 IntSubClass(Integer v)
33 : m_v(v)
34 {}
35 IntSubClass() = default;
36
37 friend bool operator==(const IntSubClass& v, Integer iv) { return v.m_v == iv; }
38 friend bool operator==(const IntSubClass& v1, const IntSubClass& v2) { return v1.m_v == v2.m_v; }
39 friend bool operator!=(const IntSubClass& v1, const IntSubClass& v2) { return v1.m_v != v2.m_v; }
40 friend std::ostream& operator<<(std::ostream& o, const IntSubClass& c)
41 {
42 o << c.m_v;
43 return o;
44 }
45 Integer value() const { return m_v; }
46 Integer m_v = 0;
47};
48
49class IntSubClassNoPod
50{
51 public:
52
53 IntSubClassNoPod() = default;
54 explicit IntSubClassNoPod(Integer v)
55 : m_v(v)
56 {}
57 //IntSubClassNoPod() : m_v(0) {}
58 Integer m_v = 0;
59 friend bool operator==(const IntSubClassNoPod& v, Integer iv) { return v.m_v == iv; }
60 //friend bool operator==(const IntSubClassNoPod& v1,const IntSubClassNoPod& v2) { return v1.m_v==v2.m_v; }
61 friend bool operator!=(const IntSubClassNoPod& v1, const IntSubClassNoPod& v2) { return v1.m_v != v2.m_v; }
62 friend std::ostream& operator<<(std::ostream& o, IntSubClassNoPod c)
63 {
64 o << c.m_v;
65 return o;
66 }
67};
68} // namespace TestArccore
69namespace Arccore
70{
71ARCCORE_DEFINE_ARRAY_PODTYPE(TestArccore::IntSubClass);
72}
73
74/*---------------------------------------------------------------------------*/
75/*---------------------------------------------------------------------------*/
76
77#define ARCCORE_UT_CHECK(expr,message) \
78if ( ! (expr) )\
79 throw Arccore::FatalErrorException((message))
80
81namespace TestArccore
82{
83class IntPtrSubClass
84{
85 public:
86
87 static Integer count;
88 IntPtrSubClass(Integer v)
89 : m_v(new Integer(v))
90 {
91 ++count;
92 }
93 IntPtrSubClass()
94 : m_v(new Integer(0))
95 {
96 ++count;
97 }
98 ~IntPtrSubClass()
99 {
100 --count;
101 delete m_v;
102 }
103 Integer* m_v;
104 IntPtrSubClass(const IntPtrSubClass& v)
105 : m_v(new Integer(*v.m_v))
106 {
107 ++count;
108 }
109 void operator=(const IntPtrSubClass& v)
110 {
111 Integer* n = new Integer(*v.m_v);
112 delete m_v;
113 m_v = n;
114 }
115 bool operator==(Integer iv) const
116 {
117 //cout << "** COMPARE: " << *m_v << " v=" << iv << '\n';
118 return *m_v == iv;
119 }
120};
121
122/*---------------------------------------------------------------------------*/
123/*---------------------------------------------------------------------------*/
124
125template <typename T> inline
126void _checkSameInfoArray2(const Array2<T>& a, const Array2<T>& b)
127{
128 ASSERT_EQ(a.allocator(), b.allocator());
129 ASSERT_EQ(a.totalNbElement(), b.totalNbElement());
130 ASSERT_EQ(a.dim1Size(), b.dim1Size());
131 ASSERT_EQ(a.dim2Size(), b.dim2Size());
132}
133
134/*---------------------------------------------------------------------------*/
135/*---------------------------------------------------------------------------*/
136
137} // namespace TestArccore
138
139/*---------------------------------------------------------------------------*/
140/*---------------------------------------------------------------------------*/
141
142#endif
Définitions et globaux de Arccore.
Tableau 2D d'items de types quelconques.
Integer totalNbElement() const
Nombre total d'éléments (dim1Size()*dim2Size()).
Int32 Integer
Type représentant un entier.
Espace de nom de Arccore.