Esempio n. 1
0
        public void Clear()
        {
            var l = new DenseList <int> {
                1, 2
            };

            l.Clear();
            Assert.AreEqual(
                new int[0],
                l.ToArray()
                );

            l.Add(1);
            l.Add(2);
            Assert.AreEqual(
                new int[] { 1, 2 },
                l.ToArray()
                );
        }
Esempio n. 2
0
        public void AddItemsAndTransition()
        {
            var l = new DenseList <int>();

            l.Add(0);
            l.Add(2);
            l.Add(3);
            l.Add(5);

            Assert.IsFalse(l.HasList);

            Assert.AreEqual(
                new int[] { 0, 2, 3, 5 },
                l.ToArray()
                );

            l.Add(7);
            l.Add(9);

            Assert.IsTrue(l.HasList);

            Assert.AreEqual(
                new int[] { 0, 2, 3, 5, 7, 9 },
                l.ToArray()
                );
        }
Esempio n. 3
0
        public void CopyToWithList()
        {
            var dl = new DenseList <int> {
                1, 2, 3, 4, 5, 6
            };
            var destination = new DenseList <int> {
                7, 8, 9, 10, 11
            };

            dl.CopyTo(ref destination);
            destination.Add(12);
            Assert.IsTrue(destination.HasList);
            Assert.AreEqual(
                new int[] { 1, 2, 3, 4, 5, 6 },
                dl.ToArray()
                );
            Assert.AreEqual(
                new int[] { 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 6, 12 },
                destination.ToArray()
                );
        }
Esempio n. 4
0
        public void CopyToWithoutList()
        {
            var dl = new DenseList <int> {
                1
            };
            var destination = new DenseList <int> {
                2, 3
            };

            dl.CopyTo(ref destination);
            destination.Add(4);
            Assert.IsFalse(dl.HasList);
            Assert.IsFalse(destination.HasList);
            Assert.AreEqual(
                new int[] { 1 },
                dl.ToArray()
                );
            Assert.AreEqual(
                new int[] { 2, 3, 1, 4 },
                destination.ToArray()
                );
        }