Arcane  v3.14.10.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-2023 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
12#include "arccore/base/ArccoreGlobal.h"
13
14#include <gtest/gtest.h>
15
16#include <iostream>
17
18/*---------------------------------------------------------------------------*/
19/*---------------------------------------------------------------------------*/
20
21namespace TestArccore
22{
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27using namespace Arccore;
29{
30 public:
31
33 : m_v(v)
34 {}
35 IntSubClass() = default;
36 Integer m_v = 0;
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};
47{
48 public:
49
50 IntSubClassNoPod() = default;
51 explicit IntSubClassNoPod(Integer v)
52 : m_v(v)
53 {}
54 //IntSubClassNoPod() : m_v(0) {}
55 Integer m_v = 0;
56 friend bool operator==(const IntSubClassNoPod& v, Integer iv) { return v.m_v == iv; }
57 //friend bool operator==(const IntSubClassNoPod& v1,const IntSubClassNoPod& v2) { return v1.m_v==v2.m_v; }
58 friend bool operator!=(const IntSubClassNoPod& v1, const IntSubClassNoPod& v2) { return v1.m_v != v2.m_v; }
59 friend std::ostream& operator<<(std::ostream& o, IntSubClassNoPod c)
60 {
61 o << c.m_v;
62 return o;
63 }
64};
65} // namespace TestArccore
66namespace Arccore
67{
68ARCCORE_DEFINE_ARRAY_PODTYPE(TestArccore::IntSubClass);
69}
70
71/*---------------------------------------------------------------------------*/
72/*---------------------------------------------------------------------------*/
73
74#define ARCCORE_UT_CHECK(expr,message) \
75if ( ! (expr) )\
76 throw Arccore::FatalErrorException((message))
77
78namespace TestArccore
79{
81{
82 public:
83
84 static Integer count;
86 : m_v(new Integer(v))
87 {
88 ++count;
89 }
91 : m_v(new Integer(0))
92 {
93 ++count;
94 }
96 {
97 --count;
98 delete m_v;
99 }
100 Integer* m_v;
102 : m_v(new Integer(*v.m_v))
103 {
104 ++count;
105 }
106 void operator=(const IntPtrSubClass& v)
107 {
108 Integer* n = new Integer(*v.m_v);
109 delete m_v;
110 m_v = n;
111 }
112 bool operator==(Integer iv) const
113 {
114 //cout << "** COMPARE: " << *m_v << " v=" << iv << '\n';
115 return *m_v == iv;
116 }
117};
118
119/*---------------------------------------------------------------------------*/
120/*---------------------------------------------------------------------------*/
121
122template <typename T> inline
123void _checkSameInfoArray2(const Array2<T>& a, const Array2<T>& b)
124{
125 ASSERT_EQ(a.allocator(), b.allocator());
126 ASSERT_EQ(a.totalNbElement(), b.totalNbElement());
127 ASSERT_EQ(a.dim1Size(), b.dim1Size());
128 ASSERT_EQ(a.dim2Size(), b.dim2Size());
129}
130
131/*---------------------------------------------------------------------------*/
132/*---------------------------------------------------------------------------*/
133
134} // namespace TestArccore
135
136/*---------------------------------------------------------------------------*/
137/*---------------------------------------------------------------------------*/
138
139#endif
Classe représentant un tableau 2D classique.
Integer totalNbElement() const
Nombre total d'éléments (dim1Size()*dim2Size())
Espace de nom de Arccore.
Definition ArcaneTypes.h:24
Int32 Integer
Type représentant un entier.