예제 #1
0
        public void CloneWithList()
        {
            var dl = new DenseList <int> {
                1, 2, 3, 4, 5, 6
            };
            var cloned = dl.Clone();

            cloned.Add(7);
            Assert.IsTrue(cloned.HasList);
            Assert.AreEqual(
                new int[] { 1, 2, 3, 4, 5, 6 },
                dl.ToArray()
                );
            Assert.AreEqual(
                new int[] { 1, 2, 3, 4, 5, 6, 7 },
                cloned.ToArray()
                );
        }
예제 #2
0
        public void CloneWithoutList()
        {
            var dl = new DenseList <int> {
                1, 2
            };
            var cloned = dl.Clone();

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