CEPS  24.01
Cardiac ElectroPhysiology Simulator
CepsGlobalFixture.hpp
Go to the documentation of this file.
1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2  This file is part of CEPS.
3 
4  CEPS is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  CEPS is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with CEPS (see file LICENSE at root of project).
16  If not, see <https://www.gnu.org/licenses/>.
17 
18 
19  Copyright 2019-2024 Inria, Universite de Bordeaux
20 
21  Authors, in alphabetical order:
22 
23  Pierre-Elliott BECUE, Florian CARO, Yves COUDIERE(*), Andjela DAVIDOVIC,
24  Charlie DOUANLA-LONTSI, Marc FUENTES, Mehdi JUHOOR, Michael LEGUEBE(*),
25  Pauline MIGERDITICHAN, Valentin PANNETIER(*), Nejib ZEMZEMI.
26  * : currently active authors
27 
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
30 #pragma once
31 
32 #ifdef CEPS_USE_CXXTEST
33 
34  #include <cxxtest/GlobalFixture.h>
35  #include <cxxtest/TestSuite.h>
36 
37  #include "common/core/CepsFlags.hpp"
41 
42 Flags *flags;
43 
44  #define TS_ASSERT_RUNS(...) TS_ASSERT_THROWS_NOTHING (__VA_ARGS__)
45  #define TS_ASSERT_STOPS(...) TS_ASSERT_THROWS_ANYTHING (__VA_ARGS__)
46 
48 class CepsGlobalFixture : public CxxTest::GlobalFixture
49 {
50  virtual CepsBool
51  setUpWorld ()
52  {
53  int argc = 5;
54  // Fake argv needed to cover all verbosity and warning lines
55  CepsChar **argv = new CepsChar*[argc];
56  argv[0] = new CepsChar[2];
57  argv[0][0] = 'a';
58  argv[0][1] = '\0';
59  argv[1] = new CepsChar[3];
60  argv[1][0] = '-';
61  argv[1][1] = 'v';
62  argv[1][2] = '\0';
63  argv[2] = new CepsChar[3];
64  argv[2][0] = '-';
65  argv[2][1] = 'w';
66  argv[2][2] = '\0';
67  argv[3] = new CepsChar[3];
68  argv[3][0] = 'n';
69  argv[3][1] = 'w';
70  argv[3][2] = '\0';
71  argv[4] = new CepsChar[3];
72  argv[4][0] = '-';
73  argv[4][1] = 'p';
74  argv[4][2] = '\0';
75  ceps::initialize (argc, argv);
76  flags->enableTesting ();
77  return true;
78  }
79 
80  virtual CepsBool
81  tearDownWorld()
82  {
83  return true;
84  }
85 };
86 
87 // Check if two files have the same contents
88 CepsBool checkSameContent(CepsString file1, CepsString file2)
89 {
90  std::ifstream f1(file1);
91  std::ifstream f2(file2);
92 
93  if (f1.fail() or f2.fail() or f1.tellg() != f2.tellg())
94  return false;
95 
96  f1.seekg(0,std::ifstream::beg);
97  f2.seekg(0,std::ifstream::beg);
98  return std::equal(std::istreambuf_iterator<char>(f1.rdbuf()),
99  std::istreambuf_iterator<char>(),
100  std::istreambuf_iterator<char>(f2.rdbuf()));
101 }
102 
103 static CepsGlobalFixture cepsInitialize;
104 
105 #endif
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
char CepsChar
Char.
Definition: CepsTypes.hpp:125
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
Flags * flags
Global variable, used in every application.
Definition: ceps.cpp:34
Management of run options.
Definition: CepsFlags.hpp:54
void enableTesting()
Enables testing (CepsException for errors do not cause abort)
Definition: CepsFlags.cpp:132
CepsUInt initialize(int argc, char *argv[])
Initializes parallel environment.