private static Result TestFindClosestEdges(Target target, S2ClosestEdgeQuery query) { List <Result> expected = new(), actual = new(); query.Options_.UseBruteForce = (true); GetClosestEdges(target, query, expected); query.Options_.UseBruteForce = (false); GetClosestEdges(target, query, actual); Assert.True(TestingDistance.CheckDistanceResults(ConvertResults(expected), ConvertResults(actual), query.Options_.MaxResults, query.Options_.MaxDistance, query.Options_.MaxError)); if (!expected.Any()) { return(new Result()); } // Note that when options.max_error() > 0, expected[0].distance() may not // be the minimum distance. It is never larger by more than max_error(), // but the actual value also depends on max_results(). // // Here we verify that GetDistance() and IsDistanceLess() return results // that are consistent with the max_error() setting. var max_error = query.Options_.MaxError; var min_distance = expected[0].Distance; Assert.True(query.GetDistance(target) <= min_distance + max_error); // Test IsDistanceLess(). Assert.False(query.IsDistanceLess(target, min_distance - max_error)); Assert.True(query.IsConservativeDistanceLessOrEqual(target, min_distance)); // Return the closest edge result so that we can also test Project. return(expected[0]); }