TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Tests_Util.cpp
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifdef TESTS__
17int test_Ref()
18{
19 Cerr << "test_Ref" << finl;
20 DoubleVect x(5);
21 OBS_PTR(DoubleVect) xx; //Constructeur par defaut.
22 assert(!xx); // pointer not set
23 OBS_PTR(DoubleVect) yy(x); //Constructeur par const T&.
24 OBS_PTR(DoubleVect) zz(yy); //Constructeur par const T&.
25 xx=x; //Operateur = const T&.
26 xx=yy; //Operateur = const Deriv<T>&.
27 assert(xx->size() == x.size()); //Operateur ->
28 assert(yy->size() == zz->size()); //valeur()
29 assert(xx == yy); //Operateur ==
30 (static_cast<DoubleVect&>(xx))[2]=1; //cast
31 assert (xx == x); //Operateur !=
32 const Nom& name=xx.le_nom(); //le_nom()
33 return zz->operator bool();
34}
35
36
37/*! @brief
38 *
39 */
40int test_Deriv()
41{
42 Cerr << "test_Deriv" << finl;
43 DoubleVect x(5);
44 OWN_PTR(DoubleVect) xx; //Constructeur par defaut.
45 assert(!xx); // pointer not set
46 OWN_PTR(DoubleVect) yy(x); //Constructeur par const T&.
47 OWN_PTR(DoubleVect) zz(yy); //Constructeur par const T&.
48 xx=x; //Operateur = const T&.
49 xx=yy; //Operateur = const Deriv<T>&.
50 assert(xx->size() == x.size()); //Operateur ->
51 assert(yy->size() == zz->size()); //valeur()
52 assert(xx == yy); //Operateur ==
53 (static_cast<DoubleVect&>(xx))[2]=1; //cast
54 assert (xx != x); //Operateur !=
55 const Nom& name=xx.le_nom(); //le_nom()
56 return zz->operator bool();
57}
58
59
60/*! @brief
61 *
62 */
63int test_List()
64{
65 Cerr << "test_List" << finl;
66 LIST(Nom) la_liste;
67 la_liste.add("Chien");
68 la_liste.add("Chat");
69 la_liste.add("Chou");
70 Cerr << la_liste;
71 LIST(Nom) copie(la_liste);
72 Cerr << copie;
73 if(la_liste == copie)
74 Cerr << "The two lists are identical" << finl;
75 copie.add_if_not(Nom("Chien"));
76 copie.add_if_not(Nom("Chiens"));
77 copie["Chiens"]=Nom("Chats");
78 la_liste[2]="Choux";
79 Cerr << la_liste;
80 Cerr << copie;
81 if(la_liste != copie)
82 Cerr << "The two lists are different" << finl;
83 return 1;
84}
85
86
87/*! @brief
88 *
89 */
90int test_Vect()
91{
92 Cerr << "test_Vect" << finl;
93 DoubleVect x(5);
94 DoubleVects xx(2);
95 xx[1]=x;
96 assert( xx.search(x) == 1);
97 Motcles les_mots(3);
98 les_mots[0]=Motcle("Zero");
99 les_mots[1]=Motcle("Un");
100 les_mots[2]=Motcle("Deux");
101 assert( les_mots.contient(Motcle("Un")) );
102 assert( les_mots.search(Motcle("Deux")) == 2);
103 assert( les_mots.search(Motcle("Un")) == 1 );
104 assert( les_mots.search(Motcle("Zero")) == 0);
105 return 1;
106}
107
108
109/*! @brief
110 *
111 */
112int test_DoubleVect()
113{
114 Cerr << "test_DoubleVect" << finl;
115 return 1;
116}
117
118/*! @brief
119 *
120 */
121int test_IntVect()
122{
123 Cerr << "test_IntVect" << finl;
124 return 1;
125}
126#endif
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
Un tableau d'objets de la classe Motcle.
Definition Motcle.h:63
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
const Nom & le_nom() const override
Renvoie *this;.
Definition Nom.cpp:563