コード例 #1
0
        public static void SortedDictionary_ValueCollectionTest2()
        {
            IntGenerator    intGenerator    = new IntGenerator();
            StringGenerator stringGenerator = new StringGenerator();

            intGenerator.NextValue();
            stringGenerator.NextValue();

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

            //Scenario 3: Check the underlying reference. Change the SortedDictionary afterwards and examine ICollection keys and make sure that the
            //change is reflected
            int count = 100;

            SimpleRef <int>[]    simpleInts    = SortedDictionaryUtils.GetSimpleInts(count);
            SimpleRef <String>[] simpleStrings = SortedDictionaryUtils.GetSimpleStrings(count);
            int[] ints = new int[count];
            int   half = count / 2;

            SimpleRef <int>[]    simpleInts_1    = new SimpleRef <int> [half];
            SimpleRef <String>[] simpleStrings_1 = new SimpleRef <String> [half];
            SimpleRef <int>[]    simpleInts_2    = new SimpleRef <int> [half];
            SimpleRef <String>[] simpleStrings_2 = new SimpleRef <String> [half];

            for (int i = 0; i < count; i++)
            {
                ints[i] = i;
            }

            int[] ints_1 = new int[half];
            int[] ints_2 = 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.TestModify(ints_1, ints_1, ints_2);
            simpleRef.TestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2);
            simpleVal.TestModify(simpleInts_1, simpleInts_1, simpleInts_2);
            intDriver.NonGenericIDictionaryTestModify(ints_1, ints_1, ints_2);
            simpleRef.NonGenericIDictionaryTestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2);

            simpleVal.NonGenericIDictionaryTestModify(simpleInts_1, simpleInts_1, simpleInts_2);
        }
コード例 #2
0
        public static void IColImplMain()
        {
            Test test = new Test();

            IntGenerator    intGenerator    = new IntGenerator();
            StringGenerator stringGenerator = new StringGenerator();

            intGenerator.NextValue();
            stringGenerator.NextValue();

            Driver <int, string> intStringDriver = new Driver <int, string>(test);
            Driver <string, int> stringIntDriver = new Driver <string, int>(test);

            test.Eval(intStringDriver.Verify(new GenerateItem <int>(intGenerator.NextValue), new GenerateItem <string>(stringGenerator.NextValue)),
                      "Err_658865eido Test Int32, String FAILED\n");

            test.Eval(stringIntDriver.Verify(new GenerateItem <string>(stringGenerator.NextValue), new GenerateItem <int>(intGenerator.NextValue)),
                      "Err_40845ahekd Test String, Int32 FAILED\n");

            Assert.True(test.Pass);
        }
コード例 #3
0
        public static void SortedDictionary_ValueCollectionTest_Negative()
        {
            IntGenerator    intGenerator    = new IntGenerator();
            StringGenerator stringGenerator = new StringGenerator();

            intGenerator.NextValue();
            stringGenerator.NextValue();

            //Scenario 1: Vanilla - fill in SortedDictionary with 10 keys and check this property
            Driver <int, int> IntDriver = new Driver <int, int>();
            Driver <SimpleRef <String>, SimpleRef <String> > simpleRef = new Driver <SimpleRef <String>, SimpleRef <String> >();
            Driver <SimpleRef <int>, SimpleRef <int> >       simpleVal = new Driver <SimpleRef <int>, SimpleRef <int> >();

            int count = 100;

            SimpleRef <int>[]    simpleInts    = SortedDictionaryUtils.GetSimpleInts(count);
            SimpleRef <String>[] simpleStrings = SortedDictionaryUtils.GetSimpleStrings(count);
            int[] ints = new int[count];

            for (int i = 0; i < count; i++)
            {
                ints[i] = i;
            }

            IntDriver.TestVanilla_Negative(ints, ints);
            simpleRef.TestVanilla_Negative(simpleStrings, simpleStrings);
            simpleVal.TestVanilla_Negative(simpleInts, simpleInts);
            IntDriver.NonGenericIDictionaryTestVanilla_Negative(ints, ints);
            simpleRef.NonGenericIDictionaryTestVanilla_Negative(simpleStrings, simpleStrings);
            simpleVal.NonGenericIDictionaryTestVanilla_Negative(simpleInts, simpleInts);


            //Scenario 2: Check for an empty SortedDictionary
            IntDriver.TestVanilla_Negative(new int[0], new int[0]);
            simpleRef.TestVanilla_Negative(new SimpleRef <String> [0], new SimpleRef <String> [0]);
            simpleVal.TestVanilla_Negative(new SimpleRef <int> [0], new SimpleRef <int> [0]);
            IntDriver.NonGenericIDictionaryTestVanilla_Negative(new int[0], new int[0]);
            simpleRef.NonGenericIDictionaryTestVanilla_Negative(new SimpleRef <String> [0], new SimpleRef <String> [0]);
            simpleVal.NonGenericIDictionaryTestVanilla_Negative(new SimpleRef <int> [0], new SimpleRef <int> [0]);
        }
コード例 #4
0
ファイル: Values.cs プロジェクト: wuyou201400/corefx
        public static void RunTests()
        {
            Test test = new Test();

            IntGenerator    intGenerator    = new IntGenerator();
            StringGenerator stringGenerator = new StringGenerator();

            intGenerator.NextValue();
            stringGenerator.NextValue();

            //This mostly follows the format established by the original author of these tests

            //Scenario 1: Vanilla - fill in an SortedList with 10 keys and check this property

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

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

            count         = 100;
            simpleInts    = SL.SortedListUtils.GetSimpleInts(count);
            simpleStrings = SL.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);
            IntDriver.TestVanillaIListReturned(ints, ints, -1);
            simpleRef.TestVanillaIListReturned(simpleStrings, simpleStrings, new SL.SimpleRef <string>("bozo"));
            simpleVal.TestVanillaIListReturned(simpleInts, simpleInts, new SL.SimpleRef <int>(-1));
            IntDriver.TestVanillaICollectionReturned(ints, ints);
            simpleRef.TestVanillaICollectionReturned(simpleStrings, simpleStrings);
            simpleVal.TestVanillaICollectionReturned(simpleInts, simpleInts);

            //Scenario 2: Check for an empty SortedList
            IntDriver.TestVanilla(new int[0], new int[0]);
            simpleRef.TestVanilla(new SL.SimpleRef <String> [0], new SL.SimpleRef <String> [0]);
            simpleVal.TestVanilla(new SL.SimpleRef <int> [0], new SL.SimpleRef <int> [0]);
            IntDriver.NonGenericIDictionaryTestVanilla(new int[0], new int[0]);
            simpleRef.NonGenericIDictionaryTestVanilla(new SL.SimpleRef <String> [0], new SL.SimpleRef <String> [0]);
            simpleVal.NonGenericIDictionaryTestVanilla(new SL.SimpleRef <int> [0], new SL.SimpleRef <int> [0]);

            //Scenario 3: Check the underlying reference. Change the SortedList afterwards and examine ICollection keys and make sure that the
            //change is reflected
            SL.SimpleRef <int>[]    simpleInts_1;
            SL.SimpleRef <String>[] simpleStrings_1;
            int[] ints_1;
            SL.SimpleRef <int>[]    simpleInts_2;
            SL.SimpleRef <String>[] simpleStrings_2;
            int[] ints_2;

            int half = count / 2;

            simpleInts_1    = new SL.SimpleRef <int> [half];
            simpleStrings_1 = new SL.SimpleRef <String> [half];
            ints_2          = new int[half];
            simpleInts_2    = new SL.SimpleRef <int> [half];
            simpleStrings_2 = new SL.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.TestModify(ints_1, ints_1, ints_2);
            simpleRef.TestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2);
            simpleVal.TestModify(simpleInts_1, simpleInts_1, simpleInts_2);
            IntDriver.NonGenericIDictionaryTestModify(ints_1, ints_1, ints_2);
            simpleRef.NonGenericIDictionaryTestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2);
            simpleVal.NonGenericIDictionaryTestModify(simpleInts_1, simpleInts_1, simpleInts_2);

            //Scenario 4: Change keys via ICollection (how?) and examine SortedList
            //How indeed?

            //Verify ICollection<V> through ICollection testing suite
            Driver <int, string> intStringDriver = new Driver <int, string>(test);
            Driver <string, int> stringIntDriver = new Driver <string, int>(test);

            test.Eval(intStringDriver.VerifyICollection_T(new GenerateItem <int>(intGenerator.NextValue),
                                                          new GenerateItem <string>(stringGenerator.NextValue), 0),
                      "Err_085184aehdke Test Int32, String Empty Dictionary FAILED\n");

            test.Eval(intStringDriver.VerifyICollection_T(new GenerateItem <int>(intGenerator.NextValue),
                                                          new GenerateItem <string>(stringGenerator.NextValue), 1),
                      "Err_05164anhekjd Test Int32, String Dictionary with 1 item FAILED\n");

            test.Eval(intStringDriver.VerifyICollection_T(new GenerateItem <int>(intGenerator.NextValue),
                                                          new GenerateItem <string>(stringGenerator.NextValue), 16),
                      "Err_1088ajeid Test Int32, String Dictionary with 16 items FAILED\n");

            test.Eval(stringIntDriver.VerifyICollection_T(new GenerateItem <string>(stringGenerator.NextValue),
                                                          new GenerateItem <int>(intGenerator.NextValue), 0),
                      "Err_31288ajkekd Test String, Int32 Empty Dictionary FAILED\n");

            test.Eval(stringIntDriver.VerifyICollection_T(new GenerateItem <string>(stringGenerator.NextValue),
                                                          new GenerateItem <int>(intGenerator.NextValue), 1),
                      "Err_0215548aheuid Test String, Int32 Dictionary with 1 item FAILED\n");

            test.Eval(stringIntDriver.VerifyICollection_T(new GenerateItem <string>(stringGenerator.NextValue),
                                                          new GenerateItem <int>(intGenerator.NextValue), 16),
                      "Err_21057ajeipzd Test String, Int32 Dictionary with 16 items FAILED\n");

            Assert.True(test.Pass);
        }
コード例 #5
0
        public static void SortedDictionary_KeyCollectionTest1()
        {
            IntGenerator    intGenerator    = new IntGenerator();
            StringGenerator stringGenerator = new StringGenerator();

            intGenerator.NextValue();
            stringGenerator.NextValue();

            //Scenario 1: Vanilla - fill in an SortedDictionary with 10 keys and check this property
            Driver <int, int> IntDriver = new Driver <int, int>();
            Driver <SimpleRef <String>, SimpleRef <String> > simpleRef = new Driver <SimpleRef <String>, SimpleRef <String> >();
            Driver <SimpleRef <int>, SimpleRef <int> >       simpleVal = new Driver <SimpleRef <int>, SimpleRef <int> >();

            int count = 1000;

            SimpleRef <int>[]    simpleInts    = SortedDictionaryUtils.GetSimpleInts(count);
            SimpleRef <String>[] simpleStrings = SortedDictionaryUtils.GetSimpleStrings(count);
            int[] 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 for an empty SortedDictionary
            IntDriver.TestVanilla(new int[0], new int[0]);
            simpleRef.TestVanilla(new SimpleRef <String> [0], new SimpleRef <String> [0]);
            simpleVal.TestVanilla(new SimpleRef <int> [0], new SimpleRef <int> [0]);
            IntDriver.NonGenericIDictionaryTestVanilla(new int[0], new int[0]);
            simpleRef.NonGenericIDictionaryTestVanilla(new SimpleRef <String> [0], new SimpleRef <String> [0]);
            simpleVal.NonGenericIDictionaryTestVanilla(new SimpleRef <int> [0], new SimpleRef <int> [0]);

            //Scenario 3: Check the underlying reference. Change the SortedDictionary afterwards and examine ICollection keys and make sure that the
            //change is reflected
            int half = count / 2;

            SimpleRef <int>[]    simpleInts_1    = new SimpleRef <int> [half];
            SimpleRef <String>[] simpleStrings_1 = new SimpleRef <String> [half];
            SimpleRef <int>[]    simpleInts_2    = new SimpleRef <int> [half];
            SimpleRef <String>[] simpleStrings_2 = new SimpleRef <String> [half];

            int[] ints_1 = new int[half];
            int[] ints_2 = 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.TestModify(ints_1, ints_1, ints_2);
            simpleRef.TestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2);
            simpleVal.TestModify(simpleInts_1, simpleInts_1, simpleInts_2);
            IntDriver.NonGenericIDictionaryTestModify(ints_1, ints_1, ints_2);
            simpleRef.NonGenericIDictionaryTestModify(simpleStrings_1, simpleStrings_1, simpleStrings_2);
            simpleVal.NonGenericIDictionaryTestModify(simpleInts_1, simpleInts_1, simpleInts_2);
        }