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

Method gridOperationTest

test/grid_t.cpp:149–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147
148
149 void gridOperationTest()
150 {
151 QFETCH(double, rotation);
152 QFETCH(double, offset);
153 QFETCH(QPointF, p00);
154 QFETCH(QPointF, p01);
155 QFETCH(QPointF, p10);
156 QFETCH(QPointF, p11);
157
158 auto bounding_box = QRectF{ -5, -5, 10, 10 };
159 auto spacing = 100.0;
160 QVarLengthArray<Record, 2> records;
161 auto recorder = makeRecorder(records);
162 Util::gridOperation(bounding_box, spacing, spacing, offset, offset, qDegreesToRadians(rotation), recorder);
163
164 const auto num_records = int(records.size());
165 QCOMPARE(num_records, 2);
166
167 if (!qIsNull(records.front().p0.y())
168 && qFuzzyCompare(records.front().p0.y(), -records.front().p1.y())
169 && !qIsNull(records.back().p0.x())
170 && qFuzzyCompare(records.back().p0.x(), -records.back().p1.x()))
171 {
172 std::swap(records.front(), records.back()); // normalize
173 }
174
175 {
176 auto& actual = records.front();
177 if (!qFuzzyCompare(actual.p0.x(), bounding_box.left()) && !qFuzzyCompare(actual.p0.y(), bounding_box.top()))
178 std::swap(actual.p0, actual.p1); // normalize
179 QCOMPARE(actual.p0, p00);
180 QCOMPARE(actual.p1, p01);
181 }
182
183 {
184 auto& actual = records.back();
185 if (!qFuzzyCompare(actual.p0.x(), bounding_box.left()) && !qFuzzyCompare(actual.p0.y(), bounding_box.top()))
186 std::swap(actual.p0, actual.p1); // normalize
187 QCOMPARE(actual.p0, p10);
188 QCOMPARE(actual.p1, p11);
189 }
190 }
191
192 void gridOperationTest_data()
193 {

Callers

nothing calls this directly

Calls 6

makeRecorderFunction · 0.85
gridOperationFunction · 0.85
yMethod · 0.80
xMethod · 0.80
backMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected