public void Test1() { int[][] points = { new[] { 1, 3 }, new[] { -2, 2 } }; const int k = 1; int[][] expectedResult = { new[] { -2, 2 } }; KClosestPointsToOriginSolution solution = new KClosestPointsToOriginSolution(); int[][] result = solution.Solve(points, k); result.Should().NotBeNull(); result.Length.Should().Be(expectedResult.Length); foreach (int[] point in expectedResult) { result.Should().ContainEquivalentOf(point); } }
public void Test5() { int[][] points = { new[] { 68, 97 }, new[] { 34, -84 }, new[] { 60, 100 }, new[] { 2, 31 }, new[] { -27, -38 }, new[] { -73, -74 }, new[] { -55, -39 }, new[] { 62, 91 }, new[] { 62, 92 }, new[] { -57, -67 } }; const int k = 5; int[][] expectedResult = { new[] { 2, 31 }, new[] { -27, -38 }, new[] { -55, -39 }, new[] { -57, -67 }, new[] { 34, -84 } }; KClosestPointsToOriginSolution solution = new KClosestPointsToOriginSolution(); int[][] result = solution.Solve(points, k); result.Should().NotBeNull(); result.Length.Should().Be(expectedResult.Length); foreach (int[] point in expectedResult) { result.Should().ContainEquivalentOf(point); } }