You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: gh-pages/index.md
+54-1Lines changed: 54 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,59 @@ layout: default
3
3
profile: true
4
4
---
5
5
6
-
C++Spec is a behavior-driven development library for C++ with an RSpec-inspired DSL.
6
+
C++Spec is a behavior-driven development library for C++ with an RSpec-inspired DSL. Designed with ease of use and rapid prototyping in mind, C++Spec offers an alternative to traditional testing libraries and frameworks. Some of the core concepts:
7
+
8
+
- A clean, readable syntax
9
+
- As few macros as possibles
10
+
- Use as a library, not a framework
11
+
- Easily extensible with custom matchers.
12
+
- Support for the RSpec and Jasmine constructs you'd expect, such as describe, context, it, expect, and let.
13
+
- Can automatically generate documentation strings based on your tests
14
+
15
+
## An example:
16
+
17
+
```c++
18
+
describe_a <std::list<int>>
19
+
int_list_spec("A list of ints", {1,2,3}, $ {
20
+
it("is doubly-linked", _ {
21
+
expect(subject.front()).to_equal(1);
22
+
expect(subject.back()).to_equal(3);
23
+
});
24
+
25
+
it(_{ is_expected().to_include(6); });
26
+
it(_{ is_expected().to_include({1,2,3}); });
27
+
it(_{ is_expected().not_().to_include(4); });
28
+
});
29
+
```
30
+
31
+
<p style="padding-bottom:0;margin-bottom:-.5em;">Using the Verbose formatter this outputs:</p>
<span class="s1">expected [1,2,3] to include 6</span>
38
+
<span class="sr"> should include 1, 2, and 3</span>
39
+
<span class="sr"> should not include 4</span>
40
+
</code>
41
+
</pre>
42
+
43
+
## Usage:
44
+
45
+
Download the [header file]() and put it in your project either alongside your tests or in a folder that is in your `INCLUDE` path. Then, simply `#include "cppspec.hpp"` and you're ready to go.
46
+
47
+
## How does it work?
48
+
49
+
C++Spec utilizes templated classes and functions as well as C++14 features in order to automatically deduce the types of your objects and construct your tests.
50
+
51
+
Lambdas are passed to functions (such as `context` and `it`) in order to build an execution tree at runtime. A formatter object visits each node when the tests are run and prints the status of the tests and any errors.
52
+
53
+
## I'm getting really long errors. What's going on?
54
+
55
+
Due to how the library is constructed with both templates and auto-type lambdas, error messages from the compiler can be difficult to understand. Errors also tend to cascade and make the enclosing objects also fail, further obfuscating what's actually going wrong.
56
+
57
+
Usually, the only information you want is the actual error, not all of the template substitution notes. You can reduce the template backtrace by using the flag `-ftemplate-backtrace-limit=1` when compiling with GCC and Clang.
0 commit comments