File: less_than_50.cpp

package info (click to toggle)
libtut 0.0.20070706-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, lenny, squeeze, stretch, wheezy
  • size: 1,020 kB
  • ctags: 607
  • sloc: cpp: 3,588; sh: 2,202; xml: 137; makefile: 59; ansic: 9
file content (76 lines) | stat: -rw-r--r-- 1,206 bytes parent folder | download | duplicates (4)
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
#include <tut/tut.hpp>

#include <stdexcept>

using std::runtime_error;

namespace tut
{
    
/**
 * Testing we can create non-50-tests group.
 */
struct less_than_50
{
    test_runner tr;
    struct dummy
    {
        static bool called;
    };
    typedef test_group<dummy,2> tf;
    typedef tf::object object;
    tf factory;

    less_than_50();
};

bool less_than_50::dummy::called = false;

/**
 * Internal test definition
 */
template<>
template<>
void less_than_50::object::test<1>()
{
    if (called)
    {
        throw std::runtime_error("called 3");
    }
}

template<>
template<>
void less_than_50::object::test<3>()
{
    called = true;
}

/**
 * Internal constructor
 */
less_than_50::less_than_50() 
    : factory("internal", tr)
{
}

typedef test_group<less_than_50> tg;
typedef tg::object object;
tg less_than_50("less than default 50 tests");

/**
 * Checks running all (and do not call 3rd test) and then only 1th.
 */
template<>
template<>
void object::test<1>()
{
    set_test_name("checks running all (and do not call 3rd test) and then"
        " only 1th.");
    
    tr.run_tests("internal");
    ensure_equals("result", tr.run_test("internal",1).result, test_result::ok);
}

}