示例#1
0
            public void subtracting_null_vector_throws()
            {
                var     left  = new VectorD(3);
                VectorD right = null;

                Assert.Throws <ArgumentNullException>(() => left.Subtract(right));
            }
示例#2
0
            public void subtracting_vectors_of_different_size_throws()
            {
                var left  = new VectorD(3);
                var right = new VectorD(4);

                Assert.NotEqual(left.Dimensions, right.Dimensions);

                Assert.Throws <ArgumentOutOfRangeException>(() => left.Subtract(right));
            }
示例#3
0
            public void subtracting_vectors_leaves_right_unchanged()
            {
                var left = new VectorD(3);

                left.Set(0, 1);
                left.Set(1, 10);
                left.Set(2, 6);
                var right = new VectorD(3);

                right.Set(0, 10);
                right.Set(1, 3);
                right.Set(2, 1);
                var expectedRight = new VectorD(right);

                left.Subtract(right);

                Assert.Equal(expectedRight, right);
            }
示例#4
0
            public void subtracting_vector_subtracts_from_components()
            {
                var actual = new VectorD(3);

                actual.Set(0, 1);
                actual.Set(1, 10);
                actual.Set(2, 6);
                var right = new VectorD(3);

                right.Set(0, 10);
                right.Set(1, 3);
                right.Set(2, 1);
                var expected = new VectorD(3);

                expected.Set(0, -9);
                expected.Set(1, 7);
                expected.Set(2, 5);

                actual.Subtract(right);

                Assert.Equal(expected, actual);
            }