summaryrefslogtreecommitdiff
path: root/vendor/bandit/specs/matchers/be_null.cpp
blob: ae3cd40d0effcef865ad57e33652250e9c427707 (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
#include <specs/specs.h>

using namespace bandit::Matchers;

SPEC_BEGIN(Matchers::BeNull)

describe("be_null matcher", [&]{
    describe("when the value is a pointer to a built-in type", [&]{
        int* value;

        describe("which is NULL", [&]{
            before_each([&]{
                value = NULL;
            });

	    it("must pass a positive match", [&]{
		value must be_null;
	    });

	    it("must reject a negative match", [&]{
		AssertThrows(std::exception, [&]{ value must_not be_null; }());
	    });
        });

        describe("which is not NULL", [&]{
            int i = 7;

            before_each([&]{
                value = &i;
            });

	    it("must pass a negative match", [&]{
		value must_not be_null;
	    });

	    it("must reject a positive match", [&]{
		AssertThrows(std::exception, [&]{ value must be_null; }());
	    });
        });
    });
});

SPEC_END