Exemple #1
0
        public void Reverse()
        {
            var mutable = ImmutableSegmentedList.CreateRange(Enumerable.Range(1, 3)).ToBuilder();

            mutable.Reverse();
            Assert.Equal(Enumerable.Range(1, 3).Reverse(), mutable);
        }
Exemple #2
0
 public void IndexOf()
 {
     IndexOfTests.IndexOfTest(
         seq => ImmutableSegmentedList.CreateRange(seq).ToBuilder(),
         (b, v) => b.IndexOf(v),
         (b, v, i) => b.IndexOf(v, i),
         (b, v, i, c) => b.IndexOf(v, i, c),
         (b, v, i, c, eq) => b.IndexOf(v, i, c, eq));
 }
Exemple #3
0
 public void LastIndexOf()
 {
     IndexOfTests.LastIndexOfTest(
         seq => ImmutableSegmentedList.CreateRange(seq).ToBuilder(),
         (b, v) => b.LastIndexOf(v),
         (b, v, eq) => b.LastIndexOf(v, b.Count > 0 ? b.Count - 1 : 0, b.Count, eq),
         (b, v, i) => b.LastIndexOf(v, i),
         (b, v, i, c) => b.LastIndexOf(v, i, c),
         (b, v, i, c, eq) => b.LastIndexOf(v, i, c, eq));
 }
Exemple #4
0
        public void Clear()
        {
            var mutable = ImmutableSegmentedList.CreateRange(Enumerable.Range(1, 3)).ToBuilder();

            mutable.Clear();
            Assert.Equal(0, mutable.Count);

            // Do it again for good measure. :)
            mutable.Clear();
            Assert.Equal(0, mutable.Count);
        }
        public void Indexer()
        {
            var list = ImmutableSegmentedList.CreateRange(Enumerable.Range(1, 3));

            Assert.Equal(1, list[0]);
            Assert.Equal(2, list[1]);
            Assert.Equal(3, list[2]);

            Assert.Throws <ArgumentOutOfRangeException>("index", () => list[3]);
            Assert.Throws <ArgumentOutOfRangeException>("index", () => list[-1]);

            Assert.Equal(3, ((IList)list)[2]);
            Assert.Equal(3, ((IList <int>)list)[2]);
        }
 public void IndexOf()
 {
     IndexOfTests.IndexOfTest(
         seq => ImmutableSegmentedList.CreateRange(seq),
         (b, v) => b.IndexOf(v),
         (b, v, i) => System.Collections.Immutable.ImmutableList.IndexOf(b, v, i),
         (b, v, i, c) => System.Collections.Immutable.ImmutableList.IndexOf(b, v, i, c),
         (b, v, i, c, eq) => b.IndexOf(v, i, c, eq));
     IndexOfTests.IndexOfTest(
         seq => (System.Collections.Immutable.IImmutableList <int>)ImmutableSegmentedList.CreateRange(seq),
         (b, v) => b.IndexOf(v),
         (b, v, i) => System.Collections.Immutable.ImmutableList.IndexOf(b, v, i),
         (b, v, i, c) => System.Collections.Immutable.ImmutableList.IndexOf(b, v, i, c),
         (b, v, i, c, eq) => b.IndexOf(v, i, c, eq));
 }
Exemple #7
0
        public void Indexer()
        {
            var mutable = ImmutableSegmentedList.CreateRange(Enumerable.Range(1, 3)).ToBuilder();

            Assert.Equal(2, mutable[1]);
            mutable[1] = 5;
            Assert.Equal(5, mutable[1]);
            mutable[0] = -2;
            mutable[2] = -3;
            Assert.Equal(new[] { -2, 5, -3 }, mutable);

            Assert.Throws <ArgumentOutOfRangeException>("index", () => mutable[3]  = 4);
            Assert.Throws <ArgumentOutOfRangeException>("index", () => mutable[-1] = 4);
            Assert.Throws <ArgumentOutOfRangeException>("index", () => mutable[3]);
            Assert.Throws <ArgumentOutOfRangeException>("index", () => mutable[-1]);
        }
        public void Create()
        {
            var comparer = StringComparer.OrdinalIgnoreCase;

            ImmutableSegmentedList <string> list = ImmutableSegmentedList.Create <string>();

            Assert.Equal(0, list.Count);

            list = ImmutableSegmentedList.Create("a");
            Assert.Equal(1, list.Count);

            list = ImmutableSegmentedList.Create("a", "b");
            Assert.Equal(2, list.Count);

            list = ImmutableSegmentedList.CreateRange((IEnumerable <string>) new[] { "a", "b" });
            Assert.Equal(2, list.Count);
        }