Exemple #1
0
        public void TestGetBlockShouldFailIndexOutOfBounds()
        {
            // Arrange
            SafeMatrix <Rational> a = new SafeMatrix <Rational>(
                new Rational[, ] {
                { R(1), R(2), R(3) },
                { R(2), R(3), R(4) },
                { R(3), R(4), R(5) },
                { R(4), R(5), R(6) }
            });

            // Act & Assert
            Assert.ThrowsException <IndexOutOfRangeException>(() => a.GetBlock(2, 1, 3, 3));
        }
Exemple #2
0
        public void TestGetBlock()
        {
            // Arrange
            SafeMatrix <Rational> a = new SafeMatrix <Rational>(
                new Rational[, ] {
                { R(1), R(2), R(3) },
                { R(2), R(3), R(4) },
                { R(3), R(4), R(5) },
                { R(4), R(5), R(6) }
            });

            // Act
            SafeMatrix <Rational> actual = a.GetBlock(2, 1, 2, 2);

            // Assert
            SafeMatrix <Rational> expected = new SafeMatrix <Rational>(
                new Rational[, ] {
                { R(4), R(5) },
                { R(5), R(6) }
            });

            Assert.AreEqual(actual, expected);
        }