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: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,8 @@
7
7
8
8
A behavior-driven development testing library for C++ with an RSpec-inspired DSL.
9
9
10
+
## Warning! This is pre-release software and may be incomplete, contain bugs, and/or introduce major breaking changes within a short period of time
11
+
10
12
## Installation ##
11
13
12
14
C++Spec will be released as a single collated header-file that can be placed in any include path in your project. After that, all features are available via `#include "cppspec.hpp"`.
Every test suite begins with either `describe` or `describe_a`.
1
2
2
-
Every test suite begins with either `describe` or `describe_a`.
3
-
4
-
# describe #
3
+
# describe
5
4
6
5
Describes have the form of:
7
6
8
7
```c++
9
8
describe example_spec("An example", $ { });
10
9
```
11
10
12
-
Each `describe` is a global instance of the `Description` class, the name of the spec being
13
-
the name of the global variable that the test is contained in.
11
+
Each `describe` is a global instance of the `Description` class, the name of the spec being the name of the global variable that the test is contained in.
14
12
15
-
__Important!__ Take note of the `$`. This is used whenever you write a `describe` or a `describe_a`.
13
+
!!! important
16
14
17
-
In conventional C++, the above snippet would be written as:
15
+
```
16
+
Take note of the `$`. This is used whenever you write a `describe` or a `describe_a`.
17
+
```
18
+
19
+
In conventional C++14, after macro-expansion the above snippet would be written as:
The `Description` constructor takes two arguments: a string, and a lambda. For simplicity's sake,
24
-
any lambdas passed to any C++Spec functions are referred to as "blocks", as the capture-list
25
-
and arguments of the lambda are effectively never seen.
25
+
The `Description` constructor takes two arguments: a string, and a lambda. For simplicity's sake, any lambdas passed to any C++Spec functions are referred to as "blocks", as the capture-list and arguments of the lambda are effectively never seen.
26
26
27
-
# describe_a #
27
+
# describe_a
28
28
29
-
A `describe_a` is more complex than `describe`.
29
+
A `describe_a` is more complex than `describe`.
30
30
31
-
Unlike `describe` which creates instances of `Description`, `describe_a` creates instances of
32
-
`ClassDescription`. `ClassDescription` is a template class, where the template's type variable
33
-
is used to specialize the description and create a subject available to all statements in the
34
-
description.
31
+
Unlike `describe` which creates instances of `Description`, `describe_a` creates instances of `ClassDescription`. `ClassDescription` is a template class, where the template's type variable is used to specialize the description and create a subject available to all statements in the description. The subject is available via the `subject` keyword.
Also unlike `describe`, there are two forms of `describe_a`: one where the subject is explicit,
42
-
and another where it is implicit.
38
+
Also unlike `describe`, there are two forms of `describe_a`: one where the subject is explicit, and another where it is implied.
39
+
40
+
## Explicit subject describe_a
41
+
42
+
An explicit describe_a has the subject passed into it as the first argument if there is no provided description, or after the description if there is one.
Copy file name to clipboardExpand all lines: gh-pages/index.md
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,17 @@ 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. 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:
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 things that make C++Spec different than other testing libraries:
7
7
8
8
- A clean, readable syntax
9
9
- As few macros as possibles
10
10
- Use as a library, not a framework
11
11
- Easily extensible with custom matchers.
12
12
- Support for the RSpec and Jasmine constructs you'd expect, such as describe, context, it, expect, and let.
13
13
- Can automatically generate documentation strings based on your tests
14
+
- Cross-platform with no need to change complex build settings.
15
+
16
+
14
17
15
18
## An example:
16
19
@@ -42,17 +45,17 @@ int_list_spec("A list of ints", {1,2,3}, $ {
42
45
43
46
## Usage:
44
47
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.
48
+
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. Both user and API documentation is available at the top of this page, and a tutorial will soon be available.
46
49
47
50
## How does it work?
48
51
49
52
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
53
51
54
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
55
53
-
## I'm getting really long errors. What's going on?
56
+
## I'm getting really long compiler errors. What's going on?
54
57
55
-
Due to how the library is constructed with both templates and auto-typelambdas, 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.
58
+
Due to how the library is constructed with both templates and type-deduced (auto) lambdas, error messages from the compiler can be difficult to understand. Errors also tend to cascade and make the structures above the problem code also fail to compile, further obfuscating what's actually going wrong.
56
59
57
60
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