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

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

                var lastColumn = new RefReadOnlyColumn <float, RefReadOnlyMatrix4x4>(
                    RefReadOnlyMatrix4x4.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> IPredicateIndex2DBounds2DTestCases()
            {
                var matrix = RefReadOnlyMatrix4x4.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));
            }
 public static ItemRequestResult <Index2D> Test <FloatPredicate>(
     RefReadOnlyMatrix4x4 matrix,
     Index2D startIndex,
     Bounds2D sector,
     FloatPredicate match)
     where FloatPredicate : struct, IPredicate <float>
 => matrix.FindIndex <float, RefReadOnlyMatrix4x4, FloatPredicate>(
     startIndex, sector, match);
コード例 #5
0
            private static IEnumerable <TestCaseData> LastTestCases()
            {
                var matrix = RefReadOnlyMatrix4x4.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));
            }
コード例 #6
0
            private static IEnumerable <TestCaseData> FirstIPredicateTestCases()
            {
                var matrix = RefReadOnlyMatrix4x4.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));
            }
            private static IEnumerable <TestCaseData> PredicateTestCases()
            {
                var matrix = RefReadOnlyMatrix4x4.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));
            }
コード例 #8
0
            private static IEnumerable <TestCaseData> IndicesTestCases()
            {
                var matrix = RefReadOnlyMatrix4x4.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)
                }));
コード例 #9
0
            private static IEnumerable <TestCaseData> ItemsIPredicateTestCases()
            {
                var matrix = RefReadOnlyMatrix4x4.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 void TestFindAll <Index2DCollection, FloatPredicate>(
     RefReadOnlyMatrix4x4 matrix, FloatPredicate match, Index2DCollection expected)
     where Index2DCollection : ICollection <Index2D>, new()
     where FloatPredicate : struct, IPredicate <float>
 => CollectionAssert.AreEqual(expected, matrix.FindAllIndices <
                                  float, Index2DCollection, RefReadOnlyMatrix4x4, FloatPredicate>(match));
 public static bool Test(RefReadOnlyMatrix4x4 matrix, Predicate <float> match)
 => matrix.TrueForAll(match);
 public static bool Test <FloatPredicate>(
     RefReadOnlyMatrix4x4 matrix, FloatPredicate match)
     where FloatPredicate : struct, IPredicate <float>
 => matrix.Exists <float, RefReadOnlyMatrix4x4, FloatPredicate>(match);
コード例 #13
0
 public static void TestFindAll <FloatCollection>(
     RefReadOnlyMatrix4x4 matrix, Predicate <float> match, FloatCollection expected)
     where FloatCollection : ICollection <float>, new()
 => CollectionAssert.AreEqual(expected, matrix.FindAll <
                                  float, FloatCollection, RefReadOnlyMatrix4x4>(match));
 public static void Index2DBounds2DThrowsExceptionIfSectorIsOutOfBounds(
     RefReadOnlyMatrix4x4 matrix, Index2D startIndex, Bounds2D sector)
 => Assert.Throws <ArgumentOutOfRangeException>(
     () => matrix.FindIndex <
         float, RefReadOnlyMatrix4x4, AlwaysTruePredicate <float> >(
         startIndex, sector, new AlwaysTruePredicate <float>()));
コード例 #15
0
 public static void Index2DBounds2DThrowsExceptionIfStartIndexIsOutOfBounds(
     RefReadOnlyMatrix4x4 matrix, Index2D startIndex)
 => Assert.Throws <ArgumentOutOfRangeException>(
     () => matrix.FindLastIndex <float, RefReadOnlyMatrix4x4>(
         startIndex, new Bounds2D(), o => true));
 public static ItemRequestResult <Index2D> Test(
     RefReadOnlyMatrix4x4 matrix,
     Index2D startIndex,
     Bounds2D sector,
     Predicate <float> match)
 => matrix.FindIndex(startIndex, sector, match);
 public static ItemRequestResult <Index2D> Test <FloatPredicate>(
     RefReadOnlyMatrix4x4 matrix, FloatPredicate match)
     where FloatPredicate : struct, IPredicate <float>
 => matrix.FindIndex <float, RefReadOnlyMatrix4x4, FloatPredicate>(match);
 public static void Index2DBounds2DThrowsExceptionIfSectorIsOutOfBounds(
     RefReadOnlyMatrix4x4 matrix, Index2D startIndex, Bounds2D sector)
 => Assert.Throws <ArgumentOutOfRangeException>(
     () => matrix.FindIndex <float, RefReadOnlyMatrix4x4>(
         startIndex, sector, o => true));
 public static ItemRequestResult <Index2D> Test(
     RefReadOnlyMatrix4x4 matrix, Predicate <float> match)
 => matrix.FindIndex(match);
 public static bool Test(RefReadOnlyMatrix4x4 matrix, Predicate <float> match)
 => matrix.Exists(match);
 public static void GetColumnThrowExceptionIfIndexExceedsColumns(
     RefReadOnlyMatrix4x4 matrix, int index)
 => Assert.Throws <ArgumentOutOfRangeException>(
     () => matrix.GetColumn <float, RefReadOnlyMatrix4x4>(index));
 public static void GetColumnTest(
     RefReadOnlyMatrix4x4 matrix,
     int index,
     RefReadOnlyColumn <float, RefReadOnlyMatrix4x4> expected)
 => CollectionAssert.AreEqual(
     expected, matrix.GetColumn <float, RefReadOnlyMatrix4x4>(index));