Skip to content

Commit

Permalink
Flake
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 24, 2020
1 parent e2a370f commit 1f6e1b1
Showing 1 changed file with 36 additions and 19 deletions.
55 changes: 36 additions & 19 deletions tests/src/python/test_qgssymbollayerutils.py
Expand Up @@ -247,67 +247,84 @@ def testDecodeSldUom(self):
self.assertEqual(decode, (QgsUnitTypes.RenderPixels, 1.0))

def testPolylineSubstring(self):
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF(), 1, 2) # no crash
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF(), 1, 2) # no crash
self.assertFalse(res)

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF(), -1, 2) # no crash
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF(), -1, 2) # no crash
self.assertFalse(res)

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF(), 1, -2) # no crash
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF(), 1, -2) # no crash
self.assertFalse(res)

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF(), -1, -2) # no crash
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF(), -1, -2) # no crash
self.assertFalse(res)

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 0, -110)
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 0,
-110)
self.assertEqual([p for p in res], [])

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 0, 110)
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 0,
110)
self.assertEqual([p for p in res], [QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)])

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), -1, -1000)
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), -1,
-1000)
self.assertFalse([p for p in res])

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 1, -1000)
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 1,
-1000)
self.assertFalse([p for p in res])

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), -1, 1000)
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), -1,
1000)
self.assertEqual([p for p in res], [QPointF(110.0, 12.0), QPointF(111.0, 12.0)])

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 100000, -10000)
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]),
100000, -10000)
self.assertFalse([p for p in res])

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 1, -109)
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 1,
-109)
self.assertEqual([p for p in res], [])

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 1, 109)
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 1,
109)
self.assertEqual([p for p in res], [QPointF(11.0, 3.0), QPointF(11.0, 12.0), QPointF(110.0, 12.0)])

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), -109, 109)
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]),
-109, 109)
self.assertEqual([p for p in res], [QPointF(11.0, 3.0), QPointF(11.0, 12.0), QPointF(110.0, 12.0)])

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 1, -1000)
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 1,
-1000)
self.assertEqual([p for p in res], [])

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 1, 10)
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 1,
10)
self.assertEqual([p for p in res], [QPointF(11, 3), QPointF(11, 12)])

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 1, 0)
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 1,
0)
self.assertEqual([p for p in res], [QPointF(11, 3), QPointF(11, 12), QPointF(111, 12)])

res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 1, -90)
res = QgsSymbolLayerUtils.polylineSubstring(QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)]), 1,
-90)
self.assertEqual([p for p in res], [QPointF(11, 3), QPointF(11, 12), QPointF(21, 12)])

def testAppendPolyline(self):
line = QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)])
line2 = QPolygonF([QPointF(111, 12), QPointF(111, 12), QPointF(111, 14), QPointF(111, 15)])
QgsSymbolLayerUtils.appendPolyline(line, line2)
self.assertEqual([p for p in line], [QPointF(11.0, 2.0), QPointF(11.0, 12.0), QPointF(111.0, 12.0), QPointF(111.0, 14.0), QPointF(111.0, 15.0)])
self.assertEqual([p for p in line],
[QPointF(11.0, 2.0), QPointF(11.0, 12.0), QPointF(111.0, 12.0), QPointF(111.0, 14.0),
QPointF(111.0, 15.0)])

line = QPolygonF([QPointF(11, 2), QPointF(11, 12), QPointF(111, 12)])
line2 = QPolygonF([QPointF(111, 14), QPointF(111, 15)])
QgsSymbolLayerUtils.appendPolyline(line, line2)
self.assertEqual([p for p in line], [QPointF(11.0, 2.0), QPointF(11.0, 12.0), QPointF(111.0, 12.0), QPointF(111.0, 14.0), QPointF(111.0, 15.0)])
self.assertEqual([p for p in line],
[QPointF(11.0, 2.0), QPointF(11.0, 12.0), QPointF(111.0, 12.0), QPointF(111.0, 14.0),
QPointF(111.0, 15.0)])


if __name__ == '__main__':
Expand Down

0 comments on commit 1f6e1b1

Please sign in to comment.