| 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 | { |
nothing calls this directly
no test coverage detected