File: DeepAbort.h

package info (click to toggle)
0ad 0.0.21-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 54,068 kB
  • sloc: cpp: 230,527; ansic: 23,115; python: 13,559; perl: 2,499; sh: 948; xml: 776; makefile: 696; java: 533; ruby: 229; erlang: 53; sql: 21
file content (84 lines) | stat: -rw-r--r-- 2,252 bytes parent folder | download | duplicates (11)
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
#include <cxxtest/TestSuite.h>

//
// This test suite verifies that the TS_ASSERT_THROWS*() macros are "abort on fail"-friendly
//

class DeepAbort : public CxxTest::TestSuite
{
public:
    void testAssertThrowsPassesAbort()
    {
        TS_ASSERT_THROWS(fail(), int);
        TS_FAIL("You shouldn't see this if --abort-on-fail is used");
    }

    void testMessageAssertThrowsPassesAbort()
    {
        TSM_ASSERT_THROWS("fail() should throw an int", fail(), int);
        TS_FAIL("You shouldn't see this if --abort-on-fail is used");
    }

    void testAssertThrowsAborts()
    {
        TS_ASSERT_THROWS(succeed(), int);
        TS_FAIL("You shouldn't see this if --abort-on-fail is used");
    }

    void testMessageAssertThrowsAborts()
    {
        TSM_ASSERT_THROWS("succeed() should throw an int", succeed(), int);
        TS_FAIL("You shouldn't see this if --abort-on-fail is used");
    }

    void testAssertThrowsNothingPassesAbort()
    {
        TS_ASSERT_THROWS_NOTHING(fail());
        TS_FAIL("You shouldn't see this if --abort-on-fail is used");
    }

    void testMessageAssertThrowsNothingPassesAbort()
    {
        TSM_ASSERT_THROWS_NOTHING("fail() shouldn't throw anything", fail());
        TS_FAIL("You shouldn't see this if --abort-on-fail is used");
    }

    void testAssertThrowsNothingAborts()
    {
        TS_ASSERT_THROWS_NOTHING(throwSomething());
        TS_FAIL("You shouldn't see this if --abort-on-fail is used");
    }

    void testMessageAssertThrowsNothingAborts()
    {
        TSM_ASSERT_THROWS_NOTHING("fail() shouldn't throw anything", throwSomething());
        TS_FAIL("You shouldn't see this if --abort-on-fail is used");
    }

    void testAssertThrowsAnything()
    {
        TS_ASSERT_THROWS_ANYTHING(succeed());
        TS_FAIL("You shouldn't see this if --abort-on-fail is used");
    }

    void testMessageAssertThrowsAnything()
    {
        TSM_ASSERT_THROWS_ANYTHING("succeed() should throw something", succeed());
        TS_FAIL("You shouldn't see this if --abort-on-fail is used");
    }

    void fail()
    {
        TS_ASSERT_EQUALS(0, 1);
    }

    void throwSomething()
    {
        throw "something";
    }

    void succeed()
    {
        TS_ASSERT_EQUALS(1, 1);
    }
};