Example #1
0
        public int PartitionedListAddOnly()
        {
            var l = new PartitionedList <int>(N, 18000);

            for (int i = 0; i < N; ++i)
            {
                l.Append(i);
            }

            return(l.Count());
        }
        public void CountTestWithExactInitialCapacity()
        {
            Prop.ForAll <int[]>(xs =>
            {
                var pList = new PartitionedList <int>(xs.Length, 1000);
                foreach (var x in xs)
                {
                    pList.Append(x);
                }

                return(xs.Length == pList.Count());
            }).QuickCheckThrowOnFailure();
        }
        public void NoOfBucketsInControl2()
        {
            var rand = new System.Random();

            Prop.ForAll <int[]>(xs =>
            {
                var pList = new PartitionedList <int>(0, 1000);
                foreach (var x in xs)
                {
                    pList.Append(x);
                }

                int expectedBuckets = (xs.Length / 1000) + ((xs.Length % 1000) > 0 ? 1 : 0);
                return(pList.NoOfBuckets() == expectedBuckets);
            }).QuickCheckThrowOnFailure();
        }
        public void InsertionAndRetrievalOrderMatch()
        {
            Prop.ForAll <int[]>(xs =>
            {
                var pList = new PartitionedList <int>(xs.Length, 1000);
                foreach (var x in xs)
                {
                    pList.Append(x);
                }

                int i = 0;
                foreach (var y in pList)
                {
                    Assert.AreEqual(xs[i], y);
                    i++;
                }
            }).QuickCheckThrowOnFailure();
        }
        public void NoOfBucketsInControl()
        {
            Prop.ForAll <int[], int>((xs, bucketSize) =>
            {
                if (bucketSize <= 0)
                {
                    bucketSize = 1;
                }

                var pList = new PartitionedList <int>(xs.Length, bucketSize);
                foreach (var x in xs)
                {
                    pList.Append(x);
                }

                int expectedBuckets = (xs.Length / bucketSize) + ((xs.Length % bucketSize) > 0 ? 1 : 0);
                return(pList.NoOfBuckets() == expectedBuckets);
            }).QuickCheckThrowOnFailure();
        }
        public void BucketSize()
        {
            var rand = new System.Random();

            Prop.ForAll <int[]>(xs =>
            {
                var pList = new PartitionedList <int>(0, 1000);
                foreach (var x in xs)
                {
                    pList.Append(x);
                }

                foreach (var bucket in pList.Buckets())
                {
                    if (1000 < bucket.Count())
                    {
                        Assert.Fail();
                    }
                }
            }).QuickCheckThrowOnFailure();
        }
Example #7
0
        public long PartitionedListAddAndIterate()
        {
            var l = new PartitionedList <int>(N, 18000);

            for (int i = 0; i < N; ++i)
            {
                l.Append(i);
            }

            long sum = 0;

            foreach (var i in l)
            {
                sum += i;
            }

            if (sum != ((long)N * (N - 1)) / 2)
            {
                throw new Exception("Sum is not equal");
            }

            return(sum);
        }