File: constructed_instances.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 (72 lines) | stat: -rw-r--r-- 1,203 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
#include <tut/tut.hpp>

#include <iostream>

namespace tut
{

/**
 * Testing exact number of instances created when top limit is specified.
 */
struct constructed_instances
{
    test_runner tr;
    struct dummy
    {
        static int constructed;
        dummy()
        {
            constructed++;
        };
    };
    typedef test_group<dummy,3> tf;
    typedef tf::object object;
    tf factory;

    constructed_instances();
};

int constructed_instances::dummy::constructed = 0;

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

template<>
template<>
void constructed_instances::object::test<3>()
{
}

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

typedef test_group<constructed_instances> tg;
typedef tg::object object;
tg constructed_instances("constructed instances");

/**
 * Checks two and only two instances were created.
 */
template<>
template<>
void object::test<1>()
{
    set_test_name("checks two and only two instances were created");
    
    tr.run_tests("internal");
    ensure_equals("result", constructed_instances::dummy::constructed, 2);
}

}