예제 #1
0
        public void IfThenElse()
        {
            // arrange
            const int NumElements   = 4;
            var       conditionData = new[] { false, true, false, true };
            var       targetData    = new int[NumElements];
            var       ifTrueData    = new[] { 1, 2, 3, 4 };
            var       ifFalseData   = new[] { 5, 6, 7, 8 };

            var condition = new DataAndLayout <bool>(conditionData, new FastAccess(new Layout(new int[] { 4 }, 0, new int[] { 1 })));
            var target    = new DataAndLayout <int>(targetData, new FastAccess(new Layout(new int[] { 4 }, 0, new int[] { 1 })));
            var ifTrue    = new DataAndLayout <int>(ifTrueData, new FastAccess(new Layout(new int[] { 4 }, 0, new int[] { 1 })));
            var ifFalse   = new DataAndLayout <int>(ifFalseData, new FastAccess(new Layout(new int[] { 4 }, 0, new int[] { 1 })));

            // action
            ScalarOps.IfThenElse(target, condition, ifTrue, ifFalse);

            // assert
            CollectionAssert.AreEqual(new[] { 5, 2, 7, 4 }, targetData);
        }