From 7b0e7684153d10d5c77428acea83d0cb2a0e0d84 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Fri, 28 Jan 2011 01:46:51 +0000 Subject: [PATCH] - added ability to inject standard includes as git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@205 bf332499-1b4d-0410-844d-d2d48d5cc64c --- lib/cmock_generator.rb | 16 +++--- test/system/systest_generator.rb | 2 +- .../newer_standards_stuff1.yml | 52 +++++++++++++++++++ 3 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 test/system/test_interactions/newer_standards_stuff1.yml diff --git a/lib/cmock_generator.rb b/lib/cmock_generator.rb index 86ee977..0dcec53 100644 --- a/lib/cmock_generator.rb +++ b/lib/cmock_generator.rb @@ -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 =~ /\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 diff --git a/test/system/systest_generator.rb b/test/system/systest_generator.rb index 6b81218..bbc8320 100644 --- a/test/system/systest_generator.rb +++ b/test/system/systest_generator.rb @@ -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 diff --git a/test/system/test_interactions/newer_standards_stuff1.yml b/test/system/test_interactions/newer_standards_stuff1.yml new file mode 100644 index 0000000..6843eae --- /dev/null +++ b/test/system/test_interactions/newer_standards_stuff1.yml @@ -0,0 +1,52 @@ +--- +#The purpose of this test is to pull in some standard library stuff from C99 +:cmock: + :includes: + - "" + - "" + +:systest: + :types: | + #include + #include + + + :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()); + } + +...