Exemple #1
0
        public static void EnsureCapacityTest()
        {
            var valueList = new ValueList <int>(new int[] { 1, 2, 3 });

            valueList.EnsureCapacity(-1);

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(3)
                        .And.Count.EqualTo(3)
                        );

            valueList.EnsureCapacity(0);

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(3)
                        .And.Count.EqualTo(3)
                        );

            valueList.EnsureCapacity(3);

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(3)
                        .And.Count.EqualTo(3)
                        );

            valueList.EnsureCapacity(4);

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(6)
                        .And.Count.EqualTo(3)
                        );

            valueList.EnsureCapacity(16);

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(16)
                        .And.Count.EqualTo(3)
                        );
        }
Exemple #2
0
        public static void TrimExcessTest()
        {
            var valueList = new ValueList <int>(new int[] { 1, 2, 3 });

            valueList.TrimExcess();

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(3)
                        .And.Count.EqualTo(3)
                        );

            valueList.Add(4);
            valueList.Add(5);

            valueList.TrimExcess();

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(5)
                        .And.Count.EqualTo(5)
                        );

            valueList.EnsureCapacity(15);
            valueList.TrimExcess(0.3f);

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(15)
                        .And.Count.EqualTo(5)
                        );

            valueList = new ValueList <int>();
            valueList.TrimExcess();

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(0)
                        .And.Count.EqualTo(0)
                        );
        }