public void TestIsInclude()
 {
     Assert.IsTrue(IncludeFinder.IsInclude("#include <header.h>"));
     Assert.IsTrue(IncludeFinder.IsInclude(" #include \"header.h\""));
     Assert.IsTrue(IncludeFinder.IsInclude("\t#include \"header.h\""));
     Assert.IsFalse(IncludeFinder.IsInclude(""));
     Assert.IsFalse(IncludeFinder.IsInclude("include <header.h>"));
 }
        public void TestGetPossibleHeaderFilesSystemHeader()
        {
            List <string> include_paths = new List <string>();

            include_paths.Add(@"d:\dev\main\Code\Core");
            include_paths.Add(@"d:\dev\main\Code\Pigs");
            List <string> possible_headers = IncludeFinder.GetPossibleHeaderFiles(include_paths,
                                                                                  @"d:\dev\main\Code\Pigs\Test\header.h", new Include("somedir/otherheader.h", 1, true));

            Assert.AreEqual(2, possible_headers.Count);
            Assert.AreEqual(@"d:\dev\main\Code\Core\somedir\otherheader.h", possible_headers[0]);
            Assert.AreEqual(@"d:\dev\main\Code\Pigs\somedir\otherheader.h", possible_headers[1]);
        }
        public void TestGetRawIncludes()
        {
            IncludeFinder  finder   = new IncludeFinder(null);
            string         source   = @"// #include <blah/blah.h>

#include <lib/include.h>

#include ""syslib/sysinclude.h""

";
            List <Include> includes = finder.GetRawIncludes(source);

            Assert.AreEqual("lib/include.h", includes[0].Path);
            Assert.AreEqual(3, includes[0].Line);
            Assert.AreEqual("syslib/sysinclude.h", includes[1].Path);
            Assert.AreEqual(5, includes[1].Line);
        }
Example #4
0
        /// <summary>
        /// Remove #include statements from C++ source.
        /// </summary>
        /// <param name="ioContents"></param>
        public void RemoveIncludes(ref string ioContents)
        {
            List <string> lines       = LineUtil.GetLineList(ioContents);
            StringBuilder output      = new StringBuilder();
            bool          add_newline = false;

            foreach (string line in lines)
            {
                if (add_newline)
                {
                    output.Append("\r\n");
                }
                add_newline = true;

                string trimmed_line = line.Trim();
                if (!IncludeFinder.IsInclude(line))
                {
                    output.Append(line);
                }
            }
            ioContents = output.ToString();
        }
 public void TestGetNativePath()
 {
     Assert.AreEqual(@"Core\CCore", IncludeFinder.GetNativePath(@"Core\CCore"));
 }
 public void TestGetIncludePath()
 {
     Assert.AreEqual("header.h", IncludeFinder.GetIncludePath("#include <header.h>"));
     Assert.AreEqual("header.h", IncludeFinder.GetIncludePath("#include \"header.h\""));
 }