blob: 0f0921e280d651ad9f20ce71362b3e4874d6fb39 (
plain)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# This file defines all the compilation tests
# Copyright (C) 2010 Collabora Ltd.
# @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
#
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##########
# Tests for testing whether the compilation tests system works as expected.
# If at least one of those tests fails, something is wrong with the cmake scripts.
cxx_compilation_test(compilation_test_system_test_1 SHOULD_COMPILE "
int main() { return 0; }
")
cxx_compilation_test(compilation_test_system_test_2 SHOULD_FAIL "
int main(float i) { return foobar; }
")
#########
######### BEGIN RefPointer tests ########
cxx_compilation_test(refpointer_test_casts SHOULD_COMPILE "
#include <QGst/Pipeline>
#include <QGst/Message>
#include <iostream>
static void testMethod(const QGlib::ObjectPtr & obj)
{
std::cout << obj.dynamicCast<QGst::Bin>().isNull();
};
int main()
{
QGst::BinPtr bin = QGst::Bin::create();
{
//operator=()
QGst::ObjectPtr obj = bin;
std::cout << obj.dynamicCast<QGst::Bin>().isNull();
}
{
//copy constructor
QGst::ObjectPtr obj(bin);
std::cout << obj.dynamicCast<QGst::Bin>().isNull();
}
{
//implicit cast
testMethod(bin);
}
{
QGst::ElementPtr element = bin.staticCast<QGst::Element>();
QGst::PipelinePtr pipeline = bin.staticCast<QGst::Pipeline>();
}
}
")
cxx_compilation_test(refpointer_test_invalid_upcast SHOULD_FAIL "
#include <QGst/Bin>
#include <QGst/Message>
int main()
{
QGst::BinPtr bin = QGst::Bin::create();
QGst::ObjectPtr obj = bin;
QGst::BinPtr bin2 = obj; //upcast not allowed
}
")
cxx_compilation_test(refpointer_test_invalid_staticCast SHOULD_FAIL "
#include <QGst/Bin>
#include <QGst/Message>
int main()
{
QGst::BinPtr bin = QGst::Bin::create();
QGst::MessagePtr message = bin.staticCast<QGst::Message>(); //bin is not a message
}
")
cxx_compilation_test(refpointer_test_integral_cast SHOULD_FAIL "
#include <QGlib/Object>
#include <iostream>
void func(int b) { std::cout << b; }
int main()
{
QGlib::ObjectPtr ptr;
func(ptr);
}
")
cxx_compilation_test(refpointer_test_bool_cast SHOULD_COMPILE "
#include <QGlib/Object>
#include <iostream>
int main()
{
QGlib::ObjectPtr ptr;
if (ptr) {
std::cout << \"foo\";
}
}
")
######### END RefPointer tests ########
|