File: setup_new_copy.cpp

package info (click to toggle)
libtut 0.0.20070706-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,148 kB
  • sloc: cpp: 3,588; xml: 137; makefile: 18; ansic: 9
file content (68 lines) | stat: -rw-r--r-- 1,093 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
#include <tut/tut.hpp>

namespace tut
{
    
/**
 * Testing each test starts with brand new test object.
 */
struct setup_new_copy
{
    static int counter;
    test_runner tr;
    struct dummy
    {
        dummy()
        {
            counter++;
        };
    };
    
    typedef test_group<dummy> tf;
    typedef tf::object object;
    tf factory;

    setup_new_copy();
};

int setup_new_copy::counter = 0;

/**
 * Internal test definition
 */
template<>
template<>
void setup_new_copy::object::test<1>()
{
}

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

typedef test_group<setup_new_copy> tg;
typedef tg::object object;
tg setup_new_copy("new test object for each test");

/**
 * Checks getting unknown exception in setup.
 */
template<>
template<>
void object::test<1>()
{
    set_test_name("checks getting unknown exception in setup");
    
    tr.run_test("internal",1);
    ensure_equals("one constructor called", counter, 1);

    tr.run_test("internal",1);
    ensure_equals("another constructor called", counter, 2);
}

}