示例#1
0
        public static void RunTests()
        {
            //This mostly follows the format established by the original author of these tests

            Test test = new Test();

            Driver <int, int> IntDriver = new Driver <int, int>(test);
            Driver <SimpleRef <String>, SimpleRef <String> > simpleRef = new Driver <SimpleRef <String>, SimpleRef <String> >(test);
            Driver <SimpleRef <int>, SimpleRef <int> >       simpleVal = new Driver <SimpleRef <int>, SimpleRef <int> >(test);

            SimpleRef <int>[]    simpleInts;
            SimpleRef <String>[] simpleStrings;
            int[] ints;
            int   count;

            count         = 1000;
            simpleInts    = SortedListUtils.GetSimpleInts(count);
            simpleStrings = SortedListUtils.GetSimpleStrings(count);
            ints          = new int[count];
            for (int i = 0; i < count; i++)
            {
                ints[i] = i;
            }


            //IsFixedSize
            //Scenario 1: Vanilla - Ensure that this returns false for an empty SortedList
            //Scenario 2: Do item manipulations in the SortedList and ensure that this property is still false
            IntDriver.NonGenericIDictionaryTestFixedSize(ints, ints);
            simpleRef.NonGenericIDictionaryTestFixedSize(simpleStrings, simpleStrings);
            simpleVal.NonGenericIDictionaryTestFixedSize(simpleInts, simpleInts);

            //IsReadOnly
            //Scenario 1: Vanilla - Ensure that this returns false for an empty SortedList
            //Scenario 2: Do item manipulations in the SortedList and ensure that this property is still false
            IntDriver.TestReadOnly(ints, ints);
            simpleRef.TestReadOnly(simpleStrings, simpleStrings);
            simpleVal.TestReadOnly(simpleInts, simpleInts);
            IntDriver.NonGenericIDictionaryTestReadOnly(ints, ints);
            simpleRef.NonGenericIDictionaryTestReadOnly(simpleStrings, simpleStrings);
            simpleVal.NonGenericIDictionaryTestReadOnly(simpleInts, simpleInts);

            //Scenario 1: Check for properties and methods that return a reference to the underlying SortedList, the SyncRoot property is the same as
            //the original SortedList
            //@NOTE: After the modified design, SortedList doesn't have any members that return a reference to the underlying SortedList

            Assert.True(test.result);
        }
示例#2
0
        public static void RunTests()
        {
            Test test = new Test();

            Driver <string, string> driver1 = new Driver <string, string>(test);
            Driver <SimpleRef <int>, SimpleRef <String> >    driver2 = new Driver <SimpleRef <int>, SimpleRef <String> >(test);
            Driver <SimpleRef <String>, SimpleRef <int> >    driver3 = new Driver <SimpleRef <String>, SimpleRef <int> >(test);
            Driver <SimpleRef <int>, SimpleRef <int> >       driver4 = new Driver <SimpleRef <int>, SimpleRef <int> >(test);
            Driver <SimpleRef <String>, SimpleRef <String> > driver5 = new Driver <SimpleRef <String>, SimpleRef <String> >(test);

            //Create a SD with default capacity and other capacities and verify
            SimpleRef <int>[]    simpleInts;
            SimpleRef <String>[] simpleStrings;
            string[]             strings;
            int count;

            count         = 100;
            simpleInts    = SortedListUtils.GetSimpleInts(count);
            simpleStrings = SortedListUtils.GetSimpleStrings(count);
            strings       = new string[count];
            for (int i = 0; i < count; i++)
            {
                strings[i] = i.ToString();
            }

            driver1.TestVanilla();
            driver2.TestVanilla();
            driver3.TestVanilla();
            driver4.TestVanilla();
            driver5.TestVanilla();

            //Test for capacities with capacity constructor after adding items
            driver1.TestCapacity(strings, strings);
            driver2.TestCapacity(simpleInts, simpleStrings);
            driver3.TestCapacity(simpleStrings, simpleInts);
            driver4.TestCapacity(simpleInts, simpleInts);
            driver5.TestCapacity(simpleStrings, simpleStrings);

            //Test for capacity growth with set starting capacity
            driver1.TestCapacityPresetValue(strings, strings, 0);
            driver1.TestCapacityPresetValue(strings, strings, 1);
            driver1.TestCapacityPresetValue(strings, strings, 16);
            driver1.TestCapacityPresetValue(strings, strings, 20);
            driver1.TestCapacityPresetValue(strings, strings, 160);

            //Test setting capacity after default
            driver1.TestVanillaSet();
            driver2.TestVanillaSet();
            driver3.TestVanillaSet();
            driver4.TestVanillaSet();
            driver5.TestVanillaSet();

            //Test parameter validation for set
            driver1.TestParmValidation(strings, strings);
            driver2.TestParmValidation(simpleInts, simpleStrings);
            driver3.TestParmValidation(simpleStrings, simpleInts);
            driver4.TestParmValidation(simpleInts, simpleInts);
            driver5.TestParmValidation(simpleStrings, simpleStrings);

            //Test for capacity when cleared
            driver1.TestCapacityWhenCleared(strings, strings, 0);
            driver1.TestCapacityWhenCleared(strings, strings, 1);
            driver1.TestCapacityWhenCleared(strings, strings, 16);
            driver1.TestCapacityWhenCleared(strings, strings, 20);
            driver1.TestCapacityWhenCleared(strings, strings, 160);

            Assert.True(test.result);
        }
示例#3
0
文件: This.cs 项目: yang73137/corefx
        public static void RunTests()
        {
            //This mostly follows the format established by the original author of these tests

            Test test = new Test();


            //Scenario 1: Vanilla - check that existing values can be accessed via the key

            Driver <int, int> IntDriver = new Driver <int, int>(test);
            Driver <SimpleRef <String>, SimpleRef <String> > simpleRef = new Driver <SimpleRef <String>, SimpleRef <String> >(test);
            Driver <SimpleRef <int>, SimpleRef <int> >       simpleVal = new Driver <SimpleRef <int>, SimpleRef <int> >(test);

            SimpleRef <int>[]    simpleInts;
            SimpleRef <String>[] simpleStrings;
            int[] ints;
            int   count;

            count         = 1000;
            simpleInts    = SortedListUtils.GetSimpleInts(count);
            simpleStrings = SortedListUtils.GetSimpleStrings(count);
            ints          = new int[count];
            for (int i = 0; i < count; i++)
            {
                ints[i] = i;
            }

            IntDriver.TestVanilla(ints, ints);
            simpleRef.TestVanilla(simpleStrings, simpleStrings);
            simpleVal.TestVanilla(simpleInts, simpleInts);
            IntDriver.NonGenericIDictionaryTestVanilla(ints, ints);
            simpleRef.NonGenericIDictionaryTestVanilla(simpleStrings, simpleStrings);
            simpleVal.NonGenericIDictionaryTestVanilla(simpleInts, simpleInts);

            //Scenario 2: Check that the existing values can be modified via the key
            //Scneario 3: Check that non-existing values are created via set
            IntDriver.TestModify(ints, ints);
            simpleRef.TestModify(simpleStrings, simpleStrings);
            simpleVal.TestModify(simpleInts, simpleInts);
            IntDriver.NonGenericIDictionaryTestModify(ints, ints);
            simpleRef.NonGenericIDictionaryTestModify(simpleStrings, simpleStrings);
            simpleVal.NonGenericIDictionaryTestModify(simpleInts, simpleInts);

            //Scenario 4: Check the returned value for non existing keys
            SimpleRef <int>[]    simpleInts_1;
            SimpleRef <String>[] simpleStrings_1;
            int[]                ints_1;
            SimpleRef <int>[]    simpleInts_2;
            SimpleRef <String>[] simpleStrings_2;
            int[]                ints_2;

            int half = count / 2;

            simpleInts_1    = new SimpleRef <int> [half];
            simpleStrings_1 = new SimpleRef <String> [half];
            ints_2          = new int[half];
            simpleInts_2    = new SimpleRef <int> [half];
            simpleStrings_2 = new SimpleRef <String> [half];
            ints_1          = new int[half];
            for (int i = 0; i < half; i++)
            {
                simpleInts_1[i]    = simpleInts[i];
                simpleStrings_1[i] = simpleStrings[i];
                ints_1[i]          = ints[i];

                simpleInts_2[i]    = simpleInts[i + half];
                simpleStrings_2[i] = simpleStrings[i + half];
                ints_2[i]          = ints[i + half];
            }

            IntDriver.TestNonExistentKeys(ints_1, ints_1, ints_2);
            simpleRef.TestNonExistentKeys(simpleStrings_1, simpleStrings_1, simpleStrings_2);
            simpleVal.TestNonExistentKeys(simpleInts_1, simpleInts_1, simpleInts_2);
            IntDriver.NonGenericIDictionaryTestNonExistentKeys(ints_1, ints_1, ints_2);
            simpleRef.NonGenericIDictionaryTestNonExistentKeys(simpleStrings_1, simpleStrings_1, simpleStrings_2);
            simpleVal.NonGenericIDictionaryTestNonExistentKeys(simpleInts_1, simpleInts_1, simpleInts_2);

            //Scenario 5: Parm validation: null, Empty string
            simpleRef.TestParm(simpleStrings, simpleStrings);
            simpleVal.TestParm(simpleInts, simpleInts);
            simpleRef.NonGenericIDictionaryTestParm(simpleStrings, simpleStrings);
            simpleVal.NonGenericIDictionaryTestParm(simpleInts, simpleInts);
            IntDriver.NonGenericIDictionaryTestParm(ints_1, ints_2);

            Assert.True(test.result);
        }
示例#4
0
文件: Count.cs 项目: yang73137/corefx
        public static void RunTests()
        {
            //This mostly follows the format established by the original author of these tests
            //Also this property is tested elsewhere in most of the other test cases

            Test test = new Test();

            Driver <int, int> driver1 = new Driver <int, int>(test);
            Driver <SimpleRef <int>, SimpleRef <String> >    driver2 = new Driver <SimpleRef <int>, SimpleRef <String> >(test);
            Driver <SimpleRef <String>, SimpleRef <int> >    driver3 = new Driver <SimpleRef <String>, SimpleRef <int> >(test);
            Driver <SimpleRef <int>, SimpleRef <int> >       driver4 = new Driver <SimpleRef <int>, SimpleRef <int> >(test);
            Driver <SimpleRef <String>, SimpleRef <String> > driver5 = new Driver <SimpleRef <String>, SimpleRef <String> >(test);

            //Scenario 1: Vanilla - Add 10 values and check that count is correct

            SimpleRef <int>[]    simpleInts;
            SimpleRef <String>[] simpleStrings;
            int[] ints;
            int   count;

            count         = 10;
            simpleInts    = SortedListUtils.GetSimpleInts(count);
            simpleStrings = SortedListUtils.GetSimpleStrings(count);
            ints          = new int[count];
            for (int i = 0; i < count; i++)
            {
                ints[i] = i;
            }


            driver1.TestVanilla(ints, ints);
            driver2.TestVanilla(simpleInts, simpleStrings);
            driver3.TestVanilla(simpleStrings, simpleInts);
            driver4.TestVanilla(simpleInts, simpleInts);
            driver5.TestVanilla(simpleStrings, simpleStrings);

            //Scenario 2: Add, Clear and check
            driver1.TestAddClear(ints, ints);
            driver2.TestAddClear(simpleInts, simpleStrings);
            driver3.TestAddClear(simpleStrings, simpleInts);
            driver4.TestAddClear(simpleInts, simpleInts);
            driver5.TestAddClear(simpleStrings, simpleStrings);

            //Scenario 3: Stress and check: A large number of values and check
            count         = 1000;
            simpleInts    = SortedListUtils.GetSimpleInts(count);
            simpleStrings = SortedListUtils.GetSimpleStrings(count);
            ints          = new int[count];
            for (int i = 0; i < count; i++)
            {
                ints[i] = i;
            }

            driver1.TestAddClear(ints, ints);
            driver2.TestAddClear(simpleInts, simpleStrings);
            driver3.TestAddClear(simpleStrings, simpleInts);
            driver4.TestAddClear(simpleInts, simpleInts);
            driver5.TestAddClear(simpleStrings, simpleStrings);


            //Scenario 4: Add, remove and clear combinations
            driver1.TestAddRemove(ints, ints);
            driver2.TestAddRemove(simpleInts, simpleStrings);
            driver3.TestAddRemove(simpleStrings, simpleInts);
            driver4.TestAddRemove(simpleInts, simpleInts);
            driver5.TestAddRemove(simpleStrings, simpleStrings);

            Assert.True(test.result);
        }