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 CoordinatesFromIndex_Base() { Assert.AreEqual(new int[] { 0 }, MxUtils.CoordinatesFromIndex(0, new int[] { 2 })); Assert.AreEqual(new int[] { 1 }, MxUtils.CoordinatesFromIndex(1, new int[] { 2 })); Assert.AreEqual(new int[] { 9 }, MxUtils.CoordinatesFromIndex(9, new int[] { 10 })); Assert.AreEqual(new int[] { 0, 0 }, MxUtils.CoordinatesFromIndex(0, new int[] { 4, 2 })); Assert.AreEqual(new int[] { 3, 0 }, MxUtils.CoordinatesFromIndex(3, new int[] { 4, 2 })); Assert.AreEqual(new int[] { 1, 1 }, MxUtils.CoordinatesFromIndex(5, new int[] { 4, 2 })); Assert.AreEqual(new int[] { 3, 1 }, MxUtils.CoordinatesFromIndex(7, new int[] { 4, 2 })); Assert.AreEqual(new int[] { 0, 0, 0 }, MxUtils.CoordinatesFromIndex(0, new int[] { 4, 2, 3 })); Assert.AreEqual(new int[] { 2, 0, 1 }, MxUtils.CoordinatesFromIndex(10, new int[] { 4, 2, 3 })); Assert.AreEqual(new int[] { 3, 1, 2 }, MxUtils.CoordinatesFromIndex(23, new int[] { 4, 2, 3 })); }
public void CoordinatesFromIndex_NegativeIndex() { MxUtils.CoordinatesFromIndex(-1, new int[] { 4, 2, 3 }); }
public void CoordinatesFromIndex_TooBigIndex() { MxUtils.CoordinatesFromIndex(24, new int[] { 4, 2, 3 }); }
public void CoordinatesFromIndex_ZeroDimension() { MxUtils.CoordinatesFromIndex(0, new int[] { 0, 5, 1 }); }
public void CoordinatesFromIndex_NegativeDimension() { MxUtils.CoordinatesFromIndex(0, new int[] { 3, 5, -1 }); }
public void CoordinatesFromIndex_NoDimensions() { MxUtils.CoordinatesFromIndex(0, new int[] { }); }