-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
95 lines (61 loc) · 2.86 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
specific - A small BDD-style unit test framework for C++.
Inspired by various ruby frameworks such as rspec, I wanted something
similiar for various C++ projects, so specific was born.
Usage
Add spec.h, spec.cpp, main.cpp and all your *_spec.cpp files to
your "spec project", and you should get an executable test/specification
out of it.
The *_spec.cpp files have syntax this syntax:
#include "spec.h"
describe(GroupName, "context description") {
it("example description") {
should_be_equal(1, 2);
}
it("should throw") {
std::vector<int> v;
v.push_back(1);
should_throw( v.at(999), std::out_of_range );
}
}
should_be_equal uses std::string specific::inspect(const T& val)
for displaying the value of object in error messages. By default it
uses the standard stream interface, so if you have operator<< defined for
std::ostream and your class you are set. Alternatively, you can
template-specialize the inspect function if want to massage the
representation to be Specific-specific. You can also disable values in
error messages by defining SPECIFIC_NO_OSTREAM before including spec.h,
the variable names are used instead.
The default main.cpp takes -s argument if you want the output in
"specdoc" format instead of the default "progress" format. Also you can
give any string which will be matched as a substring to the
describe-group, only those will be run.
Reference
describe(group, description)
This macro describes a "context" for tests. Group is used to group
similiar tests together, usually class name or similiar. While Group
is without quotes, it used used only as a string by macromagic,
so it doesn't have to be anything "real".
it(description)
This macro describes an example, a block of code that tests the
proposition described in the description, given the context.
should_be_true( expr )
Assertation that tests that the expression yields is true
should_be_false( expr )
Assertation thtat tests that the expression yields is false
should_be_equal( expr1, expr2 )
Asserts that the expressions yields equal value
should_not_be_equal( expr1, expr2 )
Asserts that the expressions yields inequal value
should_throw( expr, exceptionClass )
Asserts that the expression throws the given exception
Links
rspec - http://rspec.info/
Original inspiration
cppspec - http://www.laughingpanda.org/projects/cppspec/
Another C++ implementation. I disliked how it emphasis on
the postfix .should notation that seemed forced in C++,
but tries to keep C++ class/method, while it still resorts
to macro trickery.
License
The zlib/libpng license. See LICENSE
This work is supported by Secret Exit Ltd.