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);
}
};
|