summaryrefslogtreecommitdiff
path: root/vendor/bandit/README.md
blob: 0c95d420b5e8465719a39c12b8c4f669467c0bf1 (plain)
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
bandit
======
[![Build Status](https://travis-ci.org/joakimkarlsson/bandit.png)](https://travis-ci.org/joakimkarlsson/bandit)

Human friendly unit testing for C++11

Bandit is a framework for C++11 that wants to make working with unit tests a pleasant
experience.

For more information, go to [the bandit website](http://banditcpp.org).

Bandit is released under the [MIT license](LICENSE.md)

#An example

This is a complete test application written in bandit:

```cpp
#include <bandit/bandit.h>
using namespace bandit;

// Tell bandit there are tests here.
go_bandit([](){

    // We're describing how a fuzzbox works.
    describe("fuzzbox:", [](){
      guitar_ptr guitar;
      fuzzbox_ptr fuzzbox;

      // Make sure each test has a fresh setup with
      // a guitar with a fuzzbox connected to it.
      before_each([&](){
        guitar = guitar_ptr(new struct guitar());
        fuzzbox = fuzzbox_ptr(new struct fuzzbox());
        guitar->add_effect(*fuzzbox);
      });

      it("starts in clean mode", [&](){
        AssertThat(guitar->sound(), Equals(sounds::clean));
      });

      // Describe what happens when we turn on the fuzzbox.
      describe("in distorted mode", [&](){

        // Turn on the fuzzbox.
        before_each([&](){
          fuzzbox->flip();
        });

        it("sounds distorted", [&](){
          AssertThat(guitar->sound(), Equals(sounds::distorted));
        });
      });
    });

});

int main(int argc, char* argv[])
{
  // Run the tests.
  return bandit::run(argc, argv);
}
```