calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / testtools / source / bridgetest / multi.cxx
blob1ac6aa81b13581495b59e56bb4c275f92f18b96f
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/textenc.h>
26 #include <rtl/ustring.hxx>
28 #include <sstream>
29 #include <string_view>
30 #include <utility>
32 namespace {
34 struct CheckFailed {
35 explicit CheckFailed(OUString theMessage): message(std::move(theMessage))
38 OUString message;
41 template< typename T > void checkEqual(T const & value, T const & argument) {
42 if (argument != value) {
43 std::ostringstream s;
44 s << value << " != " << argument;
45 throw CheckFailed(
46 OStringToOUString(
47 std::string_view(s.str()), RTL_TEXTENCODING_UTF8));
53 namespace testtools::bridgetest {
55 OUString testMulti( css::uno::Reference< test::testtools::bridgetest::XMulti > const & multi )
57 try {
58 checkEqual(
59 0.0,
60 css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
61 multi, css::uno::UNO_QUERY_THROW)->getatt1());
62 checkEqual(
63 0.0,
64 static_cast< test::testtools::bridgetest::XMultiBase2 * >(
65 multi.get())->getatt1());
66 checkEqual(
67 0.0,
68 css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
69 multi, css::uno::UNO_QUERY_THROW)->getatt1());
70 checkEqual(
71 0.0,
72 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
73 multi.get())->getatt1());
74 checkEqual(
75 0.0,
76 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
77 multi, css::uno::UNO_QUERY_THROW)->getatt1());
78 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
79 multi, css::uno::UNO_QUERY_THROW)->setatt1(0.1);
80 checkEqual(
81 0.1,
82 css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
83 multi, css::uno::UNO_QUERY_THROW)->getatt1());
84 checkEqual(
85 0.1,
86 static_cast< test::testtools::bridgetest::XMultiBase2 * >(
87 multi.get())->getatt1());
88 checkEqual(
89 0.1,
90 css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
91 multi, css::uno::UNO_QUERY_THROW)->getatt1());
92 checkEqual(
93 0.1,
94 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
95 multi.get())->getatt1());
96 checkEqual(
97 0.1,
98 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
99 multi, css::uno::UNO_QUERY_THROW)->getatt1());
100 checkEqual< sal_Int32 >(
101 11 * 1,
102 css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
103 multi, css::uno::UNO_QUERY_THROW)->fn11(1));
104 checkEqual< sal_Int32 >(
105 11 * 1,
106 static_cast< test::testtools::bridgetest::XMultiBase2 * >(
107 multi.get())->fn11(1));
108 checkEqual< sal_Int32 >(
109 11 * 2,
110 css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
111 multi, css::uno::UNO_QUERY_THROW)->fn11(2));
112 checkEqual< sal_Int32 >(
113 11 * 1,
114 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
115 multi.get())->fn11(1));
116 checkEqual< sal_Int32 >(
117 11 * 5,
118 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
119 multi, css::uno::UNO_QUERY_THROW)->fn11(5));
120 checkEqual(
121 OUString("12" "abc"),
122 css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
123 multi, css::uno::UNO_QUERY_THROW)->fn12(
124 "abc"));
125 checkEqual(
126 OUString("12" "abc-2"),
127 static_cast< test::testtools::bridgetest::XMultiBase2 * >(
128 multi.get())->fn12("abc-2"));
129 checkEqual(
130 OUString("12" "abc-2"),
131 css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
132 multi, css::uno::UNO_QUERY_THROW)->fn12("abc-2"));
133 checkEqual(
134 OUString("12" "abc-5"),
135 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
136 multi.get())->fn12("abc-5"));
137 checkEqual(
138 OUString("12" "abc-5"),
139 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
140 multi, css::uno::UNO_QUERY_THROW)->fn12("abc-5"));
141 checkEqual< sal_Int32 >(21 * 2, multi->fn21(2));
142 checkEqual(
143 OUString("22" "de"),
144 multi->fn22("de"));
145 checkEqual< sal_Int32 >(
146 31 * 3,
147 css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
148 multi, css::uno::UNO_QUERY_THROW)->fn31(3));
149 checkEqual< sal_Int32 >(
150 31 * 5,
151 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
152 multi.get())->fn31(5));
153 checkEqual< sal_Int32 >(
154 31 * 5,
155 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
156 multi, css::uno::UNO_QUERY_THROW)->fn31(5));
157 checkEqual(
158 0.0,
159 css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
160 multi, css::uno::UNO_QUERY_THROW)->getatt3());
161 checkEqual(
162 0.0,
163 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
164 multi.get())->getatt3());
165 checkEqual(
166 0.0,
167 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
168 multi, css::uno::UNO_QUERY_THROW)->getatt3());
169 css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
170 multi, css::uno::UNO_QUERY_THROW)->setatt3(0.3);
171 checkEqual(
172 0.3,
173 css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
174 multi, css::uno::UNO_QUERY_THROW)->getatt3());
175 checkEqual(
176 0.3,
177 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
178 multi.get())->getatt3());
179 checkEqual(
180 0.3,
181 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
182 multi, css::uno::UNO_QUERY_THROW)->getatt3());
183 checkEqual(
184 OUString("32" "f"),
185 css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
186 multi, css::uno::UNO_QUERY_THROW)->fn32("f"));
187 checkEqual(
188 OUString("32" "f-5"),
189 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
190 multi.get())->fn32("f-5"));
191 checkEqual(
192 OUString("32" "f-5"),
193 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
194 multi, css::uno::UNO_QUERY_THROW)->fn32("f-5"));
195 checkEqual< sal_Int32 >(
197 css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
198 multi, css::uno::UNO_QUERY_THROW)->fn33());
199 checkEqual< sal_Int32 >(
201 static_cast< test::testtools::bridgetest::XMultiBase5 * >(
202 multi.get())->fn33());
203 checkEqual< sal_Int32 >(
205 css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
206 multi, css::uno::UNO_QUERY_THROW)->fn33());
207 checkEqual< sal_Int32 >(41 * 4, multi->fn41(4));
208 checkEqual< sal_Int32 >(61 * 6, multi->fn61(6));
209 checkEqual(
210 OUString("62" ""),
211 multi->fn62(OUString()));
212 checkEqual< sal_Int32 >(71 * 7, multi->fn71(7));
213 checkEqual(
214 OUString("72" "g"),
215 multi->fn72("g"));
216 checkEqual< sal_Int32 >(73, multi->fn73());
217 } catch (CheckFailed const & f) {
218 return f.message;
220 return OUString();
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */