コード例 #1
0
ファイル: ListTests.cs プロジェクト: guzlewski/Collections
        public void Insert()
        {
            var list   = new List <string>(Globals.Strings);
            var system = new S.List <string>(Globals.Strings);

            Comparer <string> .Compare(list, system);

            try
            {
                list.Insert(Globals.Strings.Length, "");
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException) { }

            try
            {
                list.Insert(-1, "");
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException) { }

            Comparer <string> .Compare(list, system);

            int count = list.Count;

            for (int i = 0; i < count; i++)
            {
                list.Insert(i, i.ToString());
                system.Insert(i, i.ToString());

                Comparer <string> .Compare(list, system);
            }

            Comparer <string> .Compare(list, system);
        }
コード例 #2
0
        public void Set()
        {
            var vector = new Vector <string>(Globals.Strings);
            var system = new S.List <string>(Globals.Strings);

            try
            {
                vector[-1] = null;
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException) { }

            try
            {
                vector[Globals.Strings.Length] = null;
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException) { }

            Comparer <string> .Compare(vector, system);

            for (int i = 0; i < Globals.Strings.Length; i++)
            {
                vector[i] = i.ToString();
                system[i] = i.ToString();

                Comparer <string> .Compare(vector, system);
            }

            Comparer <string> .Compare(vector, system);
        }
コード例 #3
0
        public void PopBack()
        {
            var vector = new Vector <string>(Globals.Strings);
            var system = new S.List <string>(Globals.Strings);

            Comparer <string> .Compare(vector, system);

            for (int i = 0; i < Globals.Strings.Length; i++)
            {
                vector.PopBack();
                system.RemoveAt(Globals.Strings.Length - i - 1);

                Comparer <string> .Compare(vector, system);
            }

            Comparer <string> .Compare(vector, system);

            try
            {
                vector.PopBack();
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException) { }

            Comparer <string> .Compare(vector, system);
        }
コード例 #4
0
ファイル: ListTests.cs プロジェクト: guzlewski/Collections
        public void Get()
        {
            var list   = new List <string>(Globals.Strings);
            var system = new S.List <string>(Globals.Strings);

            Comparer <string> .Compare(list, system);

            try
            {
                var _ = list[-1];
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException) { }

            try
            {
                var _ = list[Globals.Strings.Length];
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException) { }

            Comparer <string> .Compare(list, system);

            for (int i = 0; i < system.Count; i++)
            {
                Assert.IsTrue(list[i] == system[i]);

                Comparer <string> .Compare(list, system);
            }

            Comparer <string> .Compare(list, system);
        }
コード例 #5
0
ファイル: ListTests.cs プロジェクト: guzlewski/Collections
        public void Set()
        {
            var list   = new List <string>(Globals.Strings);
            var system = new S.List <string>(Globals.Strings);

            Comparer <string> .Compare(list, system);

            try
            {
                list[-1] = null;
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException) { }

            try
            {
                list[Globals.Strings.Length] = null;
            }
            catch (ArgumentOutOfRangeException) { }

            Comparer <string> .Compare(list, system);

            for (int i = 0; i < system.Count; i++)
            {
                list[i]   = i.ToString();
                system[i] = i.ToString();

                Comparer <string> .Compare(list, system);
            }

            Comparer <string> .Compare(list, system);
        }
コード例 #6
0
ファイル: ListTests.cs プロジェクト: guzlewski/Collections
        public void AddRange()
        {
            var list   = new List <int>();
            var system = new S.List <int>();

            list.AddRange(Globals.Ints);
            system.AddRange(Globals.Ints);

            Assert.IsTrue(list.Count == system.Count && list.Count == Globals.Ints.Length);
            Comparer <int> .Compare(list, system);
        }
コード例 #7
0
ファイル: ListTests.cs プロジェクト: guzlewski/Collections
        public void ElementAt()
        {
            var list   = new List <char>(Globals.Chars);
            var system = new S.List <char>(Globals.Chars);

            Comparer <char> .Compare(list, system);

            for (int i = 0; i < system.Count; i++)
            {
                Assert.IsTrue(list.ElementAt(i) == system.ElementAt(i));
            }

            Comparer <char> .Compare(list, system);
        }
コード例 #8
0
ファイル: ListTests.cs プロジェクト: guzlewski/Collections
        public void Clear()
        {
            var list   = new List <int>(Globals.Ints);
            var system = new S.List <int>(Globals.Ints);

            Assert.IsTrue(list.Count == Globals.Ints.Length);
            Comparer <int> .Compare(list, system);

            list.Clear();
            system.Clear();

            Assert.IsTrue(list.Count == 0);
            Comparer <int> .Compare(list, system);
        }
コード例 #9
0
        public void Add()
        {
            var vector = new Vector <string>();
            var system = new S.List <string>();

            foreach (var i in Globals.Strings)
            {
                vector.Add(i);
                system.Add(i);

                Comparer <string> .Compare(vector, system);
            }

            Comparer <string> .Compare(vector, system);
        }
コード例 #10
0
ファイル: ListTests.cs プロジェクト: guzlewski/Collections
        public void Contains()
        {
            var list   = new List <char>(Globals.Chars);
            var system = new S.List <char>(Globals.Chars);

            for (char c = '\0'; c < char.MaxValue; c++)
            {
                if (list.Contains(c) != Globals.Chars.Contains(c) || list.Contains(c) != system.Contains(c))
                {
                    Assert.Fail();
                }
            }

            Comparer <char> .Compare(list, system);
        }
コード例 #11
0
        public void AddRange()
        {
            var vector = new Vector <string> {
                "", null, "1"
            };
            var system = new S.List <string> {
                "", null, "1"
            };

            Comparer <string> .Compare(vector, system);

            vector.AddRange(Globals.Strings);
            system.AddRange(Globals.Strings);

            Comparer <string> .Compare(vector, system);
        }
コード例 #12
0
        public void ToArray()
        {
            var vector = new Vector <string>(Globals.Strings);
            var system = new S.List <string>(Globals.Strings);

            Comparer <string> .Compare(vector, system);

            Comparer <string> .Compare(vector, vector);

            var vectorArray = vector.ToArray();
            var systemArray = system.ToArray();

            Comparer <string> .Compare(vectorArray, systemArray);

            Assert.IsTrue(vectorArray.Length == systemArray.Length);
        }
コード例 #13
0
ファイル: ListTests.cs プロジェクト: guzlewski/Collections
        public void Add()
        {
            var list   = new List <int>();
            var system = new S.List <int>();

            foreach (var i in Globals.Ints)
            {
                list.Add(i);
                system.Add(i);

                Comparer <int> .Compare(list, system);
            }

            Assert.IsTrue(list.Count == system.Count && list.Count == Globals.Ints.Length);
            Comparer <int> .Compare(list, system);
        }
コード例 #14
0
ファイル: ListTests.cs プロジェクト: guzlewski/Collections
        public void RemoveAll()
        {
            var list   = new List <char>(Globals.Chars.Concat(Globals.Chars).ToArray());
            var system = new S.List <char>(Globals.Chars.Concat(Globals.Chars).ToArray());

            Comparer <char> .Compare(list, system);

            for (char c = '\0'; c < char.MaxValue; c++)
            {
                list.RemoveAll(x => x == c);
                system.RemoveAll(x => x == c);

                Comparer <char> .Compare(list, system);
            }

            Comparer <char> .Compare(list, system);
        }
コード例 #15
0
        public void GetEnumerator()
        {
            var vector = new Vector <string>(Globals.Strings);
            var system = new S.List <string>(Globals.Strings);

            Comparer <string> .Compare(vector, system);

            int index = 0;

            foreach (var item in vector)
            {
                Assert.IsTrue(item == system[index++]);
                Comparer <string> .Compare(vector, system);
            }

            Comparer <string> .Compare(vector, system);
        }
コード例 #16
0
ファイル: ListTests.cs プロジェクト: guzlewski/Collections
        public void Remove()
        {
            var list   = new List <char>(Globals.Chars);
            var system = new S.List <char>(Globals.Chars);

            Comparer <char> .Compare(list, system);

            for (char c = '\0'; c < char.MaxValue; c++)
            {
                list.Remove(c);
                system.Remove(c);

                Comparer <char> .Compare(list, system);
            }

            Comparer <char> .Compare(list, system);
        }
コード例 #17
0
        public void Remove()
        {
            var vector = new Vector <char>(Globals.Chars);
            var system = new S.List <char>(Globals.Chars);

            Comparer <char> .Compare(vector, system);

            for (char c = '\0'; c < (char)1024; c++)
            {
                vector.Remove(c);
                system.Remove(c);

                Comparer <char> .Compare(vector, system);
            }

            Comparer <char> .Compare(vector, system);
        }
コード例 #18
0
ファイル: ListTests.cs プロジェクト: guzlewski/Collections
        public void IndexOf()
        {
            var list   = new List <char>(Globals.Chars);
            var system = new S.List <char>(Globals.Chars);

            Comparer <char> .Compare(list, system);

            for (char c = '\0'; c < char.MaxValue; c++)
            {
                if (list.IndexOf(c) != system.IndexOf(c))
                {
                    Assert.Fail();
                }
            }

            Comparer <char> .Compare(list, system);
        }
コード例 #19
0
        public void Reverse()
        {
            var vector = new Vector <string>(Globals.Strings);
            var system = new S.List <string>(Globals.Strings);

            Comparer <string> .Compare(vector, system);

            int index = Globals.Strings.Length;

            foreach (var item in vector.Reverse())
            {
                Assert.IsTrue(item == system[--index]);
                Comparer <string> .Compare(vector, system);
            }

            Comparer <string> .Compare(vector, system);
        }
コード例 #20
0
ファイル: ListTests.cs プロジェクト: guzlewski/Collections
        public void Reverse()
        {
            var list   = new List <int>(Globals.Ints);
            var system = new S.List <int>(Globals.Ints);

            Comparer <int> .Compare(list, system);

            int index = Globals.Ints.Length;

            foreach (var i in list.Reverse())
            {
                Assert.IsTrue(i == system[--index]);

                Comparer <int> .Compare(list, system);
            }

            Comparer <int> .Compare(list, system);
        }
コード例 #21
0
        public void Constructor()
        {
            var vector = new Vector <string>();
            var system = new S.List <string>();

            Assert.IsTrue(vector.Count == 0);
            Comparer <string> .Compare(vector, system);

            vector = new Vector <string>(Globals.Strings);
            system = new S.List <string>(Globals.Strings);

            Assert.IsTrue(vector.Count == Globals.Strings.Length);
            Comparer <string> .Compare(vector, system);

            vector = new Vector <string>(34);
            system = new S.List <string>(34);

            Assert.IsTrue(vector.Count == system.Count);
            Assert.IsTrue(vector.Capacity == system.Capacity);
            Comparer <string> .Compare(vector, system);
        }
コード例 #22
0
        public void IndexOf()
        {
            var vector = new Vector <char>(Globals.Chars);
            var system = new S.List <char>(Globals.Chars);

            Comparer <char> .Compare(vector, system);

            for (int i = 0; i < Globals.Chars.Length; i++)
            {
                Assert.IsTrue(vector.IndexOf(Globals.Chars[i]) == i);
            }

            for (int i = 0; i < Globals.Chars.Length; i++)
            {
                Assert.IsTrue(vector.IndexOf(system[i]) == i);
            }

            Assert.IsTrue(vector.IndexOf(' ') == system.IndexOf(' '));

            Comparer <char> .Compare(vector, system);
        }
コード例 #23
0
ファイル: ListTests.cs プロジェクト: guzlewski/Collections
        public void RemoveAt()
        {
            var list   = new List <int>(Globals.Ints);
            var system = new S.List <int>(Globals.Ints);

            Comparer <int> .Compare(list, system);

            try
            {
                list.RemoveAt(Globals.Ints.Length);
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException) { }

            try
            {
                list.RemoveAt(-1);
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException) { }

            Comparer <int> .Compare(list, system);

            Random random = new Random();

            while (system.Count != 0)
            {
                int index = random.Next(0, system.Count);

                list.RemoveAt(index);
                system.RemoveAt(index);

                Comparer <int> .Compare(list, system);
            }

            Comparer <int> .Compare(list, system);
        }