bump product version to 5.0.4.1
[LibreOffice.git] / testtools / source / bridgetest / multi.cxx
blob0c20128345a042495ed05c430794756668062ad8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "sal/config.h"
23 #include "multi.hxx"
25 #include "rtl/string.hxx"
26 #include "rtl/textenc.h"
27 #include "rtl/ustring.hxx"
29 #include <sstream>
31 namespace {
33 struct CheckFailed {
34 explicit CheckFailed(OUString const & theMessage): message(theMessage)
37 OUString message;
40 ::std::ostream& operator<< (::std::ostream& os, const OUString& str)
42 return os << OUStringToOString(str, RTL_TEXTENCODING_UTF8).getStr();
45 template< typename T > void checkEqual(T const & value, T const & argument) {
46 if (argument != value) {
47 std::ostringstream s;
48 s << value << " != " << argument;
49 throw CheckFailed(
50 OStringToOUString(
51 OString(s.str().c_str()), RTL_TEXTENCODING_UTF8));
57 namespace testtools { namespace bridgetest {
59 OUString testMulti(
60 com::sun::star::uno::Reference< test::testtools::bridgetest::XMulti >
61 const & multi)
63 try {
64 checkEqual(
65 0.0,
66 css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
67 multi, css::uno::UNO_QUERY_THROW)->getatt1());
68 checkEqual(
69 0.0,
70 static_cast< test::testtools::bridgetest::XMultiBase2 * >(
71 multi.get())->getatt1());
72 checkEqual(
73 0.0,
74 css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
75 multi, css::uno::UNO_QUERY_THROW)->getatt1());
76 checkEqual(
77 0.0,
78 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
79 multi.get())->getatt1());
80 checkEqual(
81 0.0,
82 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
83 multi, css::uno::UNO_QUERY_THROW)->getatt1());
84 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
85 multi, css::uno::UNO_QUERY_THROW)->setatt1(0.1);
86 checkEqual(
87 0.1,
88 css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
89 multi, css::uno::UNO_QUERY_THROW)->getatt1());
90 checkEqual(
91 0.1,
92 static_cast< test::testtools::bridgetest::XMultiBase2 * >(
93 multi.get())->getatt1());
94 checkEqual(
95 0.1,
96 css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
97 multi, css::uno::UNO_QUERY_THROW)->getatt1());
98 checkEqual(
99 0.1,
100 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
101 multi.get())->getatt1());
102 checkEqual(
103 0.1,
104 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
105 multi, css::uno::UNO_QUERY_THROW)->getatt1());
106 checkEqual< sal_Int32 >(
107 11 * 1,
108 css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
109 multi, css::uno::UNO_QUERY_THROW)->fn11(1));
110 checkEqual< sal_Int32 >(
111 11 * 1,
112 static_cast< test::testtools::bridgetest::XMultiBase2 * >(
113 multi.get())->fn11(1));
114 checkEqual< sal_Int32 >(
115 11 * 2,
116 css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
117 multi, css::uno::UNO_QUERY_THROW)->fn11(2));
118 checkEqual< sal_Int32 >(
119 11 * 1,
120 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
121 multi.get())->fn11(1));
122 checkEqual< sal_Int32 >(
123 11 * 5,
124 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
125 multi, css::uno::UNO_QUERY_THROW)->fn11(5));
126 checkEqual(
127 OUString("12" "abc"),
128 css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
129 multi, css::uno::UNO_QUERY_THROW)->fn12(
130 OUString("abc")));
131 checkEqual(
132 OUString("12" "abc-2"),
133 static_cast< test::testtools::bridgetest::XMultiBase2 * >(
134 multi.get())->fn12(OUString("abc-2")));
135 checkEqual(
136 OUString("12" "abc-2"),
137 css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
138 multi, css::uno::UNO_QUERY_THROW)->fn12(
139 OUString("abc-2")));
140 checkEqual(
141 OUString("12" "abc-5"),
142 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
143 multi.get())->fn12(OUString("abc-5")));
144 checkEqual(
145 OUString("12" "abc-5"),
146 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
147 multi, css::uno::UNO_QUERY_THROW)->fn12(
148 OUString("abc-5")));
149 checkEqual< sal_Int32 >(21 * 2, multi->fn21(2));
150 checkEqual(
151 OUString("22" "de"),
152 multi->fn22(OUString("de")));
153 checkEqual< sal_Int32 >(
154 31 * 3,
155 css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
156 multi, css::uno::UNO_QUERY_THROW)->fn31(3));
157 checkEqual< sal_Int32 >(
158 31 * 5,
159 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
160 multi.get())->fn31(5));
161 checkEqual< sal_Int32 >(
162 31 * 5,
163 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
164 multi, css::uno::UNO_QUERY_THROW)->fn31(5));
165 checkEqual(
166 0.0,
167 css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
168 multi, css::uno::UNO_QUERY_THROW)->getatt3());
169 checkEqual(
170 0.0,
171 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
172 multi.get())->getatt3());
173 checkEqual(
174 0.0,
175 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
176 multi, css::uno::UNO_QUERY_THROW)->getatt3());
177 css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
178 multi, css::uno::UNO_QUERY_THROW)->setatt3(0.3);
179 checkEqual(
180 0.3,
181 css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
182 multi, css::uno::UNO_QUERY_THROW)->getatt3());
183 checkEqual(
184 0.3,
185 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
186 multi.get())->getatt3());
187 checkEqual(
188 0.3,
189 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
190 multi, css::uno::UNO_QUERY_THROW)->getatt3());
191 checkEqual(
192 OUString("32" "f"),
193 css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
194 multi, css::uno::UNO_QUERY_THROW)->fn32(
195 OUString("f")));
196 checkEqual(
197 OUString("32" "f-5"),
198 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
199 multi.get())->fn32(OUString("f-5")));
200 checkEqual(
201 OUString("32" "f-5"),
202 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
203 multi, css::uno::UNO_QUERY_THROW)->fn32(
204 OUString("f-5")));
205 checkEqual< sal_Int32 >(
207 css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
208 multi, css::uno::UNO_QUERY_THROW)->fn33());
209 checkEqual< sal_Int32 >(
211 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
212 multi.get())->fn33());
213 checkEqual< sal_Int32 >(
215 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
216 multi, css::uno::UNO_QUERY_THROW)->fn33());
217 checkEqual< sal_Int32 >(41 * 4, multi->fn41(4));
218 checkEqual< sal_Int32 >(61 * 6, multi->fn61(6));
219 checkEqual(
220 OUString("62" ""),
221 multi->fn62(OUString()));
222 checkEqual< sal_Int32 >(71 * 7, multi->fn71(7));
223 checkEqual(
224 OUString("72" "g"),
225 multi->fn72(OUString("g")));
226 checkEqual< sal_Int32 >(73, multi->fn73());
227 } catch (CheckFailed const & f) {
228 return f.message;
230 return OUString();
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */