summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/auto/declarative_core/tst_coordinate.qml22
-rw-r--r--tests/auto/declarative_core/tst_geoshape.qml27
2 files changed, 47 insertions, 2 deletions
diff --git a/tests/auto/declarative_core/tst_coordinate.qml b/tests/auto/declarative_core/tst_coordinate.qml
index 1541be39..19bdd572 100644
--- a/tests/auto/declarative_core/tst_coordinate.qml
+++ b/tests/auto/declarative_core/tst_coordinate.qml
@@ -138,6 +138,26 @@ Item {
compare(coordSpy.count, 3)
}
+ function test_comparison_data() {
+ return [
+ { tag: "empty", coord1: empty, coord2: QtPositioning.coordinate(), result: true },
+ { tag: "zero", coord1: zero, coord2: QtPositioning.coordinate(0, 0), result: true },
+ { tag: "plusone", coord1: plusone, coord2: QtPositioning.coordinate(0, 1), result: true },
+ { tag: "minusone", coord1: minusone, coord2: QtPositioning.coordinate(0, -1), result: true },
+ { tag: "north", coord1: north, coord2: QtPositioning.coordinate(3, 0), result: true },
+ { tag: "lat,long.alt", coord1: QtPositioning.coordinate(1.1, 2.2, 3.3), coord2: QtPositioning.coordinate(1.1, 2.2, 3.3), result: true },
+ { tag: "not equal1", coord1: plusone, coord2: minusone, result: false },
+ { tag: "not equal2", coord1: plusone, coord2: north, result: false }
+ ]
+ }
+
+ function test_comparison(data) {
+ compare(data.coord1 === data.coord2, data.result)
+ compare(data.coord1 !== data.coord2, !data.result)
+ compare(data.coord1 == data.coord2, data.result)
+ compare(data.coord1 != data.coord2, !data.result)
+ }
+
function test_distance() {
compare(zero.distanceTo(plusone), zero.distanceTo(minusone))
compare(2*plusone.distanceTo(zero), plusone.distanceTo(minusone))
@@ -178,8 +198,6 @@ Item {
var coord_30d2 = coord_30d.atDistanceAndAzimuth(200, 30)
compare(zero.distanceTo(coord_30d2), 20200)
-
}
-
}
}
diff --git a/tests/auto/declarative_core/tst_geoshape.qml b/tests/auto/declarative_core/tst_geoshape.qml
index 72dd788b..fcc2b07c 100644
--- a/tests/auto/declarative_core/tst_geoshape.qml
+++ b/tests/auto/declarative_core/tst_geoshape.qml
@@ -108,4 +108,31 @@ Item {
compare (box.contains(outside), true)
}
}
+
+ TestCase {
+ name: "Shape"
+
+ function test_shape_comparison_data() {
+ return [
+ { tag: "invalid shape", shape1: QtPositioning.shape(), shape2: QtPositioning.shape(), result: true },
+ { tag: "box equal", shape1: box, shape2: QtPositioning.rectangle(tl, br), result: true },
+ { tag: "box not equal", shape1: box, shape2: QtPositioning.rectangle([inside, outside]), result: false },
+ { tag: "box invalid shape", rect1: box, shape2: QtPositioning.shape(), result: false },
+ { tag: "invalid rectangle", shape1: QtPositioning.rectangle(), shape2: QtPositioning.rectangle(), result: true },
+ { tag: "invalid rectangle2", shape1: QtPositioning.rectangle(), shape2: QtPositioning.shape(), result: false },
+ { tag: "circle1 equal", shape1: circle1, shape2: QtPositioning.circle(coordinate1, 200000), result: true },
+ { tag: "circle1 not equal", shape1: circle1, shape2: QtPositioning.circle(coordinate2, 2000), result: false },
+ { tag: "circle1 invalid shape", shape1: circle1, shape2: QtPositioning.shape(), result: false },
+ { tag: "invalid circle", shape1: QtPositioning.circle(), shape2: QtPositioning.circle(), result: true },
+ { tag: "invalid circle2", shape1: QtPositioning.circle(), shape2: QtPositioning.shape(), result: false }
+ ]
+ }
+
+ function test_shape_comparison(data) {
+ compare(data.shape1 === data.shape2, data.result)
+ compare(data.shape1 !== data.shape2, !data.result)
+ compare(data.shape1 == data.shape2, data.result)
+ compare(data.shape1 != data.shape2, !data.result)
+ }
+ }
}