C++Spec 1.0.0
BDD testing for C++
Loading...
Searching...
No Matches
cppspec.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include "argparse.hpp"
9
10#ifndef CPPSPEC_MACROLESS
11/*>>>>>>>>>>>>>>>>>>>> MACROS <<<<<<<<<<<<<<<<<<<<<<*/
12
13// For *some* reason, MSVC++ refuses to correctly deduce the types of
14// Description blocks unless the void return type is explicitly stated.
15// GCC and clang have no problem with it being omitted. Weird.
16#define $ [](auto& self) -> void
17#define _ [=](auto& self) mutable -> void
18
19#define it self.it
20#define specify it
21
22// Apparently MSVC++ doesn't conform to C++14 14.2/4. Annoying.
23#define context self.context
24#define expect self.expect
25#define explain context // Piggybacks off of the `context` macro
26
27#define is_expected self.is_expected
28#define subject self.subject
29
30#define before_all self.before_all
31#define before_each self.before_each
32#define after_all self.after_all
33#define after_each self.after_each
34#define let(name, body) auto(name) = self.let(body);
35
36#ifdef CPPSPEC_SEMIHOSTED
37#define CPPSPEC_MAIN(spec) \
38 int main(int argc, char** const argv) { \
39 return CppSpec::parse(argc, argv).add_spec(spec).exec().is_success() ? EXIT_SUCCESS : EXIT_FAILURE; \
40 } \
41 extern "C" int _getentropy(void* buf, size_t buflen) { \
42 return -1; \
43 }
44
45#else
46#define CPPSPEC_MAIN(spec) \
47 int main(int argc, char** const argv) { \
48 return CppSpec::parse(argc, argv).add_spec(spec).exec().is_success() ? EXIT_SUCCESS : EXIT_FAILURE; \
49 }
50#endif
51
52#define CPPSPEC_SPEC(spec_name) \
53 int spec_name##_spec(int argc, char** const argv) { \
54 return CppSpec::parse(argc, argv).add_spec(spec_name).exec().is_success() ? EXIT_SUCCESS : EXIT_FAILURE; \
55 }
56
57#endif
58/*>>>>>>>>>>>>>>>>>>> TYPEDEFS <<<<<<<<<<<<<<<<<<<<<*/
59
60using describe = CppSpec::Description;
61
62template <class T>
63using describe_a = CppSpec::ClassDescription<T>;
64
65template <class T>
66using describe_an = CppSpec::ClassDescription<T>;
A Description with a defined subject.
Definition class_description.hpp:22
Definition description.hpp:20