MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / worldFileUnitTest

Method worldFileUnitTest

test/template_t.cpp:180–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178 }
179
180 void worldFileUnitTest()
181 {
182 auto world_file = WorldFile { 1, 2, 3, 4, 5, 6 };
183 QCOMPARE(world_file.parameters[0], 1.0);
184 QCOMPARE(world_file.parameters[1], 2.0);
185 QCOMPARE(world_file.parameters[2], 3.0);
186 QCOMPARE(world_file.parameters[3], 4.0);
187 QCOMPARE(world_file.parameters[4], 5.0);
188 QCOMPARE(world_file.parameters[5], 6.0);
189
190 auto const transform = QTransform(world_file);
191 QCOMPARE(transform.m11(), 1.0);
192 QCOMPARE(transform.m12(), 2.0);
193 QCOMPARE(transform.m21(), 3.0);
194 QCOMPARE(transform.m22(), 4.0);
195 QCOMPARE(transform.map(QPointF(0.5, 0.5)), QPointF(5, 6));
196
197 WorldFile world_file_2;
198 QCOMPARE(QTransform(world_file_2), QTransform{});
199
200 world_file = world_file_2;
201 QCOMPARE(QTransform(world_file), QTransform{});
202
203 auto const verify_parameters = [](auto const & parameters) {
204 QCOMPARE(parameters[0], 0.15);
205 QCOMPARE(parameters[1], 0.0);
206 QCOMPARE(parameters[2], 0.0);
207 QCOMPARE(parameters[3], -0.15);
208 QCOMPARE(parameters[4], 649078.0);
209 QCOMPARE(parameters[5], 394159.0);
210 };
211
212 QString world_file_path = QStringLiteral("testdata:templates/world-file.pgw");
213 QVERIFY(world_file.load(world_file_path));
214 verify_parameters(world_file.parameters);
215
216 QString image_path = QStringLiteral("testdata:templates/world-file.png");
217 QVERIFY(world_file_2.tryToLoadForImage(image_path));
218 verify_parameters(world_file_2.parameters);
219
220 // Try reading garbage
221 QVERIFY(!world_file.load(image_path));
222 }
223
224 void worldFileTemplateTest()
225 {

Callers

nothing calls this directly

Calls 5

mapMethod · 0.80
tryToLoadForImageMethod · 0.80
QTransformClass · 0.50
QPointFClass · 0.50
loadMethod · 0.45

Tested by

no test coverage detected