Example #1
0
        public void Partition_Orders()
        {
            int p;
            var tokens      = new Token[100000];
            var partitioner = new Partitioner();

            for (var i = 0; i < 100000; i++)
            {
                tokens[i] = new Token(null, null, 1 - i, 0, 0, 0);
            }
            p = partitioner.Partition(tokens, 100000, 3000);
            Assert.AreEqual(p, 2999);
            TestSorted(tokens, p);

            for (var i = 0; i < 100000; i++)
            {
                tokens[i] = new Token(null, null, i, 0, 0, 0);
            }
            p = partitioner.Partition(tokens, 100000, 3000);
            Assert.AreEqual(p, 2999);
            TestSorted(tokens, p);

            for (var i = 0; i < 100000; i++)
            {
                tokens[i] = new Token(null, null, 0, 0, 0, 0);
            }
            p = partitioner.Partition(tokens, 100000, 3000);
            Assert.AreEqual(p, 2999);
            TestSorted(tokens, p);

            for (var i = 0; i < 100000; i++)
            {
                tokens[i] = new Token(null, null, (float)Java.Random(), 0, 0, 0);
            }
            p = partitioner.Partition(tokens, 100000, 3000);
            Assert.AreEqual(p, 2999);
            TestSorted(tokens, p);
        }