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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
#define BOOST_TEST_MODULE compilation
#include <boost/test/unit_test.hpp>
#include <types.h>
#include <slicer/modelParts.h>
namespace std {
ostream & operator<<(ostream & strm, const type_info & ti)
{
strm << ti.name();
return strm;
}
}
#define TypeTest(Var, Expr, Explicit, Expected) \
Var obj = Expr; \
Slicer::ModelPartPtr mpp = new Slicer::Explicit<Var>(obj); \
BOOST_REQUIRE_EQUAL(Slicer::Expected, mpp->GetType()); \
\
Slicer::ModelPartPtr autoMpp = Slicer::ModelPartFor(obj); \
BOOST_REQUIRE_EQUAL(Slicer::Expected, autoMpp->GetType()); \
\
Slicer::ModelPartPtr autoPtrMpp = Slicer::ModelPartFor(&obj); \
BOOST_REQUIRE_EQUAL(Slicer::Expected, autoPtrMpp->GetType()); \
\
BOOST_TEST_MESSAGE(typeid(*mpp.get())); \
BOOST_REQUIRE_EQUAL(typeid(*mpp.get()), typeid(*autoMpp.get())); \
BOOST_REQUIRE_EQUAL(typeid(*mpp.get()), typeid(*autoPtrMpp.get()));
#define StackTypeTest(Var, Explicit, Expected) \
TypeTest(Var, Var(), Explicit, Expected)
BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_class )
{
TypeTest(TestModule::BuiltInsPtr, new TestModule::BuiltIns(), ModelPartForClass, mpt_Complex);
}
BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_sequenceclasses )
{
StackTypeTest(TestModule::Classes, ModelPartForSequence, mpt_Sequence);
}
BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_sequencestructs )
{
StackTypeTest(TestModule::Structs, ModelPartForSequence, mpt_Sequence);
}
BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_mapclasses )
{
StackTypeTest(TestModule::ClassMap, ModelPartForDictionary, mpt_Dictionary);
}
BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_mapstructs )
{
StackTypeTest(TestModule::StructMap, ModelPartForDictionary, mpt_Dictionary);
}
BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_bi_string )
{
StackTypeTest(std::string, ModelPartForSimple, mpt_Simple);
}
BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_bi_bool )
{
StackTypeTest(bool, ModelPartForSimple, mpt_Simple);
}
BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_bi_float )
{
StackTypeTest(Ice::Float, ModelPartForSimple, mpt_Simple);
}
BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_bi_double )
{
StackTypeTest(Ice::Double, ModelPartForSimple, mpt_Simple);
}
BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_bi_byte )
{
StackTypeTest(Ice::Byte, ModelPartForSimple, mpt_Simple);
}
BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_bi_short )
{
StackTypeTest(Ice::Short, ModelPartForSimple, mpt_Simple);
}
BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_bi_int )
{
StackTypeTest(Ice::Int, ModelPartForSimple, mpt_Simple);
}
BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_bi_long )
{
StackTypeTest(Ice::Long, ModelPartForSimple, mpt_Simple);
}
BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_struct )
{
StackTypeTest(TestModule::StructType, ModelPartForStruct, mpt_Complex);
}
BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_enum )
{
StackTypeTest(TestModule::SomeNumbers, ModelPartForEnum, mpt_Simple);
}
|