Skip to content
Permalink
Browse files

Followup feeeaf0, add unit tests

  • Loading branch information
nyalldawson committed May 17, 2016
1 parent feeeaf0 commit e92dc26c68da66e9a8a4d4e42bc32a1f7cbf45e5
Showing with 25 additions and 0 deletions.
  1. +25 −0 tests/src/python/test_qgsgeometry.py
@@ -1648,6 +1648,31 @@ def testReshape(self):
wkt = g.exportToWkt()
assert compareWkt(expWkt, wkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)

# Test reshape a line from first/last vertex
g = QgsGeometry.fromWkt('LineString (0 0, 5 0, 5 1)')
# extend start
self.assertEqual(g.reshapeGeometry([QgsPoint(0, 0), QgsPoint(-1, 0)]), 0)
expWkt = 'LineString (-1 0, 0 0, 5 0, 5 1)'
wkt = g.exportToWkt()
assert compareWkt(expWkt, wkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)
# extend end
self.assertEqual(g.reshapeGeometry([QgsPoint(5, 1), QgsPoint(10, 1), QgsPoint(10, 2)]), 0)
expWkt = 'LineString (-1 0, 0 0, 5 0, 5 1, 10 1, 10 2)'
wkt = g.exportToWkt()
assert compareWkt(expWkt, wkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)
# test with reversed lines
g = QgsGeometry.fromWkt('LineString (0 0, 5 0, 5 1)')
# extend start
self.assertEqual(g.reshapeGeometry([QgsPoint(-1, 0), QgsPoint(0, 0)]), 0)
expWkt = 'LineString (-1 0, 0 0, 5 0, 5 1)'
wkt = g.exportToWkt()
assert compareWkt(expWkt, wkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)
# extend end
self.assertEqual(g.reshapeGeometry([QgsPoint(10, 2), QgsPoint(10, 1), QgsPoint(5, 1)]), 0)
expWkt = 'LineString (-1 0, 0 0, 5 0, 5 1, 10 1, 10 2)'
wkt = g.exportToWkt()
assert compareWkt(expWkt, wkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)

def testConvertToMultiType(self):
""" Test converting geometries to multi type """
point = QgsGeometry.fromWkt('Point (1 2)')

1 comment on commit e92dc26

@wonder-sk

This comment has been minimized.

Copy link
Member

@wonder-sk wonder-sk commented on e92dc26 May 18, 2016

Thanks @nyalldawson 👍

Please sign in to comment.
You can’t perform that action at this time.