AnCH Framework 0.1
Another C++ Hack Framework
 
Loading...
Searching...
No Matches
unit.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++11 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 <http://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include <string>
23#include <functional>
24#include <map>
25
26namespace anch::ut {
27
37 class UnitTests {
38
39 // Attrbutes +
40 private:
42 std::string _name;
43
45 std::string _description;
46
48 std::function<void(void)> _initFunc;
49
51 std::function<void(void)> _uninitFunc;
52
54 std::function<void(void)> _beforeFunc;
55
57 std::function<void(void)> _afterFunc;
58
60 std::map<std::string, std::function<void(void)>> _tests;
61 // Attrbutes -
62
63 // Constructors +
64 public:
69 // Constructors -
70
71 // Destructor +
72 public:
76 virtual ~UnitTests();
77 // Destructor -
78
79 // Methods +
80 public:
89 UnitTests& name(const std::string& name);
90
99 UnitTests& description(const std::string& description);
100
108 UnitTests& initialize(std::function<void(void)> initFunc);
109
117 UnitTests& uninitialize(std::function<void(void)> uninitFunc);
118
126 UnitTests& beforeTest(std::function<void(void)> beforeFunc);
127
135 UnitTests& afterTest(std::function<void(void)> afterFunc);
136
145 UnitTests& add(const std::string& name, std::function<void(void)> testFunc);
146
150 void initialize() const;
151
155 void uninitialize() const;
156
160 void before() const;
161
165 void after() const;
166 // Methods -
167
168 // Accessors +
174 const std::string& getName() const;
175
181 const std::string& getDescription() const;
182
188 const std::map<std::string, std::function<void(void)>>& getTests() const;
189
195 void setTests(const std::map<std::string, std::function<void(void)>>& tests);
196 // Accessors -
197
198 };
199
205 void setup(UnitTests& tests);
206
207} // anch::ut
208
209#include "ut/impl/unit.hpp"
Unit tests collection.
Definition unit.hpp:37
UnitTests & afterTest(std::function< void(void)> afterFunc)
void setTests(const std::map< std::string, std::function< void(void)> > &tests)
UnitTests & uninitialize(std::function< void(void)> uninitFunc)
void before() const
void after() const
const std::string & getDescription() const
UnitTests & name(const std::string &name)
const std::map< std::string, std::function< void(void)> > & getTests() const
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
void initialize() const
UnitTests & beforeTest(std::function< void(void)> beforeFunc)
void uninitialize() const