Exemple #1
0
        public void Construct_ReturnsTheLengthOfArrayAsElementZero([NotNull] string s, int start, int length)
        {
            var sequence = s.AsList();
            var z        = ZArray.Construct(sequence, start, length, EqualityComparer <char> .Default);

            Assert.AreEqual(length, z[0]);
        }
Exemple #2
0
        public void Construct_ReturnsAnArrayOfTheSameLengthAsInput([NotNull] string s, int start, int length)
        {
            var sequence = s.AsList();
            var z        = ZArray.Construct(sequence, start, length, EqualityComparer <char> .Default);

            Assert.AreEqual(z.Length, length);
        }
Exemple #3
0
        public void Construct_DoesNothing_ForZeroLength()
        {
            var array = new[] { 1, 2 };

            ZArray.Construct(array, 1, 0, EqualityComparer <int> .Default);

            Assert.AreEqual(new[] { 1, 2 }, array);
        }
Exemple #4
0
        public void Construct_DoesNothing_ForEmptyArray()
        {
            var array = new int[] { };

            ZArray.Construct(array, 0, 0, EqualityComparer <int> .Default);

            Assert.AreEqual(new int[] { }, array);
        }
Exemple #5
0
        public void Construct_ReturnsAWellFormedZArray_WhenLengthIsTouched()
        {
            // ReSharper disable once StringLiteralTypo
            var sequence = "abcaababc".AsList();
            var z        = ZArray.Construct(sequence, 0, sequence.Count - 1, EqualityComparer <char> .Default);

            TestHelper.AssertSequence(z,
                                      8, 0, 0, 1, 2, 0, 2, 0);
        }
Exemple #6
0
        public void Construct_ReturnsADecreasingSequence_ForArrayOfSameChars()
        {
            // ReSharper disable once StringLiteralTypo
            var sequence = "aaaaaaaa".AsList();
            var z        = ZArray.Construct(sequence, 0, sequence.Count, EqualityComparer <char> .Default);

            TestHelper.AssertSequence(z,
                                      8, 7, 6, 5, 4, 3, 2, 1);
        }
Exemple #7
0
 public void Construct_ThrowsException_ForOutOfBounds2()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
                                                 ZArray.Construct(new[] { 1 }, 1, 1, EqualityComparer <int> .Default));
 }
Exemple #8
0
 public void Construct_ThrowsException_ForNullComparer()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           ZArray.Construct(new[] { 1 }, 0, 1, null));
 }
Exemple #9
0
 public void Construct_ThrowsException_ForNullArray()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           ZArray.Construct(null, 1, 1, EqualityComparer <int> .Default));
 }
Exemple #10
0
 public void Construct_ThrowsException_ForNegativeStartIndex()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
                                                 ZArray.Construct(new[] { 1 }, -1, 1, EqualityComparer <int> .Default));
 }