コード例 #1
0
ファイル: testcaseutils.cs プロジェクト: somelou/Randoop.NET
        public static Collection <FileInfo> Reduce2(Collection <FileInfo> tests)
        {
            Dictionary <EquivClass2, TestCase> representatives          = new Dictionary <EquivClass2, TestCase>();
            Dictionary <EquivClass2, FileInfo> representativesFileInfos = new Dictionary <EquivClass2, FileInfo>();


            foreach (FileInfo file in tests)
            {
                TestCase testCase;
                try
                {
                    testCase = new TestCase(file);
                }
                catch (Exception)
                {
                    // File does not contain a valid test case, or
                    // test case is malformed.
                    continue;
                }


                EquivClass2 partition = new EquivClass2(testCase);
                // If there are no representatives for this partition,
                // use testCase as the representative.
                if (!representatives.ContainsKey(partition))
                {
                    representatives[partition]          = testCase;
                    representativesFileInfos[partition] = file;
                }
                // if testCase is larger than the current representative (the current test sequence is a subset),
                // use testCase as the representative.
                // Delete the old representative.
                else if (testCase.NumTestLines > representatives[partition].NumTestLines)
                {
                    //representativesFileInfos[partition].Delete();
                    representativesFileInfos[partition].MoveTo(representativesFileInfos[partition].FullName + ".reduced");
                    representatives[partition]          = testCase;
                    representativesFileInfos[partition] = file;
                }
                // sequence of testCase is a subset of the sequence of current representative.
                // Delete testCase.
                else
                {
                    //file.Delete();
                    file.MoveTo(file.FullName + ".reduced");
                }
            }

            List <FileInfo> retval = new List <FileInfo>();

            retval.AddRange(representativesFileInfos.Values);
            return(new Collection <FileInfo>(retval));
        }
コード例 #2
0
ファイル: testcaseutils.cs プロジェクト: somelou/Randoop.NET
            public override bool Equals(object obj)
            {
                EquivClass2 other = obj as EquivClass2;

                if (other == null)
                {
                    return(false);
                }

                string testPlans  = getSequence(this.representative.testPlanCollection);
                string testPlans2 = getSequence(other.representative.testPlanCollection);

                if (testPlans.Contains(testPlans2))
                {
                    return(true);
                }
                if (testPlans2.Contains(testPlans))
                {
                    return(true);
                }
                return(false);
            }
コード例 #3
0
ファイル: testcaseutils.cs プロジェクト: SJMakin/Randoop.NET
        public static Collection<FileInfo> Reduce2(Collection<FileInfo> tests) 
        {
            Dictionary<EquivClass2, TestCase> representatives = new Dictionary<EquivClass2, TestCase>();
            Dictionary<EquivClass2, FileInfo> representativesFileInfos = new Dictionary<EquivClass2, FileInfo>();


            foreach (FileInfo file in tests)
            {
                TestCase testCase;
                try
                {
                    testCase = new TestCase(file);
                }
                catch (Exception)
                {
                    // File does not contain a valid test case, or
                    // test case is malformed.
                    continue;
                }


                EquivClass2 partition = new EquivClass2(testCase);
                // If there are no representatives for this partition,
                // use testCase as the representative.
                if (!representatives.ContainsKey(partition))
                {
                    representatives[partition] = testCase;
                    representativesFileInfos[partition] = file;
                }
                // if testCase is larger than the current representative (the current test sequence is a subset),
                // use testCase as the representative.
                // Delete the old representative.
                else if (testCase.NumTestLines > representatives[partition].NumTestLines)
                {
                    //representativesFileInfos[partition].Delete();
                    representativesFileInfos[partition].MoveTo(representativesFileInfos[partition].FullName + ".reduced");
                    representatives[partition] = testCase;
                    representativesFileInfos[partition] = file;
                }
                // sequence of testCase is a subset of the sequence of current representative.
                // Delete testCase.
                else
                {
                    //file.Delete();
                    file.MoveTo(file.FullName+".reduced");
                }
            }

            List<FileInfo> retval = new List<FileInfo>();
            retval.AddRange(representativesFileInfos.Values);
            return new Collection<FileInfo>(retval);
        }