Debian Codegraph @

test/unit/utils.h

raw symbols SCIP
1 /*
2 * %injeqt copyright begin%
3 * Copyright 2014 Rafał Malinowski ([email protected])
4 * %injeqt copyright end%
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #pragma once
22
23 #include <injeqt/exception/exception.h>cxx . . $ `<file>/include/injeqt/exception/exception.h`/
24
25 #include "internal/setter-method.h"cxx . . $ `<file>/src/internal/setter-method.h`/
26
27 #include <QtCore/QMetaMethod>
28 #include <QtCore/QObject>
29 #include <QtTest/QTest>
30 #include <memory>
31
32 namespace injeqtcxx . . $ injeqt/ { namespace v1cxx . . $ injeqt/v1/ {
33
34 template<typename T>
35 inline QMetaMethodcxx . . $ QMetaMethod# get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).(const stdcxx . . $ std/::stringcxx . . $ std/string# &signature)
36 {
37 return T::staticMetaObject.method(T::staticMetaObject.indexOfMethod(signature.datacxx . . $ std/__cxx11/basic_string#data(1016ee5406d91ab9).()));
38 }
39
40 template<typename T>
41 inline QMetaMethodcxx . . $ QMetaMethod# get_constructorcxx . . $ injeqt/v1/get_constructor(cd3527b7bfe5b271).(const stdcxx . . $ std/::stringcxx . . $ std/string# &signature)
42 {
43 return T::staticMetaObject.constructor(T::staticMetaObject.indexOfConstructor(signature.datacxx . . $ std/__cxx11/basic_string#data(1016ee5406d91ab9).()));
44 }
45
46 template<typename T, typename P>
47 inline injeqtcxx . . $ injeqt/::internalcxx . . $ injeqt/internal/::setter_methodcxx . . $ injeqt/internal/setter_method# make_test_setter_methodcxx . . $ injeqt/v1/make_test_setter_method(fd45cf8d4adedf1d).(const stdcxx . . $ std/::stringcxx . . $ std/string# &signature)
48 {
49 return injeqtcxx . . $ injeqt/::internalcxx . . $ injeqt/internal/::setter_methodcxx . . $ injeqt/internal/setter_method#{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<P>(), get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<T>(signature)};
50 }
51
52 template<typename T>
53 stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<QObjectcxx . . $ QObject#> make_objectcxx . . $ injeqt/v1/make_object(226c71fd9b0be07).()
54 {
55 return stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<QObjectcxx . . $ QObject#>(new T{});
56 }
57
58 template<typename T>
59 inline QMetaMethodcxx . . $ QMetaMethod# make_methodcxx . . $ injeqt/v1/make_method(cd3527b7bfe5b271).(const stdcxx . . $ std/::stringcxx . . $ std/string# &signature)
60 {
61 return T::staticMetaObject.method(T::staticMetaObject.indexOfMethod(signature.datacxx . . $ std/__cxx11/basic_string#data(1016ee5406d91ab9).()));
62 }
63
64 template<typename T>
65 void test_comparecxx . . $ injeqt/v1/test_compare(1f10a48923f889af).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>> objects)
66 {
67 for (decltype(objects.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).()) i = 0; i <cxx . . $ injeqt/v1/`operator<`(24fd26303071bddf). objects.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).(); i++)
68 for (decltype(objects.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).()) j = 0; j <cxx . . $ injeqt/v1/`operator<`(24fd26303071bddf). objects.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).(); j++)
69 if (i !=cxx . . $ injeqt/v1/`operator!=`(24fd26303071bddf). j)
70 {
71 for (auto &&x : objects[i])
72 for (auto &&y : objects[j])
73 {
74 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(x != y);
75 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(y != x);
76 }
77 }
78 else
79 {
80 for (auto &&x : objects[i])
81 for (auto &&y : objects[j])
82 {
83 QVERIFYcxx . . $ injeqt/v1/`operator==`(24fd26303071bddf).(x == y);
84 QVERIFYcxx . . $ injeqt/v1/`operator==`(24fd26303071bddf).(y == x);
85 }
86 }
87 }
88
89 template<typename T>
90 void test_compare_excxx . . $ injeqt/v1/test_compare_ex(1f10a48923f889af).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>> objects)
91 {
92 for (decltype(objects.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).()) i = 0; i <cxx . . $ injeqt/v1/`operator<`(24fd26303071bddf). objects.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).(); i++)
93 for (decltype(objects.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).()) j = 0; j <cxx . . $ injeqt/v1/`operator<`(24fd26303071bddf). objects.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).(); j++)
94 if (i !=cxx . . $ injeqt/v1/`operator!=`(24fd26303071bddf). j)
95 {
96 for (auto &&x : objects[i])
97 {
98 auto first = true;
99 auto c1 = false;
100 auto c2 = false;
101 auto c3 = false;
102 auto c4 = false;
103 auto c5 = false;
104 auto c6 = false;
105 auto c7 = false;
106 auto c8 = false;
107
108 for (auto &&y : objects[j])
109 {
110 QVERIFYcxx . . $ injeqt/v1/`operator!=`(24fd26303071bddf).(x != y);
111 QVERIFYcxx . . $ injeqt/v1/`operator!=`(24fd26303071bddf).(y != x);
112 QVERIFYcxx . . $ injeqt/v1/`operator<`(24fd26303071bddf).((x < y) ^ (y < x));
113 QVERIFYcxx . . $ `operator^`(fd3221fc99529ca8).((x > y) ^ (y > x));
114 QVERIFYcxx . . $ injeqt/v1/`operator<=`(24fd26303071bddf).((x <= y) ^ (y <= x));
115 QVERIFYcxx . . $ injeqt/v1/`operator>=`(24fd26303071bddf).((x >= y) ^ (y >= x));
116 if (first)
117 {
118 c1 = x <cxx . . $ injeqt/v1/`operator<`(24fd26303071bddf). y;
119 c2 = y <cxx . . $ injeqt/v1/`operator<`(24fd26303071bddf). x;
120 c3 = x <=cxx . . $ injeqt/v1/`operator<=`(24fd26303071bddf). y;
121 c4 = y <=cxx . . $ injeqt/v1/`operator<=`(24fd26303071bddf). x;
122 c5 = x >cxx . . $ injeqt/v1/`operator>`(24fd26303071bddf). y;
123 c6 = y >cxx . . $ injeqt/v1/`operator>`(24fd26303071bddf). x;
124 c7 = x >=cxx . . $ injeqt/v1/`operator>=`(24fd26303071bddf). y;
125 c8 = y >=cxx . . $ injeqt/v1/`operator>=`(24fd26303071bddf). x;
126 }
127 else
128 {
129 QCOMPAREcxx . . $ QTest/qCompare(da8a20149f332207).(c1, x < y);
130 QCOMPAREcxx . . $ QTest/qCompare(3ca0d093187d664a).(c2, y < x);
131 QCOMPAREcxx . . $ QTest/qCompare(3ca0d093187d664a).(c3, x <= y);
132 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(c4, y <= y);
133 QCOMPAREcxx . . $ QTest/qCompare(1f2e90c7c9b41c37).(c5, x > y);
134 QCOMPAREcxx . . $ QTest/qCompare(5788e556d6161310).(c6, y > x);
135 QCOMPAREcxx . . $ QTest/qCompare(4cf01d955751cc44).(c7, x >= y);
136 QCOMPAREcxx . . $ QTest/qCompare(5788e556d6161310).(c8, y >= x);
137 }
138 }
139 }
140 }
141 else
142 {
143 for (auto &&x : objects[i])
144 for (auto &&y : objects[j])
145 {
146 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(x == y);
147 QVERIFYcxx . . $ QTest/(y == x);
148 }
149 }
150 }
151
152 }}