Esempio n. 1
0
        public static void TestStableSortWithNoOrder()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "b",
                "c",
                "a",
                "d"
            };

            strings.StableSort();

            Assert.AreEqual("b,c,a,d", strings.ToString());
        }
Esempio n. 2
0
        public static void TestStableSortWithNoOrder()
        {
            OrderableStrings strings = new OrderableStrings();

            strings.Add("b");
            strings.Add("c");
            strings.Add("a");
            strings.Add("d");

            strings.StableSort();

            // Verify order is the expected one
            Assert.AreEqual(strings[0], "b");
            Assert.AreEqual(strings[1], "c");
            Assert.AreEqual(strings[2], "a");
            Assert.AreEqual(strings[3], "d");
        }
Esempio n. 3
0
        public static void TestStableSortWithOrder()
        {
            OrderableStrings strings = new OrderableStrings();

            strings.Add("b");
            strings.Add("c", 1);
            strings.Add("a");
            strings.Add("d", -1);
            strings.Add("e");
            strings.Add("g", 2);
            strings.Add("f", -2);

            strings.StableSort();

            // Verify order is the expected one
            Assert.AreEqual(strings[0], "f");
            Assert.AreEqual(strings[1], "d");
            Assert.AreEqual(strings[2], "b");
            Assert.AreEqual(strings[3], "a");
            Assert.AreEqual(strings[4], "e");
            Assert.AreEqual(strings[5], "c");
            Assert.AreEqual(strings[6], "g");
        }
Esempio n. 4
0
        public static void TestStableSortWithOrder()
        {
            OrderableStrings strings = new OrderableStrings
            {
                "b",
                { "c", 1 },
                "a",
                { "d", -1 },
                "e",
                { "g", 2 },
                { "f", -2 }
            };

            strings.StableSort();

            Assert.AreEqual("f", strings[0]);
            Assert.AreEqual("d", strings[1]);
            Assert.AreEqual("b", strings[2]);
            Assert.AreEqual("a", strings[3]);
            Assert.AreEqual("e", strings[4]);
            Assert.AreEqual("c", strings[5]);
            Assert.AreEqual("g", strings[6]);
        }