added couple function parsing test cases; inserted comments

git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@88 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
mkarlesky
2009-04-22 12:57:06 +00:00
parent 733d463d4f
commit 14ce655a91
2 changed files with 7 additions and 8 deletions
+2 -2
View File
@@ -25,12 +25,12 @@ class CMockHeaderParser
def import_source(source)
source.gsub!(/\s*\\\s*/m, ' ') # smush multiline into single line
source.gsub!(/\/\*.*?\*\//m, '') # remove block comments
source.gsub!(/\/\*.*?\*\//m, '') # remove block comments (do it first to avoid trouble with embedded line comments)
source.gsub!(/\/\/.*$/, '') # remove line comments
source.gsub!(/#.*/, '') # remove preprocessor statements
source.gsub!(/typedef.*/, '') # remove typedef statements
@src_lines = source.split(/\s*;\s*/)
@src_lines = source.split(/\s*;\s*/) # split source at end of statements (removing extra white space)
@src_lines.delete_if {|line| line.strip.length == 0} # remove blank lines
end
+5 -6
View File
@@ -38,8 +38,7 @@ class CMockHeaderParserTest < Test::Unit::TestCase
" abcd;\n" +
"/* hello;*/\n" +
"who /* is you\n" +
"// embedded line comment */\n" +
"/* shizzzle*/"
"// embedded line comment */\n"
@parser = CMockHeaderParser.new(source, @config)
expected =
@@ -52,7 +51,6 @@ class CMockHeaderParserTest < Test::Unit::TestCase
end
should "treat preprocessor directives as single line" do
#flunk "this substitution generates an empty first line element?"
source =
"#when stuff_happens\n" +
"#ifdef _TEST\n" +
@@ -117,13 +115,14 @@ class CMockHeaderParserTest < Test::Unit::TestCase
source =
"int Foo(int a, unsigned int b);\n" +
"void bar \n(uint la, int de, bool da);\n" +
"void bar \n(uint la, int de, bool da) ; \n" +
"void FunkyChicken (\n uint la,\n int de,\n bool da);\n" +
"void\n shiz(void);\n" +
"void tat();\n" +
# following lines should yield no function declarations
# following lines should yield no function declarations:
"#define get_foo() \\\n (Thing)foo())\n" +
"array_type[((U8)10)];\n"
"ARRAY_TYPE array[((U8)10)];\n" +
"THINGER_MASK = (0x0001 << 5),\n"
@parser = CMockHeaderParser.new(source, @config)
parsed_stuff = @parser.parse