1d48fe848SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3d48fe848SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4d48fe848SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5d48fe848SAndrew Rist  * distributed with this work for additional information
6d48fe848SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7d48fe848SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8d48fe848SAndrew Rist  * "License"); you may not use this file except in compliance
9d48fe848SAndrew Rist  * with the License.  You may obtain a copy of the License at
10d48fe848SAndrew Rist  *
11d48fe848SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12d48fe848SAndrew Rist  *
13d48fe848SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14d48fe848SAndrew Rist  * software distributed under the License is distributed on an
15d48fe848SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16d48fe848SAndrew Rist  * KIND, either express or implied.  See the License for the
17d48fe848SAndrew Rist  * specific language governing permissions and limitations
18d48fe848SAndrew Rist  * under the License.
19d48fe848SAndrew Rist  *
20d48fe848SAndrew Rist  *************************************************************/
21d48fe848SAndrew Rist 
22d48fe848SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_testtools.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "sal/config.h"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "multi.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "rtl/string.hxx"
32cdf0e10cSrcweir #include "rtl/textenc.h"
33cdf0e10cSrcweir #include "rtl/ustring.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <sstream>
36cdf0e10cSrcweir 
operator <<(std::ostream & s,const rtl::OUString r)37*24c56ab9SHerbert Dürr inline std::ostream& operator<<( std::ostream& s, const rtl::OUString r) { return (s << r.getStr()); }
38*24c56ab9SHerbert Dürr 
39cdf0e10cSrcweir namespace css = com::sun::star;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace {
42cdf0e10cSrcweir 
43cdf0e10cSrcweir struct CheckFailed {
CheckFailed__anon0518675f0111::CheckFailed44cdf0e10cSrcweir     explicit CheckFailed(rtl::OUString const & theMessage): message(theMessage)
45cdf0e10cSrcweir     {}
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     rtl::OUString message;
48cdf0e10cSrcweir };
49cdf0e10cSrcweir 
checkEqual(T const & value,T const & argument)50cdf0e10cSrcweir template< typename T > void checkEqual(T const & value, T const & argument) {
51cdf0e10cSrcweir     if (argument != value) {
52cdf0e10cSrcweir         std::ostringstream s;
53cdf0e10cSrcweir         s << value << " != " << argument;
54cdf0e10cSrcweir         throw CheckFailed(
55cdf0e10cSrcweir             rtl::OStringToOUString(
56cdf0e10cSrcweir                 rtl::OString(s.str().c_str()), RTL_TEXTENCODING_UTF8));
57cdf0e10cSrcweir     }
58cdf0e10cSrcweir }
59cdf0e10cSrcweir 
60cdf0e10cSrcweir }
61cdf0e10cSrcweir 
62cdf0e10cSrcweir namespace testtools { namespace bridgetest {
63cdf0e10cSrcweir 
testMulti(com::sun::star::uno::Reference<test::testtools::bridgetest::XMulti> const & multi)64cdf0e10cSrcweir rtl::OUString testMulti(
65cdf0e10cSrcweir     com::sun::star::uno::Reference< test::testtools::bridgetest::XMulti >
66cdf0e10cSrcweir     const & multi)
67cdf0e10cSrcweir {
68cdf0e10cSrcweir     try {
69cdf0e10cSrcweir         checkEqual(
70cdf0e10cSrcweir             0.0,
71cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
72cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->getatt1());
73cdf0e10cSrcweir         checkEqual(
74cdf0e10cSrcweir             0.0,
75cdf0e10cSrcweir             static_cast< test::testtools::bridgetest::XMultiBase2 * >(
76cdf0e10cSrcweir                 multi.get())->getatt1());
77cdf0e10cSrcweir         checkEqual(
78cdf0e10cSrcweir             0.0,
79cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
80cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->getatt1());
81cdf0e10cSrcweir         checkEqual(
82cdf0e10cSrcweir             0.0,
83cdf0e10cSrcweir             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
84cdf0e10cSrcweir                 multi.get())->getatt1());
85cdf0e10cSrcweir         checkEqual(
86cdf0e10cSrcweir             0.0,
87cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
88cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->getatt1());
89cdf0e10cSrcweir         css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
90cdf0e10cSrcweir             multi, css::uno::UNO_QUERY_THROW)->setatt1(0.1);
91cdf0e10cSrcweir         checkEqual(
92cdf0e10cSrcweir             0.1,
93cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
94cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->getatt1());
95cdf0e10cSrcweir         checkEqual(
96cdf0e10cSrcweir             0.1,
97cdf0e10cSrcweir             static_cast< test::testtools::bridgetest::XMultiBase2 * >(
98cdf0e10cSrcweir                 multi.get())->getatt1());
99cdf0e10cSrcweir         checkEqual(
100cdf0e10cSrcweir             0.1,
101cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
102cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->getatt1());
103cdf0e10cSrcweir         checkEqual(
104cdf0e10cSrcweir             0.1,
105cdf0e10cSrcweir             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
106cdf0e10cSrcweir                 multi.get())->getatt1());
107cdf0e10cSrcweir         checkEqual(
108cdf0e10cSrcweir             0.1,
109cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
110cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->getatt1());
111cdf0e10cSrcweir         checkEqual< sal_Int32 >(
112cdf0e10cSrcweir             11 * 1,
113cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
114cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->fn11(1));
115cdf0e10cSrcweir         checkEqual< sal_Int32 >(
116cdf0e10cSrcweir             11 * 1,
117cdf0e10cSrcweir             static_cast< test::testtools::bridgetest::XMultiBase2 * >(
118cdf0e10cSrcweir                 multi.get())->fn11(1));
119cdf0e10cSrcweir         checkEqual< sal_Int32 >(
120cdf0e10cSrcweir             11 * 2,
121cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
122cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->fn11(2));
123cdf0e10cSrcweir         checkEqual< sal_Int32 >(
124cdf0e10cSrcweir             11 * 1,
125cdf0e10cSrcweir             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
126cdf0e10cSrcweir                 multi.get())->fn11(1));
127cdf0e10cSrcweir         checkEqual< sal_Int32 >(
128cdf0e10cSrcweir             11 * 5,
129cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
130cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->fn11(5));
131cdf0e10cSrcweir         checkEqual(
132cdf0e10cSrcweir             rtl::OUString::createFromAscii("12" "abc"),
133cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
134cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->fn12(
135cdf0e10cSrcweir                     rtl::OUString::createFromAscii("abc")));
136cdf0e10cSrcweir         checkEqual(
137cdf0e10cSrcweir             rtl::OUString::createFromAscii("12" "abc-2"),
138cdf0e10cSrcweir             static_cast< test::testtools::bridgetest::XMultiBase2 * >(
139cdf0e10cSrcweir                 multi.get())->fn12(rtl::OUString::createFromAscii("abc-2")));
140cdf0e10cSrcweir         checkEqual(
141cdf0e10cSrcweir             rtl::OUString::createFromAscii("12" "abc-2"),
142cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
143cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->fn12(
144cdf0e10cSrcweir                     rtl::OUString::createFromAscii("abc-2")));
145cdf0e10cSrcweir         checkEqual(
146cdf0e10cSrcweir             rtl::OUString::createFromAscii("12" "abc-5"),
147cdf0e10cSrcweir             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
148cdf0e10cSrcweir                 multi.get())->fn12(rtl::OUString::createFromAscii("abc-5")));
149cdf0e10cSrcweir         checkEqual(
150cdf0e10cSrcweir             rtl::OUString::createFromAscii("12" "abc-5"),
151cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
152cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->fn12(
153cdf0e10cSrcweir                     rtl::OUString::createFromAscii("abc-5")));
154cdf0e10cSrcweir         checkEqual< sal_Int32 >(21 * 2, multi->fn21(2));
155cdf0e10cSrcweir         checkEqual(
156cdf0e10cSrcweir             rtl::OUString::createFromAscii("22" "de"),
157cdf0e10cSrcweir             multi->fn22(rtl::OUString::createFromAscii("de")));
158cdf0e10cSrcweir         checkEqual< sal_Int32 >(
159cdf0e10cSrcweir             31 * 3,
160cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
161cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->fn31(3));
162cdf0e10cSrcweir         checkEqual< sal_Int32 >(
163cdf0e10cSrcweir             31 * 5,
164cdf0e10cSrcweir             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
165cdf0e10cSrcweir                 multi.get())->fn31(5));
166cdf0e10cSrcweir         checkEqual< sal_Int32 >(
167cdf0e10cSrcweir             31 * 5,
168cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
169cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->fn31(5));
170cdf0e10cSrcweir         checkEqual(
171cdf0e10cSrcweir             0.0,
172cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
173cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->getatt3());
174cdf0e10cSrcweir         checkEqual(
175cdf0e10cSrcweir             0.0,
176cdf0e10cSrcweir             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
177cdf0e10cSrcweir                 multi.get())->getatt3());
178cdf0e10cSrcweir         checkEqual(
179cdf0e10cSrcweir             0.0,
180cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
181cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->getatt3());
182cdf0e10cSrcweir         css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
183cdf0e10cSrcweir             multi, css::uno::UNO_QUERY_THROW)->setatt3(0.3);
184cdf0e10cSrcweir         checkEqual(
185cdf0e10cSrcweir             0.3,
186cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
187cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->getatt3());
188cdf0e10cSrcweir         checkEqual(
189cdf0e10cSrcweir             0.3,
190cdf0e10cSrcweir             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
191cdf0e10cSrcweir                 multi.get())->getatt3());
192cdf0e10cSrcweir         checkEqual(
193cdf0e10cSrcweir             0.3,
194cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
195cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->getatt3());
196cdf0e10cSrcweir         checkEqual(
197cdf0e10cSrcweir             rtl::OUString::createFromAscii("32" "f"),
198cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
199cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->fn32(
200cdf0e10cSrcweir                     rtl::OUString::createFromAscii("f")));
201cdf0e10cSrcweir         checkEqual(
202cdf0e10cSrcweir             rtl::OUString::createFromAscii("32" "f-5"),
203cdf0e10cSrcweir             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
204cdf0e10cSrcweir                 multi.get())->fn32(rtl::OUString::createFromAscii("f-5")));
205cdf0e10cSrcweir         checkEqual(
206cdf0e10cSrcweir             rtl::OUString::createFromAscii("32" "f-5"),
207cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
208cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->fn32(
209cdf0e10cSrcweir                     rtl::OUString::createFromAscii("f-5")));
210cdf0e10cSrcweir         checkEqual< sal_Int32 >(
211cdf0e10cSrcweir             33,
212cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
213cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->fn33());
214cdf0e10cSrcweir         checkEqual< sal_Int32 >(
215cdf0e10cSrcweir             33,
216cdf0e10cSrcweir             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
217cdf0e10cSrcweir                 multi.get())->fn33());
218cdf0e10cSrcweir         checkEqual< sal_Int32 >(
219cdf0e10cSrcweir             33,
220cdf0e10cSrcweir             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
221cdf0e10cSrcweir                 multi, css::uno::UNO_QUERY_THROW)->fn33());
222cdf0e10cSrcweir         checkEqual< sal_Int32 >(41 * 4, multi->fn41(4));
223cdf0e10cSrcweir         checkEqual< sal_Int32 >(61 * 6, multi->fn61(6));
224cdf0e10cSrcweir         checkEqual(
225cdf0e10cSrcweir             rtl::OUString::createFromAscii("62" ""),
226cdf0e10cSrcweir             multi->fn62(rtl::OUString::createFromAscii("")));
227cdf0e10cSrcweir         checkEqual< sal_Int32 >(71 * 7, multi->fn71(7));
228cdf0e10cSrcweir         checkEqual(
229cdf0e10cSrcweir             rtl::OUString::createFromAscii("72" "g"),
230cdf0e10cSrcweir             multi->fn72(rtl::OUString::createFromAscii("g")));
231cdf0e10cSrcweir         checkEqual< sal_Int32 >(73, multi->fn73());
232cdf0e10cSrcweir     } catch (CheckFailed const & f) {
233cdf0e10cSrcweir         return f.message;
234cdf0e10cSrcweir     }
235cdf0e10cSrcweir     return rtl::OUString();
236cdf0e10cSrcweir }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir } }
239