Example #1
0
        public void TestParamsCtorSumThreeZeroes()
        {
            var c = new ArrayVar11(1, 0, 1, 1, 2, 0, 4, 1, 0, 2, 3);

            Assert.That(c.Count, Is.EqualTo(11));

            Assert.That(c.SumFromFirstZeroToLastZero(), Is.EqualTo(9));
            Assert.That(c.SumFromFirstZeroToLastZeroLinq(), Is.EqualTo(9));
        }
Example #2
0
        public void TestIEnumerableCtor()
        {
            var c = new ArrayVar11(
                Enumerable.Range(0, 5)
                .Prepend(10)
                .Append(0)
                .Append(11)
                .Select(u => (double)u)
                );

            Assert.That(c.Array, Is.EqualTo(new[] { 10d, 0, 1, 2, 3, 4, 0, 11 }));
            Assert.That(c.SumFromFirstZeroToLastZero(), Is.EqualTo(10).Within(1e-10));
        }