Ejemplo n.º 1
0
        public void testLoadFile()
        {
            ClangWrapper wrapper = new ClangWrapper();

            // Create temporary test file
            string fileName = "func.c";

            using (StreamWriter sw = System.IO.File.CreateText(fileName))
            {
                sw.Write("Hello");
            }

            // Load file
            wrapper.loadFile("func.c");
            // No exception, load success

            wrapper.dispose();
            System.IO.File.Delete(fileName);
        }
Ejemplo n.º 2
0
        private ClangWrapper getWrapper(string code)
        {
            ClangWrapper wrapper = new ClangWrapper();

            // Create temporary test file
            string fileName = "func.c";

            using (StreamWriter sw = System.IO.File.CreateText(fileName))
            {
                sw.Write(code);
            }

            // Load file
            wrapper.loadFile("func.c");

            System.IO.File.Delete(fileName);

            return(wrapper);
        }
Ejemplo n.º 3
0
        public void testGetAstRoot()
        {
            ClangWrapper wrapper = new ClangWrapper();

            // Create temporary test file
            string fileName = "func.c";

            using (StreamWriter sw = System.IO.File.CreateText(fileName))
            {
                sw.Write("int main() { return 0; }");
            }

            // Load file
            wrapper.loadFile("func.c");

            // Assert root kind and first child kind
            Assert.AreEqual(CursorKind.TranslationUnit, wrapper.getRoot().Kind);
            Assert.AreEqual(CursorKind.FunctionDecl, wrapper.getRoot().Children[0].Kind);
            Assert.AreEqual("main", wrapper.getRoot().Children[0].Spelling);

            wrapper.dispose();
            System.IO.File.Delete(fileName);
        }
Ejemplo n.º 4
0
        public void testLoadFileFail()
        {
            ClangWrapper wrapper = new ClangWrapper();

            Assert.Throws <FileNotFoundException>(delegate { wrapper.loadFile("nonExistingFile.c"); });
        }