- added ability to inject standard includes as <blah.h>

git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@205 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
mvandervoord
2011-01-28 01:46:51 +00:00
parent d7caef0569
commit 7b0e768415
3 changed files with 61 additions and 9 deletions
+8 -8
View File
@@ -19,10 +19,10 @@ class CMockGenerator
@ordered = @config.enforce_strict_ordering
@framework = @config.framework.to_s
@includes_h_pre_orig_header = @config.includes || @config.includes_h_pre_orig_header || []
@includes_h_post_orig_header = @config.includes_h_post_orig_header || []
@includes_c_pre_header = @config.includes_c_pre_header || []
@includes_c_post_header = @config.includes_c_post_header || []
@includes_h_pre_orig_header = (@config.includes || @config.includes_h_pre_orig_header || []).map{|h| h =~ /</ ? h : "\"#{h}\""}
@includes_h_post_orig_header = (@config.includes_h_post_orig_header || []).map{|h| h =~ /</ ? h : "\"#{h}\""}
@includes_c_pre_header = (@config.includes_c_pre_header || []).map{|h| h =~ /</ ? h : "\"#{h}\""}
@includes_c_post_header = (@config.includes_c_post_header || []).map{|h| h =~ /</ ? h : "\"#{h}\""}
end
def create_mock(module_name, parsed_stuff)
@@ -67,9 +67,9 @@ class CMockGenerator
file << "/* AUTOGENERATED FILE. DO NOT EDIT. */\n"
file << "#ifndef _#{define_name}\n"
file << "#define _#{define_name}\n\n"
@includes_h_pre_orig_header.each {|inc| file << "#include \"#{inc}\"\n"}
@includes_h_pre_orig_header.each {|inc| file << "#include #{inc}\n"}
file << "#include \"#{orig_filename}\"\n"
@includes_h_post_orig_header.each {|inc| file << "#include \"#{inc}\"\n"}
@includes_h_post_orig_header.each {|inc| file << "#include #{inc}\n"}
plugin_includes = @plugins.run(:include_files)
file << plugin_includes if (!plugin_includes.empty?)
file << "\n"
@@ -99,9 +99,9 @@ class CMockGenerator
file << "#include <setjmp.h>\n"
file << "#include \"#{@framework}.h\"\n"
file << "#include \"cmock.h\"\n"
@includes_c_pre_header.each {|inc| file << "#include \"#{inc}\"\n"}
@includes_c_pre_header.each {|inc| file << "#include #{inc}\n"}
file << "#include \"#{header_file}\"\n"
@includes_c_post_header.each {|inc| file << "#include \"#{inc}\"\n"}
@includes_c_post_header.each {|inc| file << "#include #{inc}\n"}
file << "\n"
end
+1 -1
View File
@@ -47,7 +47,7 @@ class SystemTestGenerator
cmock = cmock_yaml[:cmock]
cmock[:mock_path] = GENERATED_PATH
cmock[:includes] = [namix + TYPES_H]
cmock[:includes] = (cmock[:includes] || []) + [namix + TYPES_H]
cmock[:mock_prefix] = MOCK_PREFIX
if not yaml_hash[:systest][:unity_helper].nil?
cmock[:includes] << namix + UNITY_HELPER_H
@@ -0,0 +1,52 @@
---
#The purpose of this test is to pull in some standard library stuff from C99
:cmock:
:includes:
- "<stdint.h>"
- "<limits.h>"
:systest:
:types: |
#include <stdint.h>
#include <limits.h>
:mockable: |
int32_t foo(int32_t a);
:source:
:header: |
int8_t function_a(void);
:code: |
int8_t function_a(void) {
return (int8_t)(INT_MIN == foo(INT_MAX));
}
:tests:
:common: |
void setUp(void) {}
void tearDown(void) {}
:units:
- :pass: TRUE
:should: 'handle handle a simple comparison of C99 types which pass'
:code: |
test()
{
foo_ExpectAndReturn(INT_MAX, INT_MIN);
TEST_ASSERT_TRUE(function_a());
}
- :pass: FALSE
:should: 'handle handle a simple comparison of C99 types which fail'
:code: |
test()
{
foo_ExpectAndReturn(INT_MIN, INT_MIN);
TEST_ASSERT_TRUE(function_a());
}
...