Beispiel #1
0
        public void Given_1dArray_When_ConvertedTo2dArrayAcrossColumns_Then_New2dArrayHasCorrectNumberOfRowsAndColumns()
        {
            IOneBasedArray <string>   oneDimArray = new OneBasedArrayImpl <string>(new string[] { "a", "b", "c", "d" });
            IOneBasedArray2D <string> twoDimArray = oneDimArray.To2DArray(ArrayOrientation.COLUMN);

            Assert.AreEqual(1, twoDimArray.GetLength(0), "New 2D array should have 1 row");
            Assert.AreEqual(4, twoDimArray.GetLength(1), "New 2D array should have 4 columns");
        }
Beispiel #2
0
        public void OneBasedGetterYieldsCorrectResults()
        {
            IOneBasedArray2D <string> arrOneBased = GenTestData();

            Assert.AreEqual(arrOneBased[1, 1], One + 1);
            Assert.AreEqual(arrOneBased[1, 2], Two + 1);
            Assert.AreEqual(arrOneBased[2, 3], Three + 2);
            Assert.AreEqual(arrOneBased[2, 4], Four + 2);
        }
Beispiel #3
0
        public void Given_2DArrayOfBytes_When_SubArray_Then_ExpectedSubArrayReturned
            (byte[,] data, int startAtRow, int startAtColumn, int stopBeforeRow, int stopBeforeColumn, byte[,] expected)
        {
            IOneBasedArray2D <byte> oneBasedData     = new OneBasedArray2DImpl <byte>(data);
            IOneBasedArray2D <byte> oneBasedExpected = new OneBasedArray2DImpl <byte>(expected);
            IOneBasedArray2D <byte> sub = oneBasedData.SubArray(startAtRow, startAtColumn, stopBeforeRow, stopBeforeColumn);

            Assert.AreEqual(oneBasedExpected.ZeroBasedEquivalent, sub.ZeroBasedEquivalent, string.Format(
                                "Failure for sub array with coordinates ({0}, {1}) --> ({2}, {3}))",
                                startAtRow, startAtColumn, stopBeforeRow, stopBeforeColumn));
        }
 public IOneBasedArray2D <TResult> ZipArray <TOther, TResult>(Func <TVal, TOther, TResult> zipper, IOneBasedArray2D <TOther> other)
 {
     TResult[,] zipped = ZeroBasedEquivalent.ZipArray(zipper, other.ZeroBasedEquivalent);
     return(new OneBasedArray2DImpl <TResult>(zipped));
 }
 public void WriteToArea(IOneBasedArray2D <TVal> values, int rowOffset, int columnOffset)
 {
     ZeroBasedEquivalent.WriteToArea(values.ZeroBasedEquivalent, rowOffset, columnOffset);
 }
Beispiel #6
0
        public void UpperIndexOutOfBoundsDim1()
        {
            IOneBasedArray2D <string> arrOneBased = GenTestData();

            Assert.Throws <IndexOutOfRangeException>(() => { _ = arrOneBased[2, 5]; });
        }