예제 #1
0
        public void TestInterfaceHeaderNotConfigured()
        {
            IncludeChecker checker = new IncludeChecker(new TestOutput(), mConfig,
                                                        TestUtils.sGetFullPath(@"IncludeCheckerLib\test\InterfaceHeaders\includeinterfaceheader.cpp"), "",
                                                        0);

            checker.CheckIncludes();
            List <IncludeChecker.UnusedHeaderResult> results = checker.Results;

            Assert.AreEqual(1, results.Count);
        }
예제 #2
0
        public void TestUsedHeaders()
        {
            IncludeChecker checker = new IncludeChecker(new TestOutput(), mConfig,
                                                        TestUtils.sGetFullPath(@"IncludeCheckerLib\test\UsedHeaders\sourcefile.cpp"), "",
                                                        0);

            checker.CheckIncludes();
            Assert.AreEqual(0, checker.NrWarnings);
            List <IncludeChecker.UnusedHeaderResult> results = checker.Results;

            Assert.AreEqual(0, results.Count);
        }
예제 #3
0
        public void TestIgnorePathOnNonExistentHeaderAndSource()
        {
            mConfig.AddIgnoreHeaderInfo(new IncludeChecker.IgnoreHeaderInfo("sourcefile.cpp", "unknown.h"));
            IncludeChecker checker = new IncludeChecker(new TestOutput(), mConfig,
                                                        TestUtils.sGetFullPath(@"IncludeCheckerLib\test\IgnoreNonExistentHeader\sourcefile.cpp"), "",
                                                        0);

            checker.CheckIncludes();
            Assert.AreEqual(0, checker.NrWarnings);
            List <IncludeChecker.UnusedHeaderResult> results = checker.Results;

            Assert.AreEqual(0, results.Count);
        }
예제 #4
0
        public void TestTypeAliasSuffix()
        {
            mConfig.AddTypeAliasPrefix("a");
            mConfig.AddTypeAliasSuffix("Ref");
            IncludeChecker checker = new IncludeChecker(new TestOutput(), mConfig,
                                                        TestUtils.sGetFullPath(@"IncludeCheckerLib\test\TypeAliasSuffix\sourcefile.cpp"), "",
                                                        0);

            checker.CheckIncludes();
            Assert.AreEqual(0, checker.NrWarnings);
            List <IncludeChecker.UnusedHeaderResult> results = checker.Results;

            Assert.AreEqual(0, results.Count);
        }
예제 #5
0
        public void TestIgnorePathOnHeader()
        {
            mConfig.AddIgnorePath(TestUtils.sGetFullPath(@"IncludeCheckerLib\test\IgnoreUnusedHeaders\unused.h"));
            mConfig.AddIgnorePath(TestUtils.sGetFullPath(@"IncludeCheckerLib\test\IgnoreUnusedHeaders\unused2.h"));
            mConfig.AddIgnorePath(TestUtils.sGetFullPath(@"IncludeCheckerLib\test\IgnoreUnusedHeaders\unused3.h"));
            IncludeChecker checker = new IncludeChecker(new TestOutput(), mConfig,
                                                        TestUtils.sGetFullPath(@"IncludeCheckerLib\test\IgnoreUnusedHeaders\sourcefile.cpp"), "",
                                                        0);

            checker.CheckIncludes();
            Assert.AreEqual(0, checker.NrWarnings);
            List <IncludeChecker.UnusedHeaderResult> results = checker.Results;

            Assert.AreEqual(0, results.Count);
        }
예제 #6
0
        /// <summary>
        /// Run the check with all command line arguments.
        /// </summary>
        public bool Check(string[] inCommandLine)
        {
            ParseCommandLine(inCommandLine);

            IncludeChecker checker = new IncludeChecker(this, mConfig, mStartFiles, mStartDir, mNrWarnings);

            checker.CheckIncludes();

            if (!string.IsNullOrEmpty(mXmlOutputPath))
            {
                List <IncludeChecker.UnusedHeaderResult> results = checker.Results;
                WriteResultsToXml(results, mXmlOutputPath);
            }

            return(checker.Results.Count == 0);
        }
예제 #7
0
        public void TestUnusedHeaderAfterHeaderWithoutTags()
        {
            IncludeChecker checker = new IncludeChecker(new TestOutput(), mConfig,
                                                        TestUtils.sGetFullPath(@"IncludeCheckerLib\test\UnusedHeaders\sourcefile2.cpp"), "",
                                                        0);

            checker.CheckIncludes();
            Assert.AreEqual(0, checker.NrWarnings);
            List <IncludeChecker.UnusedHeaderResult> results = checker.Results;

            Assert.AreEqual(2, results.Count);
            Assert.AreEqual(TestUtils.sGetFullPath(@"IncludeCheckerLib\test\UnusedHeaders\sourcefile2.cpp"), results[0].SourceFile);
            Assert.AreEqual(TestUtils.sGetFullPath(@"IncludeCheckerLib\test\UnusedHeaders\onlyincludes.h"), results[0].HeaderFile);
            Assert.AreEqual(TestUtils.sGetFullPath(@"IncludeCheckerLib\test\UnusedHeaders\sourcefile2.cpp"), results[1].SourceFile);
            Assert.AreEqual(TestUtils.sGetFullPath(@"IncludeCheckerLib\test\UnusedHeaders\header.h"), results[1].HeaderFile);
        }