Example #1
0
        protected void SetUp()
        {
            TestIntegerArrays =
                new Dictionary <string, Multiarray <int> >()
            {
                { "A", Multiarray <int> .FromArray(new int[] {
                        1, 3, 5, 2, 4, 6, 8
                    }) },
                { "B", Multiarray <int> .FromArray(new int[, ] {
                        { 1, 2, 3 },
                        { 4, 5, 6 }
                    }) },
                { "C", Multiarray <int> .FromArray(new int[, , ] {
                        { { -4, -2, -1 }, { 1, 4, 2 }, { 5, 3, 1 }, { -6, 3, 13 } },
                        { { 0, 0, 1 }, { 1, 2, 3 }, { -4, 0, 5 }, { 7, 6, -1 } }
                    }) },
                { "D", Multiarray <int> .FromArray(new int[, , , ] {
                        { { { 1, 2, 3 }, { 4, 5, 6 } }, { { 7, 8, 9 }, { 0, 1, 2 } } },
                        { { { 3, 4, 5 }, { 6, 7, 8 } }, { { 9, 0, 1 }, { 2, 3, 4 } } },
                        { { { 5, 6, 7 }, { 8, 9, 0 } }, { { 1, 2, 3 }, { 4, 5, 6 } } }
                    }) },
                { "E", Multiarray <int> .FromArray(new int[, ] {
                        { 1, 3, 5, 2, 4, 6, 8 }
                    }) },
                { "F", Multiarray <int> .FromArray(new int[, , ] {
                        { { -4, -2, -1 }, { 1, 4, 2 }, { 5, 3, 1 }, { -6, 3, 13 } },
                        { { 0, 0, 1 }, { 1, 2, 3 }, { -4, 0, 5 }, { 7, 6, -1 } }
                    }) },
                { "G", new Multiarray <int>(new int[] {
                        5, 2, 8
                    }, new int[] { 3 }) },
                { "H", new Multiarray <int>(new int[] {
                        1, 3, 4, 6
                    }, new int[] { 2, 2 }) },
                { "I", new Multiarray <int>(new int[] {
                        0, 0, 1, 2, -4, 0, 7, 6
                    }, new int[] { 1, 4, 2 }) },
                { "J", Multiarray <int> .FromArray(new int[] {
                        1, 3, 5, 3, 4, 6, 8
                    }) },
                { "K", Multiarray <int> .FromArray(new int[] {}) },
            };

            TestIntegerArrays.Add("A'", TestIntegerArrays["A"].Subarray(axis: 0, 2, 3, 6));
            TestIntegerArrays.Add("B'", TestIntegerArrays["B"].Subarray(axis: 1, new int[] { 0, 2 })
                                  .Subarray(axis: 0, new int[] { 0, 1 }));
            TestIntegerArrays.Add("C'", TestIntegerArrays["C"].Subarray(new int[][] {
                new int[] { 1 },
                null,
                new int[] { 0, 1 }
            }));

            TestIntegerArrays.Add("B''", TestIntegerArrays["B'"].Subarray(axis: 0, new int[] { 1, 0, 1 }));
        }
Example #2
0
 public void TestArrayTypeMismatch(object[] data, bool fails)
 {
     if (fails)
     {
         Assert.Throws <ArrayTypeMismatchException>(delegate
         {
             Multiarray <double> array = Multiarray <double> .FromArray(data);
         });
     }
     else
     {
         Assert.DoesNotThrow(delegate
         {
             Multiarray <double> array = Multiarray <double> .FromArray(data);
         });
     }
 }