コード例 #1
0
            private static IEnumerable <TestCaseData> IPredicateIndex2DBounds2DTestCases()
            {
                var matrix = ReadOnlyMatrix4x4.FromSystem2DArray(
                    new float[, ] {
                    { 1, 2, 3, 4 },
                    { 9, 8, 7, 6 },
                    { 3, 6, 12, 24 },
                    { 5, 25, 125, 625 }
                });

                yield return(new TestCaseData(
                                 matrix,
                                 new Index2D(0, 0),
                                 new Bounds2D(4, 4),
                                 new GreaterThanPredicate <float>(125))
                             .Returns(new ItemRequestResult <Index2D>((3, 3))));

                yield return(new TestCaseData(
                                 matrix,
                                 new Index2D(0, 0),
                                 new Bounds2D(0, 0),
                                 new AlwaysTruePredicate <float>())
                             .Returns(ItemRequestResult <Index2D> .Fail));

                yield return(new TestCaseData(
                                 matrix,
                                 new Index2D(2, 2),
                                 new Bounds2D(2, 2),
                                 new EqualsPredicate <float>(10))
                             .Returns(ItemRequestResult <Index2D> .Fail));
            }
コード例 #2
0
            private static IEnumerable <TestCaseData> GetColumnTestCases()
            {
                var matrix = ReadOnlyMatrix4x4.FromSystem2DArray(
                    new float[, ] {
                    { 1, 2, 3, 4 },
                    { 9, 8, 7, 6 },
                    { 3, 6, 12, 24 },
                    { 5, 25, 125, 625 }
                });

                var firstColumn = new ReadOnlyColumn <float, ReadOnlyMatrix4x4>(
                    ReadOnlyMatrix4x4.FromSystem2DArray(
                        new float[, ] {
                    { 1, 0, 0, 0 },
                    { 9, 0, 0, 0 },
                    { 3, 0, 0, 0 },
                    { 5, 0, 0, 0 }
                }), 0);

                var lastColumn = new ReadOnlyColumn <float, ReadOnlyMatrix4x4>(
                    ReadOnlyMatrix4x4.FromSystem2DArray(
                        new float[, ] {
                    { 4, 0, 0, 0 },
                    { 6, 0, 0, 0 },
                    { 24, 0, 0, 0 },
                    { 625, 0, 0, 0 }
                }), 0);

                yield return(new TestCaseData(matrix, 0, firstColumn));

                yield return(new TestCaseData(matrix, 3, lastColumn));
            }
            private static IEnumerable <TestCaseData> PredicateIndex2DBounds2DTestCases()
            {
                var matrix = ReadOnlyMatrix4x4.FromSystem2DArray(
                    new float[, ] {
                    { 1, 2, 3, 4 },
                    { 9, 8, 7, 6 },
                    { 3, 6, 12, 24 },
                    { 5, 25, 125, 625 }
                });

                yield return(new TestCaseData(
                                 matrix,
                                 new Index2D(3, 3),
                                 new Bounds2D(4, 4),
                                 new Predicate <float>(o => o < 2))
                             .Returns(new ItemRequestResult <Index2D>((0, 0))));

                yield return(new TestCaseData(
                                 matrix,
                                 new Index2D(0, 0),
                                 new Bounds2D(0, 0),
                                 new Predicate <float>(o => true))
                             .Returns(ItemRequestResult <Index2D> .Fail));

                yield return(new TestCaseData(
                                 matrix,
                                 new Index2D(1, 1),
                                 new Bounds2D(2, 2),
                                 new Predicate <float>(o => o == 10))
                             .Returns(ItemRequestResult <Index2D> .Fail));
            }
コード例 #4
0
 public static ItemRequestResult <Index2D> Test <FloatPredicate>(
     ReadOnlyMatrix4x4 matrix,
     Index2D startIndex,
     Bounds2D sector,
     FloatPredicate match)
     where FloatPredicate : struct, IPredicate <float>
 => matrix.FindIndex <float, ReadOnlyMatrix4x4, FloatPredicate>(
     startIndex, sector, match);
コード例 #5
0
            private static IEnumerable <TestCaseData> PredicateTestCases()
            {
                var matrix = ReadOnlyMatrix4x4.FromSystem2DArray(
                    new float[, ] {
                    { 1, 2, 3, 4 },
                    { 9, 8, 7, 6 },
                    { 3, 6, 12, 24 },
                    { 5, 25, 125, 625 }
                });

                yield return(new TestCaseData(matrix, new Predicate <float>(o => o > 125))
                             .Returns(true));

                yield return(new TestCaseData(matrix, new Predicate <float>(o => o == 10))
                             .Returns(false));
            }
コード例 #6
0
            private static IEnumerable <TestCaseData> FirstIPredicateTestCases()
            {
                var matrix = ReadOnlyMatrix4x4.FromSystem2DArray(
                    new float[, ] {
                    { 1, 2, 3, 4 },
                    { 9, 8, 7, 6 },
                    { 3, 6, 12, 24 },
                    { 5, 25, 125, 625 }
                });

                yield return(new TestCaseData(matrix, new GreaterThanPredicate <float>(125))
                             .Returns(new ItemRequestResult <float>(625)));

                yield return(new TestCaseData(matrix, new EqualsPredicate <float>(10))
                             .Returns(ItemRequestResult <float> .Fail));
            }
コード例 #7
0
            private static IEnumerable <TestCaseData> LastTestCases()
            {
                var matrix = ReadOnlyMatrix4x4.FromSystem2DArray(
                    new float[, ] {
                    { 1, 2, 3, 4 },
                    { 9, 8, 7, 6 },
                    { 3, 6, 12, 24 },
                    { 5, 25, 125, 625 }
                });

                yield return(new TestCaseData(matrix, new Predicate <float>(o => o < 2))
                             .Returns(new ItemRequestResult <float>(1)));

                yield return(new TestCaseData(matrix, new Predicate <float>(o => o == 10))
                             .Returns(ItemRequestResult <float> .Fail));
            }
            private static IEnumerable <TestCaseData> IndicesTestCases()
            {
                var matrix = ReadOnlyMatrix4x4.FromSystem2DArray(
                    new float[, ] {
                    { 1, 2, 3, 4 },
                    { 9, 8, 7, 6 },
                    { 3, 6, 12, 24 },
                    { 5, 25, 125, 625 }
                });

                yield return(new TestCaseData(
                                 matrix,
                                 new Predicate <float>(o => o > 20),
                                 new List <Index2D>()
                {
                    (2, 3), (3, 1), (3, 2), (3, 3)
                }));
            private static IEnumerable <TestCaseData> ItemsIPredicateTestCases()
            {
                var matrix = ReadOnlyMatrix4x4.FromSystem2DArray(
                    new float[, ] {
                    { 1, 2, 3, 4 },
                    { 9, 8, 7, 6 },
                    { 3, 6, 12, 24 },
                    { 5, 25, 125, 625 }
                });

                yield return(new TestCaseData(
                                 matrix,
                                 new GreaterThanPredicate <float>(20),
                                 new List <float>()
                {
                    24, 25, 125, 625
                }));

                yield return(new TestCaseData(
                                 matrix, new EqualsPredicate <float>(10), new List <float>()));
            }
コード例 #10
0
 public static bool Test <FloatPredicate>(ReadOnlyMatrix4x4 matrix, FloatPredicate match)
     where FloatPredicate : struct, IPredicate <float>
 => matrix.Exists <float, ReadOnlyMatrix4x4, FloatPredicate>(match);
 public static void TestFindAll <Index2DCollection, FloatPredicate>(
     ReadOnlyMatrix4x4 matrix, FloatPredicate match, Index2DCollection expected)
     where Index2DCollection : ICollection <Index2D>, new()
     where FloatPredicate : struct, IPredicate <float>
 => CollectionAssert.AreEqual(expected, matrix.FindAllIndices <
                                  float, Index2DCollection, ReadOnlyMatrix4x4, FloatPredicate>(match));
コード例 #12
0
 public static ItemRequestResult <float> Test <FloatPredicate>(
     ReadOnlyMatrix4x4 matrix, FloatPredicate match)
     where FloatPredicate : struct, IPredicate <float>
 => matrix.FindLast <float, ReadOnlyMatrix4x4, FloatPredicate>(match);
コード例 #13
0
 public static ItemRequestResult <float> Test(
     ReadOnlyMatrix4x4 matrix, Predicate <float> match)
 => matrix.FindLast(match);
コード例 #14
0
 public static ItemRequestResult <Index2D> Test(
     ReadOnlyMatrix4x4 matrix,
     Index2D startIndex,
     Bounds2D sector,
     Predicate <float> match)
 => matrix.FindIndex(startIndex, sector, match);
コード例 #15
0
 public static void Index2DBounds2DThrowsExceptionIfSectorIsOutOfBounds(
     ReadOnlyMatrix4x4 matrix, Index2D startIndex, Bounds2D sector)
 => Assert.Throws <ArgumentOutOfRangeException>(
     () => matrix.FindIndex <
         float, ReadOnlyMatrix4x4, AlwaysTruePredicate <float> >(
         startIndex, sector, new AlwaysTruePredicate <float>()));
コード例 #16
0
 public static void GetColumnThrowExceptionIfIndexExceedsColumns(
     ReadOnlyMatrix4x4 matrix, int index)
 => Assert.Throws <ArgumentOutOfRangeException>(
     () => matrix.GetColumn <float, ReadOnlyMatrix4x4>(index));
コード例 #17
0
 public static void Index2DBounds2DThrowsExceptionIfSectorIsOutOfBounds(
     ReadOnlyMatrix4x4 matrix, Index2D startIndex, Bounds2D sector)
 => Assert.Throws <ArgumentOutOfRangeException>(
     () => matrix.FindIndex <float, ReadOnlyMatrix4x4>(
         startIndex, sector, o => true));
コード例 #18
0
 public static void GetColumnTest(
     ReadOnlyMatrix4x4 matrix,
     int index,
     ReadOnlyColumn <float, ReadOnlyMatrix4x4> expected)
 => CollectionAssert.AreEqual(
     expected, matrix.GetColumn <float, ReadOnlyMatrix4x4>(index));
 public static void TestFindAll <FloatCollection>(
     ReadOnlyMatrix4x4 matrix, Predicate <float> match, FloatCollection expected)
     where FloatCollection : ICollection <float>, new()
 => CollectionAssert.AreEqual(expected, matrix.FindAll <
                                  float, FloatCollection, ReadOnlyMatrix4x4>(match));
コード例 #20
0
 public static bool Test(ReadOnlyMatrix4x4 matrix, Predicate <float> match)
 => matrix.Exists(match);
コード例 #21
0
 public static bool Test(ReadOnlyMatrix4x4 matrix, Predicate <float> match)
 => matrix.TrueForAll(match);
 public static void Index2DBounds2DThrowsExceptionIfStartIndexIsOutOfBounds(
     ReadOnlyMatrix4x4 matrix, Index2D startIndex)
 => Assert.Throws <ArgumentOutOfRangeException>(
     () => matrix.FindLastIndex <float, ReadOnlyMatrix4x4>(
         startIndex, new Bounds2D(), o => true));