spore_test_base.h
1 /*
2  * This file is part of SPORE.
3  *
4  * Copyright (C) 2016, the SPORE team (see AUTHORS).
5  *
6  * SPORE is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * SPORE is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with SPORE. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * For more information see: https://github.com/IGITUGraz/spore-nest-module
20  *
21  * File: spore_test_base.h
22  * Author: Kappel
23  *
24  * Created on November 9, 2016, 3:13 PM
25  */
26 
27 #ifndef SPORE_TEST_BASE_H
28 #define SPORE_TEST_BASE_H
29 
30 #include <string>
31 
32 #include "nest.h"
33 
34 #include "tracing_node.h"
35 
36 
37 namespace spore
38 {
39 
44 {
45 public:
46 
47  SporeTestBase(const std::string& name, nest::delay t_max = 1)
48  : name_(name), t_max_(t_max)
49  {
50  };
51 
52  virtual ~SporeTestBase()
53  {
54  };
55 
56  const std::string& get_name() const
57  {
58  return name_;
59  };
60 
61  nest::delay get_t_max() const
62  {
63  return t_max_;
64  };
65 
66  virtual void init()
67  {
68  };
69 
70  virtual void check(nest::delay time_step, TracingNode* node)
71  {
72  };
73 
74  virtual size_t get_num_traces() const
75  {
76  return 0;
77  };
78 
79  virtual double get_trace(nest::delay time_step, TracingNode::trace_id id)
80  {
81  assert(false);
82  };
83 
84  virtual void get_status(DictionaryDatum& d) const
85  {
86  };
87 
88  virtual void set_status(const DictionaryDatum& d)
89  {
90  };
91 
92 protected:
93 
94  void test_assert(bool condition, const std::string& msg)
95  {
96  if (!condition)
97  throw std::runtime_error(name_ + " failed: " + msg);
98  };
99 
100 private:
101  std::string name_;
102  nest::delay t_max_;
103 };
104 
105 }
106 
107 #endif
108 
Base class to all nodes that record traces.
Definition: tracing_node.h:52
Base class to all tests.
Definition: spore_test_base.h:43
Global namespace holding all classes of the SPORE NEST module.
Definition: circular_buffer.h:31