public void FromDataTest2()
{
double[][] points =
{
new double[] { 2, 3 },
new double[] { 2, 4 },
new double[] { 4, 3 }
};
var tree = KDTree.FromData<int>(points);
// The sorting algorithm has changed from .NET 4.0
// to 4.5. Since the framework doesn't do stable sorts,
// tests involving equal elements have changed.
Assert.AreEqual(2, tree.Root.Position[0]);
if (tree.Root.Position[1] == 3)
{
Assert.AreEqual(2, tree.Root.Left.Position[0]);
Assert.AreEqual(4, tree.Root.Left.Position[1]);
}
else if (tree.Root.Position[1] == 4)
{
Assert.AreEqual(2, tree.Root.Left.Position[0]);
Assert.AreEqual(3, tree.Root.Left.Position[1]);
}
else
{
Assert.Fail();
}
Assert.AreEqual(4, tree.Root.Right.Position[0]);
Assert.AreEqual(3, tree.Root.Right.Position[1]);
Assert.IsNull(tree.Root.Left.Left);
Assert.IsNull(tree.Root.Left.Right);
Assert.IsNull(tree.Root.Right.Left);
Assert.IsNull(tree.Root.Right.Right);
}