ceedling 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ceedling.gemspec +1 -1
- data/lib/ceedling/version.rb +2 -2
- data/lib/ceedling/version.rb.erb +1 -2
- data/test_graveyard/unit/busted/generator_test_runner_test.rb +2 -5
- data/vendor/cmock/Gemfile +1 -3
- data/vendor/cmock/Rakefile +10 -17
- data/vendor/cmock/docs/license.txt +18 -30
- data/vendor/cmock/examples/gcc.yml +2 -2
- data/vendor/cmock/examples/iar_v4.yml +3 -3
- data/vendor/cmock/examples/iar_v5.yml +3 -3
- data/vendor/cmock/examples/rakefile_helper.rb +35 -35
- data/vendor/cmock/lib/cmock_generator.rb +17 -5
- data/vendor/cmock/lib/cmock_generator_plugin_array.rb +9 -3
- data/vendor/cmock/lib/cmock_generator_plugin_ignore_arg.rb +1 -1
- data/vendor/cmock/lib/cmock_generator_plugin_return_thru_ptr.rb +1 -1
- data/vendor/cmock/lib/cmock_header_parser.rb +7 -3
- data/vendor/cmock/release/version.info +1 -1
- data/vendor/cmock/test/c/TestCMockCDynamic_Runner.c +1 -2
- data/vendor/cmock/test/c/TestCMockC_Runner.c +1 -1
- data/vendor/cmock/test/system/systest_generator.rb +6 -2
- data/vendor/cmock/test/system/test_compilation/const.h +3 -1
- data/vendor/cmock/test/test_helper.rb +38 -40
- data/vendor/cmock/test/unit/cmock_config_test.rb +26 -29
- data/vendor/cmock/test/unit/cmock_file_writer_test.rb +8 -11
- data/vendor/cmock/test/unit/cmock_generator_main_test.rb +82 -80
- data/vendor/cmock/test/unit/cmock_generator_plugin_array_test.rb +62 -43
- data/vendor/cmock/test/unit/cmock_generator_plugin_callback_test.rb +44 -45
- data/vendor/cmock/test/unit/cmock_generator_plugin_cexception_test.rb +30 -31
- data/vendor/cmock/test/unit/cmock_generator_plugin_expect_any_args_test.rb +15 -16
- data/vendor/cmock/test/unit/cmock_generator_plugin_expect_test.rb +76 -77
- data/vendor/cmock/test/unit/cmock_generator_plugin_ignore_arg_test.rb +19 -19
- data/vendor/cmock/test/unit/cmock_generator_plugin_ignore_test.rb +17 -18
- data/vendor/cmock/test/unit/cmock_generator_plugin_return_thru_ptr_test.rb +17 -17
- data/vendor/cmock/test/unit/cmock_generator_utils_test.rb +74 -65
- data/vendor/cmock/test/unit/cmock_header_parser_test.rb +103 -76
- data/vendor/cmock/test/unit/cmock_plugin_manager_test.rb +46 -36
- data/vendor/cmock/test/unit/cmock_unityhelper_parser_test.rb +85 -85
- data/vendor/unity/auto/generate_test_runner.rb +4 -3
- data/vendor/unity/auto/type_sanitizer.rb +8 -0
- data/vendor/unity/auto/unity_test_summary.py +135 -0
- data/vendor/unity/examples/example_1/makefile +16 -0
- data/vendor/unity/examples/example_1/src/ProductionCode2.c +2 -0
- data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +0 -13
- data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +0 -13
- data/vendor/unity/examples/example_2/makefile +20 -1
- data/vendor/unity/examples/example_2/src/ProductionCode2.c +2 -0
- data/vendor/unity/examples/example_2/test/test_runners/all_tests.c +2 -2
- data/vendor/unity/examples/example_3/makefile +16 -0
- data/vendor/unity/examples/example_3/src/ProductionCode2.c +2 -0
- data/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c +0 -13
- data/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode_Runner.c +0 -13
- data/vendor/unity/extras/fixture/rakefile.rb +14 -3
- data/vendor/unity/extras/fixture/src/unity_fixture.c +21 -11
- data/vendor/unity/extras/fixture/src/unity_fixture.h +8 -4
- data/vendor/unity/extras/fixture/src/unity_fixture_internals.h +1 -1
- data/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +5 -0
- data/vendor/unity/extras/fixture/test/main/AllTests.c +2 -2
- data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +8 -8
- data/vendor/unity/extras/fixture/test/unity_output_Spy.c +2 -2
- data/vendor/unity/extras/fixture/test/unity_output_Spy.h +2 -2
- data/vendor/unity/release/version.info +1 -1
- data/vendor/unity/src/unity.c +26 -19
- data/vendor/unity/src/unity_internals.h +9 -12
- data/vendor/unity/test/targets/gcc_auto_stdint.yml +13 -0
- metadata +4 -5
- data/vendor/cmock/test/spec/cmock_file_writer_spec.rb +0 -45
- data/vendor/cmock/test/spec/cmock_generator_plugin_array_spec.rb +0 -52
- data/vendor/cmock/test/spec/spec_helper.rb +0 -12
@@ -4,8 +4,6 @@
|
|
4
4
|
# [Released under MIT License. Please refer to license.txt for details]
|
5
5
|
# ==========================================
|
6
6
|
|
7
|
-
$here = File.dirname __FILE__
|
8
|
-
|
9
7
|
class CMockGenerator
|
10
8
|
|
11
9
|
attr_accessor :config, :file_writer, :module_name, :clean_mock_name, :mock_name, :utils, :plugins, :ordered
|
@@ -23,12 +21,24 @@ class CMockGenerator
|
|
23
21
|
@includes_h_post_orig_header = (@config.includes_h_post_orig_header || []).map{|h| h =~ /</ ? h : "\"#{h}\""}
|
24
22
|
@includes_c_pre_header = (@config.includes_c_pre_header || []).map{|h| h =~ /</ ? h : "\"#{h}\""}
|
25
23
|
@includes_c_post_header = (@config.includes_c_post_header || []).map{|h| h =~ /</ ? h : "\"#{h}\""}
|
24
|
+
|
25
|
+
here = File.dirname __FILE__
|
26
|
+
unity_path_in_ceedling = "#{here}/../../unity" # path to Unity from within Ceedling
|
27
|
+
unity_path_in_cmock = "#{here}/../vendor/unity" # path to Unity from within CMock
|
28
|
+
if File.exist? unity_path_in_ceedling
|
29
|
+
require "#{unity_path_in_ceedling}/auto/type_sanitizer"
|
30
|
+
elsif File.exist? unity_path_in_cmock
|
31
|
+
require "#{unity_path_in_cmock}/auto/type_sanitizer"
|
32
|
+
else
|
33
|
+
raise "Failed to find an instance of Unity to pull in type_sanitizer module!"
|
34
|
+
end
|
35
|
+
|
26
36
|
end
|
27
37
|
|
28
38
|
def create_mock(module_name, parsed_stuff)
|
29
39
|
@module_name = module_name
|
30
40
|
@mock_name = @prefix + @module_name
|
31
|
-
@clean_mock_name = @mock_name
|
41
|
+
@clean_mock_name = TypeSanitizer.sanitize_c_identifier(@mock_name)
|
32
42
|
create_mock_header_file(parsed_stuff)
|
33
43
|
create_mock_source_file(parsed_stuff)
|
34
44
|
end
|
@@ -63,7 +73,7 @@ class CMockGenerator
|
|
63
73
|
end
|
64
74
|
|
65
75
|
def create_mock_header_header(file, filename)
|
66
|
-
define_name = @clean_mock_name.
|
76
|
+
define_name = @clean_mock_name.upcase
|
67
77
|
orig_filename = filename[@config.mock_prefix.size..-1]
|
68
78
|
file << "/* AUTOGENERATED FILE. DO NOT EDIT. */\n"
|
69
79
|
file << "#ifndef _#{define_name}_H\n"
|
@@ -75,11 +85,13 @@ class CMockGenerator
|
|
75
85
|
file << plugin_includes if (!plugin_includes.empty?)
|
76
86
|
file << "\n"
|
77
87
|
file << "/* Ignore the following warnings, since we are copying code */\n"
|
78
|
-
file << "#if
|
88
|
+
file << "#if defined(__GNUC__) && !defined(__ICC)\n"
|
89
|
+
file << "#if !defined(__clang__)\n"
|
79
90
|
file << "#pragma GCC diagnostic ignored \"-Wpragmas\"\n"
|
80
91
|
file << "#endif\n"
|
81
92
|
file << "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n"
|
82
93
|
file << "#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n"
|
94
|
+
file << "#endif\n"
|
83
95
|
file << "\n"
|
84
96
|
end
|
85
97
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# CMock Project - Automatic Mock Generation for C
|
3
3
|
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
4
4
|
# [Released under MIT License. Please refer to license.txt for details]
|
5
|
-
# ==========================================
|
5
|
+
# ==========================================
|
6
6
|
|
7
7
|
class CMockGeneratorPluginArray
|
8
8
|
|
@@ -26,7 +26,10 @@ class CMockGeneratorPluginArray
|
|
26
26
|
def mock_function_declarations(function)
|
27
27
|
return nil unless function[:contains_ptr?]
|
28
28
|
args_call = function[:args].map{|m| m[:ptr?] ? "#{m[:name]}, #{m[:name]}_Depth" : "#{m[:name]}"}.join(', ')
|
29
|
-
args_string = function[:args].map
|
29
|
+
args_string = function[:args].map do |m|
|
30
|
+
const_str = m[:const?] ? 'const ' : ''
|
31
|
+
m[:ptr?] ? "#{const_str}#{m[:type]} #{m[:name]}, int #{m[:name]}_Depth" : "#{const_str}#{m[:type]} #{m[:name]}"
|
32
|
+
end.join(', ')
|
30
33
|
if (function[:return][:void?])
|
31
34
|
return "#define #{function[:name]}_ExpectWithArray(#{args_call}) #{function[:name]}_CMockExpectWithArray(__LINE__, #{args_call})\n" +
|
32
35
|
"void #{function[:name]}_CMockExpectWithArray(UNITY_LINE_TYPE cmock_line, #{args_string});\n"
|
@@ -40,7 +43,10 @@ class CMockGeneratorPluginArray
|
|
40
43
|
return nil unless function[:contains_ptr?]
|
41
44
|
lines = []
|
42
45
|
func_name = function[:name]
|
43
|
-
args_string = function[:args].map
|
46
|
+
args_string = function[:args].map do |m|
|
47
|
+
const_str = m[:const?] ? 'const ' : ''
|
48
|
+
m[:ptr?] ? "#{const_str}#{m[:type]} #{m[:name]}, int #{m[:name]}_Depth" : "#{const_str}#{m[:type]} #{m[:name]}"
|
49
|
+
end.join(', ')
|
44
50
|
call_string = function[:args].map{|m| m[:ptr?] ? "#{m[:name]}, #{m[:name]}_Depth" : m[:name]}.join(', ')
|
45
51
|
if (function[:return][:void?])
|
46
52
|
lines << "void #{func_name}_CMockExpectWithArray(UNITY_LINE_TYPE cmock_line, #{args_string})\n"
|
@@ -34,7 +34,7 @@ class CMockGeneratorPluginIgnoreArg
|
|
34
34
|
lines << "void #{function[:name]}_CMockIgnoreArg_#{arg[:name]}(UNITY_LINE_TYPE cmock_line)\n"
|
35
35
|
lines << "{\n"
|
36
36
|
lines << " CMOCK_#{func_name}_CALL_INSTANCE* cmock_call_instance = " +
|
37
|
-
"
|
37
|
+
"(CMOCK_#{func_name}_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.#{func_name}_CallInstance));\n"
|
38
38
|
lines << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"#{arg_name} IgnoreArg called before Expect on '#{func_name}'.\");\n"
|
39
39
|
lines << " cmock_call_instance->IgnoreArg_#{arg_name} = 1;\n"
|
40
40
|
lines << "}\n\n"
|
@@ -45,7 +45,7 @@ class CMockGeneratorPluginReturnThruPtr
|
|
45
45
|
lines << "void #{func_name}_CMockReturnMemThruPtr_#{arg_name}(UNITY_LINE_TYPE cmock_line, #{arg[:type]} #{arg_name}, int cmock_size)\n"
|
46
46
|
lines << "{\n"
|
47
47
|
lines << " CMOCK_#{func_name}_CALL_INSTANCE* cmock_call_instance = " +
|
48
|
-
"
|
48
|
+
"(CMOCK_#{func_name}_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.#{func_name}_CallInstance));\n"
|
49
49
|
lines << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"#{arg_name} ReturnThruPtr called before Expect on '#{func_name}'.\");\n"
|
50
50
|
lines << " cmock_call_instance->ReturnThruPtr_#{arg_name}_Used = 1;\n"
|
51
51
|
lines << " cmock_call_instance->ReturnThruPtr_#{arg_name}_Val = #{arg_name};\n"
|
@@ -93,6 +93,12 @@ class CMockHeaderParser
|
|
93
93
|
"#{functype} #{$2.strip}(#{$3});"
|
94
94
|
end
|
95
95
|
|
96
|
+
# remove function definitions by stripping off the arguments right now
|
97
|
+
source.gsub!(/\([^\)]*\)\s*\{[^\}]*\}/m, ";")
|
98
|
+
|
99
|
+
# remove pairs of braces because no function declarations will be inside of them
|
100
|
+
#source.gsub!(/\{[^\}]*\}/m, '')
|
101
|
+
|
96
102
|
#drop extra white space to make the rest go faster
|
97
103
|
source.gsub!(/^\s+/, '') # remove extra white space from beginning of line
|
98
104
|
source.gsub!(/\s+$/, '') # remove extra white space from end of line
|
@@ -101,7 +107,7 @@ class CMockHeaderParser
|
|
101
107
|
source.gsub!(/\s+/, ' ') # remove remaining extra white space
|
102
108
|
|
103
109
|
#split lines on semicolons and remove things that are obviously not what we are looking for
|
104
|
-
src_lines = source.split(/\s*;\s*/)
|
110
|
+
src_lines = source.split(/\s*;\s*/).uniq
|
105
111
|
src_lines.delete_if {|line| line.strip.length == 0} # remove blank lines
|
106
112
|
src_lines.delete_if {|line| !(line =~ /[\w\s\*]+\(+\s*\*[\*\s]*[\w\s]+(?:\[[\w\s]*\]\s*)+\)+\s*\((?:[\w\s\*]*,?)*\s*\)/).nil?} #remove function pointer arrays
|
107
113
|
if (@treat_externs == :include)
|
@@ -109,8 +115,6 @@ class CMockHeaderParser
|
|
109
115
|
else
|
110
116
|
src_lines.delete_if {|line| !(line =~ /(?:^|\s+)(?:extern|inline)\s+/).nil?} # remove inline and extern functions
|
111
117
|
end
|
112
|
-
src_lines.delete_if {|line| !(line =~ /\{/).nil? } # remove lines with opening braces { because this isn't a declaration, it's a definition!
|
113
|
-
src_lines.map!{|line| line.gsub(/.*\}/,'')} #remove braces left at the beginning of lines
|
114
118
|
src_lines.delete_if {|line| line.empty? } #drop empty lines
|
115
119
|
end
|
116
120
|
|
@@ -1,2 +1,2 @@
|
|
1
|
-
2.
|
1
|
+
2.3
|
2
2
|
|
@@ -21,8 +21,7 @@ extern void test_ThatWeCanAskForAllSortsOfSizes(void);
|
|
21
21
|
|
22
22
|
int main(void)
|
23
23
|
{
|
24
|
-
UnityBegin();
|
25
|
-
Unity.TestFile = "TestCMockDynamic.c";
|
24
|
+
UnityBegin("TestCMockDynamic.c");
|
26
25
|
|
27
26
|
RUN_TEST(test_MemNewWillReturnNullIfGivenIllegalSizes, 26);
|
28
27
|
RUN_TEST(test_MemNewWillNowSupportSizesGreaterThanTheDefinesCMockSize, 35);
|
@@ -22,8 +22,8 @@ extern void test_ThatWeCanAskForAllSortsOfSizes(void);
|
|
22
22
|
|
23
23
|
int main(void)
|
24
24
|
{
|
25
|
-
UnityBegin();
|
26
25
|
Unity.TestFile = "TestCMock.c";
|
26
|
+
UnityBegin(Unity.TestFile);
|
27
27
|
|
28
28
|
RUN_TEST(test_MemNewWillReturnNullIfGivenIllegalSizes, 21);
|
29
29
|
RUN_TEST(test_MemChainWillReturnNullAndDoNothingIfGivenIllegalInformation, 32);
|
@@ -151,11 +151,13 @@ class SystemTestGenerator
|
|
151
151
|
out.puts("#include \"#{include}\"")
|
152
152
|
end
|
153
153
|
out.puts('')
|
154
|
-
out.puts("#if
|
154
|
+
out.puts("#if defined(__GNUC__) && !defined(__ICC)")
|
155
|
+
out.puts("#if !defined(__clang__)")
|
155
156
|
out.puts("#pragma GCC diagnostic ignored \"-Wpragmas\"")
|
156
157
|
out.puts("#endif")
|
157
158
|
out.puts('#pragma GCC diagnostic ignored "-Wunknown-pragmas"')
|
158
159
|
out.puts('#pragma GCC diagnostic ignored "-Wduplicate-decl-specifier"')
|
160
|
+
out.puts("#endif")
|
159
161
|
out.puts('')
|
160
162
|
yield(out)
|
161
163
|
out.puts('')
|
@@ -170,11 +172,13 @@ class SystemTestGenerator
|
|
170
172
|
out.puts("#include \"#{include}\"")
|
171
173
|
end
|
172
174
|
out.puts('')
|
173
|
-
out.puts("#if
|
175
|
+
out.puts("#if defined(__GNUC__) && !defined(__ICC)")
|
176
|
+
out.puts("#if !defined(__clang__)")
|
174
177
|
out.puts("#pragma GCC diagnostic ignored \"-Wpragmas\"")
|
175
178
|
out.puts("#endif")
|
176
179
|
out.puts('#pragma GCC diagnostic ignored "-Wunknown-pragmas"')
|
177
180
|
out.puts('#pragma GCC diagnostic ignored "-Wduplicate-decl-specifier"')
|
181
|
+
out.puts("#endif")
|
178
182
|
out.puts('')
|
179
183
|
yield(out)
|
180
184
|
out.puts('')
|
@@ -4,11 +4,13 @@
|
|
4
4
|
[Released under MIT License. Please refer to license.txt for details]
|
5
5
|
========================================== */
|
6
6
|
|
7
|
-
#if
|
7
|
+
#if defined(__GNUC__) && !defined(__ICC)
|
8
|
+
#if !defined(__clang__)
|
8
9
|
#pragma GCC diagnostic ignored "-Wpragmas"
|
9
10
|
#endif
|
10
11
|
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
11
12
|
#pragma GCC diagnostic ignored "-Wduplicate-decl-specifier"
|
13
|
+
#endif
|
12
14
|
|
13
15
|
struct _DUMMY_T { unsigned int a; float b; };
|
14
16
|
|
@@ -2,48 +2,46 @@
|
|
2
2
|
# CMock Project - Automatic Mock Generation for C
|
3
3
|
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
4
4
|
# [Released under MIT License. Please refer to license.txt for details]
|
5
|
-
# ==========================================
|
6
|
-
[ "/../config/test_environment",
|
7
|
-
"/../vendor/behaviors/lib/behaviors"
|
8
|
-
].each do |req|
|
9
|
-
require File.expand_path(File.dirname(__FILE__)) + req
|
10
|
-
end
|
5
|
+
# ==========================================
|
11
6
|
|
12
|
-
# Note from Matt July 16 2012: not sure why this is here, as 1.9 comes with
|
13
|
-
# minitest, an implementation for Test::Unit in 1.9.
|
14
|
-
# Using test-unit makes hardmock quite unhappy.
|
15
|
-
# Long-term solution: replace hardmock with a mocking library like rr or rspec
|
16
|
-
# that is well maintained into the future. hardmock is off of life support.
|
17
|
-
#gem install test-unit -v 1.2.3
|
18
|
-
# ruby_version = RUBY_VERSION.split('.')
|
19
|
-
# if (ruby_version[1].to_i == 9) and (ruby_version[2].to_i > 1)
|
20
|
-
# require 'rubygems'
|
21
|
-
# gem 'test-unit'
|
22
|
-
# end
|
23
|
-
require 'test/unit'
|
24
|
-
require 'hardmock'
|
25
7
|
|
26
|
-
|
27
|
-
extend Behaviors
|
28
|
-
|
29
|
-
#these are helpful test structures which can be used during tests
|
30
|
-
|
31
|
-
def test_return
|
32
|
-
{
|
33
|
-
:int => {:type => "int", :name => 'cmock_to_return', :ptr? => false, :const? => false, :void? => false, :str => 'int cmock_to_return'},
|
34
|
-
:int_ptr => {:type => "int*", :name => 'cmock_to_return', :ptr? => true, :const? => false, :void? => false, :str => 'int* cmock_to_return'},
|
35
|
-
:void => {:type => "void", :name => 'cmock_to_return', :ptr? => false, :const? => false, :void? => true, :str => 'void cmock_to_return'},
|
36
|
-
:string => {:type => "char*", :name => 'cmock_to_return', :ptr? => false, :const? => true, :void? => false, :str => 'const char* cmock_to_return'},
|
37
|
-
}
|
38
|
-
end
|
8
|
+
require 'minitest/autorun'
|
39
9
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
:int_ptr => {:type => "int*", :name => 'MyIntPtr', :ptr? => true, :const? => false},
|
44
|
-
:mytype => {:type => "MY_TYPE", :name => 'MyMyType', :ptr? => false, :const? => true},
|
45
|
-
:mytype_ptr => {:type => "MY_TYPE*", :name => 'MyMyTypePtr', :ptr? => true, :const? => false},
|
46
|
-
:string => {:type => "char*", :name => 'MyStr', :ptr? => false, :const? => true},
|
47
|
-
}
|
10
|
+
def create_mocks(*mocks)
|
11
|
+
mocks.each do |mock|
|
12
|
+
eval "@#{mock} = Minitest::Mock.new"
|
48
13
|
end
|
49
14
|
end
|
15
|
+
|
16
|
+
def create_stub(funcs)
|
17
|
+
stub = Class.new
|
18
|
+
#if (RUBY_VERSION.split('.')[0].to_i >= 2)
|
19
|
+
# funcs.each_pair {|k,v| stub.define_singleton_method(k) {|*unused| return v } }
|
20
|
+
#else
|
21
|
+
blob = "class << stub\n"
|
22
|
+
funcs.each_pair {|k,v| blob += "def #{k.to_s}(unused=nil)\n #{v.inspect}\nend\n" }
|
23
|
+
blob += "end"
|
24
|
+
eval blob
|
25
|
+
#end
|
26
|
+
stub
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_return
|
30
|
+
{
|
31
|
+
:int => {:type => "int", :name => 'cmock_to_return', :ptr? => false, :const? => false, :void? => false, :str => 'int cmock_to_return'},
|
32
|
+
:int_ptr => {:type => "int*", :name => 'cmock_to_return', :ptr? => true, :const? => false, :void? => false, :str => 'int* cmock_to_return'},
|
33
|
+
:void => {:type => "void", :name => 'cmock_to_return', :ptr? => false, :const? => false, :void? => true, :str => 'void cmock_to_return'},
|
34
|
+
:string => {:type => "char*", :name => 'cmock_to_return', :ptr? => false, :const? => true, :void? => false, :str => 'const char* cmock_to_return'},
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_arg
|
39
|
+
{
|
40
|
+
:int => {:type => "int", :name => 'MyInt', :ptr? => false, :const? => false},
|
41
|
+
:int_ptr => {:type => "int*", :name => 'MyIntPtr', :ptr? => true, :const? => false},
|
42
|
+
:mytype => {:type => "MY_TYPE", :name => 'MyMyType', :ptr? => false, :const? => true},
|
43
|
+
:mytype_ptr => {:type => "MY_TYPE*", :name => 'MyMyTypePtr', :ptr? => true, :const? => false},
|
44
|
+
:string => {:type => "char*", :name => 'MyStr', :ptr? => false, :const? => true},
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
@@ -2,19 +2,16 @@
|
|
2
2
|
# CMock Project - Automatic Mock Generation for C
|
3
3
|
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
4
4
|
# [Released under MIT License. Please refer to license.txt for details]
|
5
|
-
# ==========================================
|
5
|
+
# ==========================================
|
6
|
+
|
6
7
|
|
7
8
|
require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
|
8
9
|
require 'cmock_config'
|
9
10
|
|
10
|
-
class CMockConfigTest < Test::Unit::TestCase
|
11
|
-
def setup
|
12
|
-
end
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
should "use default settings when no parameters are specified" do
|
12
|
+
describe CMockConfig, "Verify CMockConfig Module" do
|
13
|
+
|
14
|
+
it "use default settings when no parameters are specified" do
|
18
15
|
config = CMockConfig.new
|
19
16
|
assert_equal(CMockConfig::CMockDefaultOptions[:mock_path], config.mock_path)
|
20
17
|
assert_equal(CMockConfig::CMockDefaultOptions[:includes], config.includes)
|
@@ -22,8 +19,8 @@ class CMockConfigTest < Test::Unit::TestCase
|
|
22
19
|
assert_equal(CMockConfig::CMockDefaultOptions[:plugins], config.plugins)
|
23
20
|
assert_equal(CMockConfig::CMockDefaultOptions[:treat_externs], config.treat_externs)
|
24
21
|
end
|
25
|
-
|
26
|
-
|
22
|
+
|
23
|
+
it "replace only options specified in a hash" do
|
27
24
|
test_includes = ['hello']
|
28
25
|
test_attributes = ['blah', 'bleh']
|
29
26
|
config = CMockConfig.new(:includes => test_includes, :attributes => test_attributes)
|
@@ -33,8 +30,8 @@ class CMockConfigTest < Test::Unit::TestCase
|
|
33
30
|
assert_equal(CMockConfig::CMockDefaultOptions[:plugins], config.plugins)
|
34
31
|
assert_equal(CMockConfig::CMockDefaultOptions[:treat_externs], config.treat_externs)
|
35
32
|
end
|
36
|
-
|
37
|
-
|
33
|
+
|
34
|
+
it "replace only options specified in a yaml file" do
|
38
35
|
test_plugins = [:soda, :pizza]
|
39
36
|
config = CMockConfig.new("#{File.expand_path(File.dirname(__FILE__))}/cmock_config_test.yml")
|
40
37
|
assert_equal(CMockConfig::CMockDefaultOptions[:mock_path], config.mock_path)
|
@@ -43,8 +40,8 @@ class CMockConfigTest < Test::Unit::TestCase
|
|
43
40
|
assert_equal(:include, config.treat_externs)
|
44
41
|
end
|
45
42
|
|
46
|
-
|
47
|
-
|
43
|
+
it "populate treat_as map with internal standard_treat_as_map defaults, redefine defaults, and add custom values" do
|
44
|
+
|
48
45
|
user_treat_as1 = {
|
49
46
|
'BOOL' => 'UINT8', # redefine standard default
|
50
47
|
'unsigned long' => 'INT', # redefine standard default
|
@@ -55,10 +52,10 @@ class CMockConfigTest < Test::Unit::TestCase
|
|
55
52
|
'BOOL' => 'INT16', # redefine standard default
|
56
53
|
'U16' => 'HEX16' # custom value
|
57
54
|
}
|
58
|
-
|
55
|
+
|
59
56
|
config1 = CMockConfig.new({:treat_as => user_treat_as1})
|
60
57
|
config2 = CMockConfig.new({:treat_as => user_treat_as2})
|
61
|
-
|
58
|
+
|
62
59
|
# ----- USER SET 1
|
63
60
|
# standard defaults
|
64
61
|
assert_equal('INT', config1.treat_as['BOOL_T'])
|
@@ -73,16 +70,16 @@ class CMockConfigTest < Test::Unit::TestCase
|
|
73
70
|
# overrides
|
74
71
|
assert_equal('UINT8', config1.treat_as['BOOL'])
|
75
72
|
assert_equal('INT', config1.treat_as['unsigned long'])
|
76
|
-
|
73
|
+
|
77
74
|
# added custom values
|
78
75
|
assert_equal('UINT8', config1.treat_as['U8'])
|
79
76
|
assert_equal('UINT16', config1.treat_as['U16'])
|
80
|
-
|
77
|
+
|
81
78
|
# standard_treat_as_map: unchanged
|
82
79
|
assert_equal('INT', config1.standard_treat_as_map['BOOL'])
|
83
|
-
assert_equal('HEX32', config1.standard_treat_as_map['unsigned long'])
|
80
|
+
assert_equal('HEX32', config1.standard_treat_as_map['unsigned long'])
|
84
81
|
assert_equal('STRING', config1.standard_treat_as_map['char*'])
|
85
|
-
|
82
|
+
|
86
83
|
# ----- USER SET 2
|
87
84
|
# standard defaults
|
88
85
|
assert_equal('INT', config2.treat_as['BOOL_T'])
|
@@ -97,25 +94,25 @@ class CMockConfigTest < Test::Unit::TestCase
|
|
97
94
|
|
98
95
|
# overrides
|
99
96
|
assert_equal('INT16', config2.treat_as['BOOL'])
|
100
|
-
|
97
|
+
|
101
98
|
# added custom values
|
102
99
|
assert_equal('HEX16', config2.treat_as['U16'])
|
103
|
-
|
100
|
+
|
104
101
|
# standard_treat_as_map: unchanged
|
105
102
|
assert_equal('INT', config2.standard_treat_as_map['BOOL'])
|
106
|
-
assert_equal('HEX32', config2.standard_treat_as_map['unsigned long'])
|
103
|
+
assert_equal('HEX32', config2.standard_treat_as_map['unsigned long'])
|
107
104
|
assert_equal('STRING', config2.standard_treat_as_map['char*'])
|
108
105
|
end
|
109
|
-
|
110
|
-
|
106
|
+
|
107
|
+
it "standard treat_as map should be incorruptable" do
|
111
108
|
config = CMockConfig.new({})
|
112
|
-
|
109
|
+
|
113
110
|
assert_equal('INT', config.standard_treat_as_map['BOOL_T'])
|
114
|
-
|
111
|
+
|
115
112
|
local = config.standard_treat_as_map
|
116
113
|
local['BOOL_T'] = "U8"
|
117
|
-
|
114
|
+
|
118
115
|
assert_equal('INT', config.standard_treat_as_map['BOOL_T'])
|
119
116
|
end
|
120
|
-
|
117
|
+
|
121
118
|
end
|
@@ -2,29 +2,26 @@
|
|
2
2
|
# CMock Project - Automatic Mock Generation for C
|
3
3
|
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
4
4
|
# [Released under MIT License. Please refer to license.txt for details]
|
5
|
-
# ==========================================
|
5
|
+
# ==========================================
|
6
6
|
|
7
7
|
require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
|
8
8
|
require 'cmock_file_writer'
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
describe CMockFileWriter, "Verify CMockFileWriter Module" do
|
11
|
+
|
12
|
+
before do
|
12
13
|
create_mocks :config
|
13
14
|
@cmock_file_writer = CMockFileWriter.new(@config)
|
14
15
|
end
|
15
16
|
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
should "have set up internal accessors correctly on init" do
|
20
|
-
assert_equal(@config, @cmock_file_writer.config)
|
17
|
+
after do
|
21
18
|
end
|
22
|
-
|
23
|
-
|
19
|
+
|
20
|
+
it "complain if a block was not specified when calling create" do
|
24
21
|
begin
|
25
22
|
@cmock_file_writer.create_file("test.txt")
|
26
23
|
assert false, "Should Have Thrown An Error When Calling Without A Block"
|
27
24
|
rescue
|
28
25
|
end
|
29
|
-
end
|
26
|
+
end
|
30
27
|
end
|