AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
unit.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 standard
3 Copyright (C) 2020 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <https://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include "anch-ut-export.hpp"
23
24#include <string>
25#include <functional>
26#include <vector>
27#include <utility>
28
29namespace anch::ut {
30
40 class ANCH_UT_EXPORT UnitTests {
41
42 // Attrbutes +
43 private:
45 std::string _name;
46
48 std::string _description;
49
51 std::function<void(void)> _initFunc;
52
54 std::function<void(void)> _uninitFunc;
55
57 std::function<void(void)> _beforeFunc;
58
60 std::function<void(void)> _afterFunc;
61
63 std::vector<std::pair<std::string, std::function<void(void)>>> _tests;
64 // Attrbutes -
65
66 // Constructors +
67 public:
72 // Constructors -
73
74 // Destructor +
75 public:
79 virtual ~UnitTests();
80 // Destructor -
81
82 // Methods +
83 public:
92 UnitTests& name(const std::string& name);
93
102 UnitTests& description(const std::string& description);
103
111 UnitTests& initialize(std::function<void(void)> initFunc);
112
120 UnitTests& uninitialize(std::function<void(void)> uninitFunc);
121
129 UnitTests& beforeTest(std::function<void(void)> beforeFunc);
130
138 UnitTests& afterTest(std::function<void(void)> afterFunc);
139
150 UnitTests& add(const std::string& name, std::function<void(void)> testFunc);
151
155 void initialize() const;
156
160 void uninitialize() const;
161
165 void before() const;
166
170 void after() const;
171 // Methods -
172
173 // Accessors +
179 const std::string& getName() const;
180
186 const std::string& getDescription() const;
187
193 const std::vector<std::pair<std::string, std::function<void(void)>>>& getTests() const;
194
204 const std::function<void(void)>* find(const std::string& name) const;
205 // Accessors -
206
207 };
208
214 void setup(UnitTests& tests);
215
216} // anch::ut
217
218#include "ut/impl/unit.hpp"
Unit tests collection.
Definition unit.hpp:40
UnitTests & afterTest(std::function< void(void)> afterFunc)
const std::vector< std::pair< std::string, std::function< void(void)> > > & getTests() const
UnitTests & uninitialize(std::function< void(void)> uninitFunc)
void before() const
void after() const
const std::string & getDescription() const
UnitTests & name(const std::string &name)
UnitTests & add(const std::string &name, std::function< void(void)> testFunc)
UnitTests & initialize(std::function< void(void)> initFunc)
UnitTests & description(const std::string &description)
const std::string & getName() const
const std::function< void(void)> * find(const std::string &name) const
void initialize() const
UnitTests & beforeTest(std::function< void(void)> beforeFunc)
void uninitialize() const
AnCH unit tests library namespace.
Definition assert.hpp:37
void setup(UnitTests &tests)