public void IndexAndCoordinatesReciprocity() { int[] dims = new int[] { 5, 6, 4, 9 }; for (int i = 0; i < 5 * 6 * 4 * 9; i++) { int r = MxUtils.IndexFromCoordinates(MxUtils.CoordinatesFromIndex(i, dims), dims); Assert.AreEqual(i, r); } }
public void IndexFromCoordinates_Base() { Assert.AreEqual(0, MxUtils.IndexFromCoordinates(new int[] { 0 }, new int[] { 2 })); Assert.AreEqual(1, MxUtils.IndexFromCoordinates(new int[] { 1 }, new int[] { 2 })); Assert.AreEqual(9, MxUtils.IndexFromCoordinates(new int[] { 9 }, new int[] { 10 })); Assert.AreEqual(0, MxUtils.IndexFromCoordinates(new int[] { 0, 0 }, new int[] { 4, 2 })); Assert.AreEqual(3, MxUtils.IndexFromCoordinates(new int[] { 3, 0 }, new int[] { 4, 2 })); Assert.AreEqual(5, MxUtils.IndexFromCoordinates(new int[] { 1, 1 }, new int[] { 4, 2 })); Assert.AreEqual(7, MxUtils.IndexFromCoordinates(new int[] { 3, 1 }, new int[] { 4, 2 })); Assert.AreEqual(0, MxUtils.IndexFromCoordinates(new int[] { 0, 0, 0 }, new int[] { 4, 2, 3 })); Assert.AreEqual(10, MxUtils.IndexFromCoordinates(new int[] { 2, 0, 1 }, new int[] { 4, 2, 3 })); Assert.AreEqual(23, MxUtils.IndexFromCoordinates(new int[] { 3, 1, 2 }, new int[] { 4, 2, 3 })); }
public void IndexFromCoordinates_TooBigCoordArray() { MxUtils.IndexFromCoordinates(new int[] { 3, 2, 1, 1 }, new int[] { 4, 2, 3 }); }
public void IndexFromCoordinates_TooSmallCoordArray() { MxUtils.IndexFromCoordinates(new int[] { 3, 2 }, new int[] { 4, 2, 3 }); }
public void IndexFromCoordinates_NegativeCoord() { MxUtils.IndexFromCoordinates(new int[] { 3, -1, 2 }, new int[] { 4, 2, 3 }); }
public void IndexFromCoordinates_DimNegativeValue() { MxUtils.IndexFromCoordinates(new int[] { 3, 2, 1 }, new int[] { 4, -1, 3 }); }
public void IndexFromCoordinates_DimZeroValue() { MxUtils.IndexFromCoordinates(new int[] { 3, 2, 1 }, new int[] { 4, 0, 3 }); }
public void IndexFromCoordinates_CoordMoreThanDim() { MxUtils.IndexFromCoordinates(new int[] { 4, 2, 1 }, new int[] { 4, 2, 3 }); }