Esempio n. 1
0
        public void TestGenerateSrcMLFromFiles()
        {
            LibSrcMLRunner run      = new LibSrcMLRunner();
            List <string>  fileList = new List <string>()
            {
                Path.Combine(TestInputPath, "input.cpp"), Path.Combine(TestInputPath, "input2.cpp")
            };

            try {
                run.GenerateSrcMLFromFiles(fileList, "output", Language.CPlusPlus, new List <UInt32>()
                {
                    LibSrcMLRunner.SrcMLOptions.SRCML_OPTION_MODIFIER
                }, new Dictionary <string, Language>()
                {
                });

                Assert.True(File.Exists("output0.cpp.xml"));
                SrcMLFile srcFile = new SrcMLFile("output0.cpp.xml");
                Assert.IsNotNull(srcFile);

                var files = srcFile.FileUnits.ToList();
                Assert.AreEqual(2, files.Count());

                string file = Path.Combine(TestInputPath, "input.cpp");
                var    f1   = (from ele in files
                               where ele.Attribute("filename").Value == file
                               select ele);
                Assert.AreEqual(file, f1.FirstOrDefault().Attribute("filename").Value);

                string file2 = Path.Combine(TestInputPath, "input2.cpp");
                var    f2    = (from ele in files
                                where ele.Attribute("filename").Value == file2
                                select ele);
                Assert.AreEqual(file2, f2.FirstOrDefault().Attribute("filename").Value);
            }
            catch (SrcMLException e) {
                throw e;
            }
        }