diff options
author | zmiao <miao.zhao@mapbox.com> | 2020-02-18 14:11:50 +0200 |
---|---|---|
committer | zmiao <miao.zhao@mapbox.com> | 2020-02-21 21:39:48 +0200 |
commit | 351f421080572849b175326ccbee13a77a39bae6 (patch) | |
tree | 2de5d1144102ffd986258febc49553c9937430c5 /test/style/property_expression.test.cpp | |
parent | 6764ab46752681b6bdeb068bdfbc9d4f5313d845 (diff) | |
download | qtlocation-mapboxgl-351f421080572849b175326ccbee13a77a39bae6.tar.gz |
[core] Update unti tests. Remove unnecessary debugging code
Diffstat (limited to 'test/style/property_expression.test.cpp')
-rw-r--r-- | test/style/property_expression.test.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/test/style/property_expression.test.cpp b/test/style/property_expression.test.cpp index 0624cff385..672cff44f5 100644 --- a/test/style/property_expression.test.cpp +++ b/test/style/property_expression.test.cpp @@ -265,15 +265,35 @@ TEST(PropertyExpression, WithinExpression) { ASSERT_TRUE(expression); PropertyExpression<bool> propExpr(std::move(expression)); - // evaluation test with valid geojson source but FeatureType is not Point (currently only support + // evaluation test with valid geojson source but FeatureType is not Point/LineString (currently only support // FeatureType::Point) { - // testLine is inside polygon, but will return false - LineString<double> testLine{{-9.228515625, -17.560246503294888}, {-2.4609375, -16.04581345375217}}; - auto geoLine = convertGeometry(testLine, canonicalTileID); - StubGeometryTileFeature lineFeature(FeatureType::LineString, geoLine); + // testPoly is inside polygon, but will return false + Polygon<double> testRing{{{-9.228515625, -17.560246503294888}, + {-2.4609375, -16.04581345375217}, + {-9.228515625, -17.560246503294888}}}; + auto geoPoly = convertGeometry(testRing, canonicalTileID); + StubGeometryTileFeature polyFeature(FeatureType::Polygon, geoPoly); + + auto evaluatedResult = propExpr.evaluate(EvaluationContext(&polyFeature).withCanonicalTileID(&canonicalTileID)); + EXPECT_FALSE(evaluatedResult); + } + // evaluation test with valid geojson source and valid linestring features + { + // testLine is inside polygon, but will return true + LineString<double> testLine0{{-9.228515625, -17.560246503294888}, {-2.4609375, -16.04581345375217}}; + auto geoLine0 = convertGeometry(testLine0, canonicalTileID); + StubGeometryTileFeature lineFeature0(FeatureType::LineString, geoLine0); - auto evaluatedResult = propExpr.evaluate(EvaluationContext(&lineFeature).withCanonicalTileID(&canonicalTileID)); + // testLine is intersecting polygon even though end points are all inside polygon, but will return false + LineString<double> testLine1{{-10.4150390625, -10.082445532162465}, {-8.8275146484375, -9.194292714912638}}; + auto geoLine1 = convertGeometry(testLine1, canonicalTileID); + StubGeometryTileFeature lineFeature1(FeatureType::LineString, geoLine1); + + auto evaluatedResult = + propExpr.evaluate(EvaluationContext(&lineFeature0).withCanonicalTileID(&canonicalTileID)); + EXPECT_TRUE(evaluatedResult); + evaluatedResult = propExpr.evaluate(EvaluationContext(&lineFeature1).withCanonicalTileID(&canonicalTileID)); EXPECT_FALSE(evaluatedResult); } |