コード例 #1
0
        public void NullArrayTest()
        {
            bool catchException = false;

            try
            {
                AlgosFromCodility.PrefixSum(null);
            }
            catch (ArgumentNullException)
            {
                catchException = true;
            }

            if (catchException)
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail();
            }
        }
コード例 #2
0
        public void SliceNullArrayTest()
        {
            bool catchException = false;

            try
            {
                AlgosFromCodility.TotalOfSlice(null, 1, 5);
            }
            catch (ArgumentNullException)
            {
                catchException = true;
            }

            if (catchException)
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail();
            }
        }
コード例 #3
0
        public void NullArayExceptionTest()
        {
            bool catchException = false;

            try
            {
                AlgosFromCodility.MashroomPicker(null, 5, 10);
            }
            catch (ArgumentNullException)
            {
                catchException = true;
            }

            if (catchException)
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail();
            }
        }
コード例 #4
0
        public void WrongStartPositionTest()
        {
            bool catchException = false;

            try
            {
                AlgosFromCodility.MashroomPicker(new int[] { 2, 3, 7, 5, 1, 3, 9 }, 8, 10);
            }
            catch (ArgumentOutOfRangeException)
            {
                catchException = true;
            }

            if (catchException)
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail();
            }
        }
コード例 #5
0
        public void YBiggerThenArrayLengthTest()
        {
            bool catchException = false;

            try
            {
                AlgosFromCodility.TotalOfSlice(new long[3], 0, 5);
            }
            catch (ArgumentOutOfRangeException)
            {
                catchException = true;
            }

            if (catchException)
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail();
            }
        }
コード例 #6
0
 public void NegativeArrayTest()
 {
     Assert.AreEqual(new long[] { 0, -5, 5, 8 }, AlgosFromCodility.PrefixSum(new int[] { -5, 10, 3 }));
 }
コード例 #7
0
 public void EmptyArrayTest()
 {
     Assert.AreEqual(new long[1], AlgosFromCodility.PrefixSum(new int[0]));
 }
コード例 #8
0
 public void TwoElementsTest()
 {
     int[] A = new[] { 5, 8 };
     Assert.AreEqual(new long[] { 0, 5, 13 }, AlgosFromCodility.PrefixSum(A));
 }
コード例 #9
0
 public void OneElementTest()
 {
     Assert.AreEqual(new long [] { 0, 10 }, AlgosFromCodility.PrefixSum(new [] { 10 }));
 }
コード例 #10
0
 public void ExampleTest()
 {
     Assert.AreEqual(new long [] { 0, 1, 3, 6, 10, 15, 21 }, AlgosFromCodility.PrefixSum(Enumerable.Range(1, 6).ToArray()));
 }
コード例 #11
0
 public void NegativeSliceTest()
 {
     Assert.AreEqual(5, AlgosFromCodility.TotalOfSlice(new long[] { 0, -5, 5, 8 }, 0, 1));
 }
コード例 #12
0
 public void OneElementSliceTest()
 {
     Assert.AreEqual(4, AlgosFromCodility.TotalOfSlice(new long[] { 0, 1, 3, 6, 10, 15, 21 }, 3, 3));
 }
コード例 #13
0
 public void ExampleSliceTest()
 {
     Assert.AreEqual(12, AlgosFromCodility.TotalOfSlice(new long[] { 0, 1, 3, 6, 10, 15, 21 }, 2, 4));
 }
コード例 #14
0
 public void TwoPlaceTest()
 {
     Assert.AreEqual(5, AlgosFromCodility.MashroomPicker(new [] { 2, 3 }, 0, 10));
 }
コード例 #15
0
 public void TwoStepsTest()
 {
     Assert.AreEqual(13, AlgosFromCodility.MashroomPicker(A, 4, 2));
 }
コード例 #16
0
 public void ZeroStepsTest()
 {
     Assert.AreEqual(9, AlgosFromCodility.MashroomPicker(A, 6, 0));
 }
コード例 #17
0
 public void OneStepTest()
 {
     Assert.AreEqual(12, AlgosFromCodility.MashroomPicker(A, 6, 1));
 }
コード例 #18
0
 public void ExampleTest()
 {
     Assert.AreEqual(25, AlgosFromCodility.MashroomPicker(A, 4, 6));
 }