Ejemplo n.º 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]);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
        public void Construct_DoesNothing_ForEmptyArray()
        {
            var array = new int[] { };

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

            Assert.AreEqual(new int[] { }, array);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 7
0
 public void Construct_ThrowsException_ForOutOfBounds2()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
                                                 ZArray.Construct(new[] { 1 }, 1, 1, EqualityComparer <int> .Default));
 }
Ejemplo n.º 8
0
 public void Construct_ThrowsException_ForNullComparer()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           ZArray.Construct(new[] { 1 }, 0, 1, null));
 }
Ejemplo n.º 9
0
 public void Construct_ThrowsException_ForNullArray()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           ZArray.Construct(null, 1, 1, EqualityComparer <int> .Default));
 }
Ejemplo n.º 10
0
 public void Construct_ThrowsException_ForNegativeStartIndex()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
                                                 ZArray.Construct(new[] { 1 }, -1, 1, EqualityComparer <int> .Default));
 }