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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/ceedling.gemspec +1 -1
  3. data/lib/ceedling/version.rb +2 -2
  4. data/lib/ceedling/version.rb.erb +1 -2
  5. data/test_graveyard/unit/busted/generator_test_runner_test.rb +2 -5
  6. data/vendor/cmock/Gemfile +1 -3
  7. data/vendor/cmock/Rakefile +10 -17
  8. data/vendor/cmock/docs/license.txt +18 -30
  9. data/vendor/cmock/examples/gcc.yml +2 -2
  10. data/vendor/cmock/examples/iar_v4.yml +3 -3
  11. data/vendor/cmock/examples/iar_v5.yml +3 -3
  12. data/vendor/cmock/examples/rakefile_helper.rb +35 -35
  13. data/vendor/cmock/lib/cmock_generator.rb +17 -5
  14. data/vendor/cmock/lib/cmock_generator_plugin_array.rb +9 -3
  15. data/vendor/cmock/lib/cmock_generator_plugin_ignore_arg.rb +1 -1
  16. data/vendor/cmock/lib/cmock_generator_plugin_return_thru_ptr.rb +1 -1
  17. data/vendor/cmock/lib/cmock_header_parser.rb +7 -3
  18. data/vendor/cmock/release/version.info +1 -1
  19. data/vendor/cmock/test/c/TestCMockCDynamic_Runner.c +1 -2
  20. data/vendor/cmock/test/c/TestCMockC_Runner.c +1 -1
  21. data/vendor/cmock/test/system/systest_generator.rb +6 -2
  22. data/vendor/cmock/test/system/test_compilation/const.h +3 -1
  23. data/vendor/cmock/test/test_helper.rb +38 -40
  24. data/vendor/cmock/test/unit/cmock_config_test.rb +26 -29
  25. data/vendor/cmock/test/unit/cmock_file_writer_test.rb +8 -11
  26. data/vendor/cmock/test/unit/cmock_generator_main_test.rb +82 -80
  27. data/vendor/cmock/test/unit/cmock_generator_plugin_array_test.rb +62 -43
  28. data/vendor/cmock/test/unit/cmock_generator_plugin_callback_test.rb +44 -45
  29. data/vendor/cmock/test/unit/cmock_generator_plugin_cexception_test.rb +30 -31
  30. data/vendor/cmock/test/unit/cmock_generator_plugin_expect_any_args_test.rb +15 -16
  31. data/vendor/cmock/test/unit/cmock_generator_plugin_expect_test.rb +76 -77
  32. data/vendor/cmock/test/unit/cmock_generator_plugin_ignore_arg_test.rb +19 -19
  33. data/vendor/cmock/test/unit/cmock_generator_plugin_ignore_test.rb +17 -18
  34. data/vendor/cmock/test/unit/cmock_generator_plugin_return_thru_ptr_test.rb +17 -17
  35. data/vendor/cmock/test/unit/cmock_generator_utils_test.rb +74 -65
  36. data/vendor/cmock/test/unit/cmock_header_parser_test.rb +103 -76
  37. data/vendor/cmock/test/unit/cmock_plugin_manager_test.rb +46 -36
  38. data/vendor/cmock/test/unit/cmock_unityhelper_parser_test.rb +85 -85
  39. data/vendor/unity/auto/generate_test_runner.rb +4 -3
  40. data/vendor/unity/auto/type_sanitizer.rb +8 -0
  41. data/vendor/unity/auto/unity_test_summary.py +135 -0
  42. data/vendor/unity/examples/example_1/makefile +16 -0
  43. data/vendor/unity/examples/example_1/src/ProductionCode2.c +2 -0
  44. data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +0 -13
  45. data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +0 -13
  46. data/vendor/unity/examples/example_2/makefile +20 -1
  47. data/vendor/unity/examples/example_2/src/ProductionCode2.c +2 -0
  48. data/vendor/unity/examples/example_2/test/test_runners/all_tests.c +2 -2
  49. data/vendor/unity/examples/example_3/makefile +16 -0
  50. data/vendor/unity/examples/example_3/src/ProductionCode2.c +2 -0
  51. data/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c +0 -13
  52. data/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode_Runner.c +0 -13
  53. data/vendor/unity/extras/fixture/rakefile.rb +14 -3
  54. data/vendor/unity/extras/fixture/src/unity_fixture.c +21 -11
  55. data/vendor/unity/extras/fixture/src/unity_fixture.h +8 -4
  56. data/vendor/unity/extras/fixture/src/unity_fixture_internals.h +1 -1
  57. data/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +5 -0
  58. data/vendor/unity/extras/fixture/test/main/AllTests.c +2 -2
  59. data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +8 -8
  60. data/vendor/unity/extras/fixture/test/unity_output_Spy.c +2 -2
  61. data/vendor/unity/extras/fixture/test/unity_output_Spy.h +2 -2
  62. data/vendor/unity/release/version.info +1 -1
  63. data/vendor/unity/src/unity.c +26 -19
  64. data/vendor/unity/src/unity_internals.h +9 -12
  65. data/vendor/unity/test/targets/gcc_auto_stdint.yml +13 -0
  66. metadata +4 -5
  67. data/vendor/cmock/test/spec/cmock_file_writer_spec.rb +0 -45
  68. data/vendor/cmock/test/spec/cmock_generator_plugin_array_spec.rb +0 -52
  69. data/vendor/cmock/test/spec/spec_helper.rb +0 -12
@@ -35,52 +35,46 @@ class MockedPluginHelper
35
35
  end
36
36
  end
37
37
 
38
- class CMockGeneratorTest < Test::Unit::TestCase
39
- def setup
38
+ describe CMockGenerator, "Verify CMockGenerator Module" do
39
+
40
+ before do
40
41
  create_mocks :config, :file_writer, :utils, :plugins
41
42
  @module_name = "PoutPoutFish"
42
43
 
43
44
  #no strict handling
44
- @config.expect.mock_prefix.returns("Mock")
45
- @config.expect.enforce_strict_ordering.returns(nil)
46
- @config.expect.framework.returns(:unity)
47
- @config.expect.includes.returns(["ConfigRequiredHeader1.h","ConfigRequiredHeader2.h"])
48
- #@config.expect.includes_h_pre_orig_header.returns(nil) #not called because includes called
49
- @config.expect.includes_h_post_orig_header.returns(nil)
50
- @config.expect.includes_c_pre_header.returns(nil)
51
- @config.expect.includes_c_post_header.returns(nil)
45
+ @config.expect :mock_prefix, "Mock"
46
+ @config.expect :enforce_strict_ordering, nil
47
+ @config.expect :framework, :unity
48
+ @config.expect :includes, ["ConfigRequiredHeader1.h","ConfigRequiredHeader2.h"]
49
+ #@config.expect :includes_h_pre_orig_header, nil #not called because includes called
50
+ @config.expect :includes_h_post_orig_header, nil
51
+ @config.expect :includes_c_pre_header, nil
52
+ @config.expect :includes_c_post_header, nil
52
53
  @cmock_generator = CMockGenerator.new(@config, @file_writer, @utils, @plugins)
53
54
  @cmock_generator.module_name = @module_name
54
55
  @cmock_generator.mock_name = "Mock#{@module_name}"
55
56
  @cmock_generator.clean_mock_name = "Mock#{@module_name}"
56
57
 
57
58
  #strict handling
58
- @config.expect.mock_prefix.returns("Mock")
59
- @config.expect.enforce_strict_ordering.returns(true)
60
- @config.expect.framework.returns(:unity)
61
- @config.expect.includes.returns(nil)
62
- @config.expect.includes_h_pre_orig_header.returns(nil)
63
- @config.expect.includes_h_post_orig_header.returns(nil)
64
- @config.expect.includes_c_pre_header.returns(nil)
65
- @config.expect.includes_c_post_header.returns(nil)
59
+ @config.expect :mock_prefix, "Mock"
60
+ @config.expect :enforce_strict_ordering, true
61
+ @config.expect :framework, :unity
62
+ @config.expect :includes, nil
63
+ @config.expect :includes_h_pre_orig_header, nil
64
+ @config.expect :includes_h_post_orig_header, nil
65
+ @config.expect :includes_c_pre_header, nil
66
+ @config.expect :includes_c_post_header, nil
66
67
  @cmock_generator_strict = CMockGenerator.new(@config, @file_writer, @utils, @plugins)
67
68
  @cmock_generator_strict.module_name = @module_name
68
69
  @cmock_generator_strict.mock_name = "Mock#{@module_name}"
69
70
  @cmock_generator_strict.clean_mock_name = "Mock#{@module_name}"
70
71
  end
71
72
 
72
- def teardown
73
- end
74
-
75
- should "have set up internal accessors correctly on init" do
76
- assert_equal(@config, @cmock_generator.config)
77
- assert_equal(@file_writer, @cmock_generator.file_writer)
78
- assert_equal(@utils, @cmock_generator.utils)
79
- assert_equal(@plugins, @cmock_generator.plugins)
73
+ after do
80
74
  end
81
75
 
82
- should "create the top of a header file with optional include files from config and include file from plugin" do
83
- @config.expect.mock_prefix.returns("Mock")
76
+ it "create the top of a header file with optional include files from config and include file from plugin" do
77
+ @config.expect :mock_prefix, "Mock"
84
78
  orig_filename = "PoutPoutFish.h"
85
79
  define_name = "MOCKPOUTPOUTFISH_H"
86
80
  mock_name = "MockPoutPoutFish"
@@ -95,37 +89,39 @@ class CMockGeneratorTest < Test::Unit::TestCase
95
89
  "#include \"PluginRequiredHeader.h\"\n",
96
90
  "\n",
97
91
  "/* Ignore the following warnings, since we are copying code */\n",
98
- "#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)\n",
92
+ "#if defined(__GNUC__) && !defined(__ICC)\n",
93
+ "#if !defined(__clang__)\n",
99
94
  "#pragma GCC diagnostic ignored \"-Wpragmas\"\n",
100
95
  "#endif\n",
101
96
  "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n",
102
97
  "#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n",
98
+ "#endif\n",
103
99
  "\n",
104
100
  ]
105
101
 
106
- @config.expect.orig_header_include_fmt.returns("#include \"%s\"")
107
- @plugins.expect.run(:include_files).returns("#include \"PluginRequiredHeader.h\"\n")
102
+ @config.expect :orig_header_include_fmt, "#include \"%s\""
103
+ @plugins.expect :run, "#include \"PluginRequiredHeader.h\"\n", [:include_files]
108
104
 
109
105
  @cmock_generator.create_mock_header_header(output, "MockPoutPoutFish.h")
110
106
 
111
107
  assert_equal(expected, output)
112
108
  end
113
109
 
114
- should "handle dashes and spaces in the module name" do
110
+ it "handle dashes and spaces in the module name" do
115
111
  #no strict handling
116
- @config.expect.mock_prefix.returns("Mock")
117
- @config.expect.enforce_strict_ordering.returns(nil)
118
- @config.expect.framework.returns(:unity)
119
- @config.expect.includes.returns(["ConfigRequiredHeader1.h","ConfigRequiredHeader2.h"])
120
- @config.expect.includes_h_post_orig_header.returns(nil)
121
- @config.expect.includes_c_pre_header.returns(nil)
122
- @config.expect.includes_c_post_header.returns(nil)
112
+ @config.expect :mock_prefix, "Mock"
113
+ @config.expect :enforce_strict_ordering, nil
114
+ @config.expect :framework, :unity
115
+ @config.expect :includes, ["ConfigRequiredHeader1.h","ConfigRequiredHeader2.h"]
116
+ @config.expect :includes_h_post_orig_header, nil
117
+ @config.expect :includes_c_pre_header, nil
118
+ @config.expect :includes_c_post_header, nil
123
119
  @cmock_generator2 = CMockGenerator.new(@config, @file_writer, @utils, @plugins)
124
120
  @cmock_generator2.module_name = "Pout-Pout Fish"
125
121
  @cmock_generator2.mock_name = "MockPout-Pout Fish"
126
122
  @cmock_generator2.clean_mock_name = "MockPout_Pout_Fish"
127
123
 
128
- @config.expect.mock_prefix.returns("Mock")
124
+ @config.expect :mock_prefix, "Mock"
129
125
  orig_filename = "Pout-Pout Fish.h"
130
126
  define_name = "MOCKPOUT_POUT_FISH_H"
131
127
  mock_name = "MockPout_Pout_Fish"
@@ -140,24 +136,26 @@ class CMockGeneratorTest < Test::Unit::TestCase
140
136
  "#include \"PluginRequiredHeader.h\"\n",
141
137
  "\n",
142
138
  "/* Ignore the following warnings, since we are copying code */\n",
143
- "#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)\n",
139
+ "#if defined(__GNUC__) && !defined(__ICC)\n",
140
+ "#if !defined(__clang__)\n",
144
141
  "#pragma GCC diagnostic ignored \"-Wpragmas\"\n",
145
142
  "#endif\n",
146
143
  "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n",
147
144
  "#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n",
145
+ "#endif\n",
148
146
  "\n",
149
147
  ]
150
148
 
151
- @config.expect.orig_header_include_fmt.returns("#include \"%s\"")
152
- @plugins.expect.run(:include_files).returns("#include \"PluginRequiredHeader.h\"\n")
149
+ @config.expect :orig_header_include_fmt, "#include \"%s\""
150
+ @plugins.expect :run, "#include \"PluginRequiredHeader.h\"\n", [:include_files]
153
151
 
154
152
  @cmock_generator2.create_mock_header_header(output, "MockPout-Pout Fish.h")
155
153
 
156
154
  assert_equal(expected, output)
157
155
  end
158
156
 
159
- should "create the top of a header file with optional include files from config" do
160
- @config.expect.mock_prefix.returns("Mock")
157
+ it "create the top of a header file with optional include files from config" do
158
+ @config.expect :mock_prefix, "Mock"
161
159
  orig_filename = "PoutPoutFish.h"
162
160
  define_name = "MOCKPOUTPOUTFISH_H"
163
161
  mock_name = "MockPoutPoutFish"
@@ -171,24 +169,26 @@ class CMockGeneratorTest < Test::Unit::TestCase
171
169
  "#include \"#{orig_filename}\"\n",
172
170
  "\n",
173
171
  "/* Ignore the following warnings, since we are copying code */\n",
174
- "#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)\n",
172
+ "#if defined(__GNUC__) && !defined(__ICC)\n",
173
+ "#if !defined(__clang__)\n",
175
174
  "#pragma GCC diagnostic ignored \"-Wpragmas\"\n",
176
175
  "#endif\n",
177
176
  "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n",
178
177
  "#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n",
178
+ "#endif\n",
179
179
  "\n",
180
180
  ]
181
181
 
182
- @config.expect.orig_header_include_fmt.returns("#include \"%s\"")
183
- @plugins.expect.run(:include_files).returns('')
182
+ @config.expect :orig_header_include_fmt, "#include \"%s\""
183
+ @plugins.expect :run, '', [:include_files]
184
184
 
185
185
  @cmock_generator.create_mock_header_header(output, "MockPoutPoutFish.h")
186
186
 
187
187
  assert_equal(expected, output)
188
188
  end
189
189
 
190
- should "create the top of a header file with include file from plugin" do
191
- @config.expect.mock_prefix.returns("Mock")
190
+ it "create the top of a header file with include file from plugin" do
191
+ @config.expect :mock_prefix, "Mock"
192
192
  orig_filename = "PoutPoutFish.h"
193
193
  define_name = "MOCKPOUTPOUTFISH_H"
194
194
  mock_name = "MockPoutPoutFish"
@@ -203,23 +203,25 @@ class CMockGeneratorTest < Test::Unit::TestCase
203
203
  "#include \"PluginRequiredHeader.h\"\n",
204
204
  "\n",
205
205
  "/* Ignore the following warnings, since we are copying code */\n",
206
- "#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)\n",
206
+ "#if defined(__GNUC__) && !defined(__ICC)\n",
207
+ "#if !defined(__clang__)\n",
207
208
  "#pragma GCC diagnostic ignored \"-Wpragmas\"\n",
208
209
  "#endif\n",
209
210
  "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n",
210
211
  "#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n",
212
+ "#endif\n",
211
213
  "\n",
212
214
  ]
213
215
 
214
- @config.expect.orig_header_include_fmt.returns("#include \"%s\"")
215
- @plugins.expect.run(:include_files).returns("#include \"PluginRequiredHeader.h\"\n")
216
+ @config.expect :orig_header_include_fmt, "#include \"%s\""
217
+ @plugins.expect :run, "#include \"PluginRequiredHeader.h\"\n", [:include_files]
216
218
 
217
219
  @cmock_generator.create_mock_header_header(output, "MockPoutPoutFish.h")
218
220
 
219
221
  assert_equal(expected, output)
220
222
  end
221
223
 
222
- should "write typedefs" do
224
+ it "write typedefs" do
223
225
  typedefs = [ 'typedef unsigned char U8;',
224
226
  'typedef char S8;',
225
227
  'typedef unsigned long U32;'
@@ -237,7 +239,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
237
239
  assert_equal(expected, output.flatten)
238
240
  end
239
241
 
240
- should "create the header file service call declarations" do
242
+ it "create the header file service call declarations" do
241
243
  mock_name = "MockPoutPoutFish"
242
244
 
243
245
  output = []
@@ -251,7 +253,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
251
253
  assert_equal(expected, output)
252
254
  end
253
255
 
254
- should "append the proper footer to the header file" do
256
+ it "append the proper footer to the header file" do
255
257
  output = []
256
258
  expected = ["\n#endif\n"]
257
259
 
@@ -260,7 +262,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
260
262
  assert_equal(expected, output)
261
263
  end
262
264
 
263
- should "create a proper heading for a source file" do
265
+ it "create a proper heading for a source file" do
264
266
  output = []
265
267
  expected = [ "/* AUTOGENERATED FILE. DO NOT EDIT. */\n",
266
268
  "#include <string.h>\n",
@@ -277,7 +279,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
277
279
  assert_equal(expected, output)
278
280
  end
279
281
 
280
- should "create the instance structure where it is needed when no functions" do
282
+ it "create the instance structure where it is needed when no functions" do
281
283
  output = []
282
284
  functions = []
283
285
  expected = [ "static struct MockPoutPoutFishInstance\n",
@@ -291,7 +293,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
291
293
  assert_equal(expected, output.join)
292
294
  end
293
295
 
294
- should "create the instance structure where it is needed when functions required" do
296
+ it "create the instance structure where it is needed when functions required" do
295
297
  output = []
296
298
  functions = [ { :name => "First", :args => "int Candy", :return => test_return[:int] },
297
299
  { :name => "Second", :args => "bool Smarty", :return => test_return[:string] }
@@ -310,18 +312,18 @@ class CMockGeneratorTest < Test::Unit::TestCase
310
312
  " CMOCK_MEM_INDEX_TYPE Second_CallInstance;\n",
311
313
  "} Mock;\n\n"
312
314
  ].join
313
- @plugins.expect.run(:instance_typedefs, functions[0]).returns([" b1"," b2"])
314
- @plugins.expect.run(:instance_typedefs, functions[1]).returns([])
315
+ @plugins.expect :run, [" b1"," b2"], [:instance_typedefs, functions[0]]
316
+ @plugins.expect :run, [], [:instance_typedefs, functions[1]]
315
317
 
316
- @plugins.expect.run(:instance_structure, functions[0]).returns([" d1"])
317
- @plugins.expect.run(:instance_structure, functions[1]).returns([" e1"," e2"," e3"])
318
+ @plugins.expect :run, [" d1"], [:instance_structure, functions[0]]
319
+ @plugins.expect :run, [" e1"," e2"," e3"], [:instance_structure, functions[1]]
318
320
 
319
321
  @cmock_generator.create_instance_structure(output, functions)
320
322
 
321
323
  assert_equal(expected, output.join)
322
324
  end
323
325
 
324
- should "create extern declarations for source file" do
326
+ it "create extern declarations for source file" do
325
327
  output = []
326
328
  expected = [ "extern jmp_buf AbortFrame;\n",
327
329
  "\n" ]
@@ -331,7 +333,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
331
333
  assert_equal(expected, output.flatten)
332
334
  end
333
335
 
334
- should "create extern declarations for source file when using strict ordering" do
336
+ it "create extern declarations for source file when using strict ordering" do
335
337
  output = []
336
338
  expected = [ "extern jmp_buf AbortFrame;\n",
337
339
  "extern int GlobalExpectCount;\n",
@@ -343,7 +345,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
343
345
  assert_equal(expected, output.flatten)
344
346
  end
345
347
 
346
- should "create mock verify functions in source file when no functions specified" do
348
+ it "create mock verify functions in source file when no functions specified" do
347
349
  functions = []
348
350
  output = []
349
351
  expected = "void MockPoutPoutFish_Verify(void)\n{\n}\n\n"
@@ -353,7 +355,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
353
355
  assert_equal(expected, output.join)
354
356
  end
355
357
 
356
- should "create mock verify functions in source file when extra functions specified" do
358
+ it "create mock verify functions in source file when extra functions specified" do
357
359
  functions = [ { :name => "First", :args => "int Candy", :return => test_return[:int] },
358
360
  { :name => "Second", :args => "bool Smarty", :return => test_return[:string] }
359
361
  ]
@@ -366,8 +368,8 @@ class CMockGeneratorTest < Test::Unit::TestCase
366
368
  " Dos_Second",
367
369
  "}\n\n"
368
370
  ]
369
- @plugins.expect.run(:mock_verify, functions[0]).returns([" Uno_First"," Dos_First"])
370
- @plugins.expect.run(:mock_verify, functions[1]).returns([" Uno_Second"," Dos_Second"])
371
+ @plugins.expect :run, [" Uno_First"," Dos_First"], [:mock_verify, functions[0]]
372
+ @plugins.expect :run, [" Uno_Second"," Dos_Second"], [:mock_verify, functions[1]]
371
373
 
372
374
  @cmock_generator.ordered = true
373
375
  @cmock_generator.create_mock_verify_function(output, functions)
@@ -375,7 +377,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
375
377
  assert_equal(expected, output.flatten)
376
378
  end
377
379
 
378
- should "create mock init functions in source file" do
380
+ it "create mock init functions in source file" do
379
381
  output = []
380
382
  expected = [ "void MockPoutPoutFish_Init(void)\n{\n",
381
383
  " MockPoutPoutFish_Destroy();\n",
@@ -387,7 +389,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
387
389
  assert_equal(expected.join, output.join)
388
390
  end
389
391
 
390
- should "create mock destroy functions in source file" do
392
+ it "create mock destroy functions in source file" do
391
393
  functions = []
392
394
  output = []
393
395
  expected = [ "void MockPoutPoutFish_Destroy(void)\n{\n",
@@ -401,7 +403,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
401
403
  assert_equal(expected.join, output.join)
402
404
  end
403
405
 
404
- should "create mock destroy functions in source file when specified with strict ordering" do
406
+ it "create mock destroy functions in source file when specified with strict ordering" do
405
407
  functions = [ { :name => "First", :args => "int Candy", :return => test_return[:int] },
406
408
  { :name => "Second", :args => "bool Smarty", :return => test_return[:string] }
407
409
  ]
@@ -414,15 +416,15 @@ class CMockGeneratorTest < Test::Unit::TestCase
414
416
  " GlobalVerifyOrder = 0;\n",
415
417
  "}\n\n"
416
418
  ]
417
- @plugins.expect.run(:mock_destroy, functions[0]).returns([])
418
- @plugins.expect.run(:mock_destroy, functions[1]).returns([" uno"])
419
+ @plugins.expect :run, [], [:mock_destroy, functions[0]]
420
+ @plugins.expect :run, [" uno"], [:mock_destroy, functions[1]]
419
421
 
420
422
  @cmock_generator_strict.create_mock_destroy_function(output, functions)
421
423
 
422
424
  assert_equal(expected.join, output.join)
423
425
  end
424
426
 
425
- should "create mock implementation functions in source file" do
427
+ it "create mock implementation functions in source file" do
426
428
  function = { :modifier => "static",
427
429
  :return => test_return[:int],
428
430
  :args_string => "uint32 sandwiches, const char* named",
@@ -445,15 +447,15 @@ class CMockGeneratorTest < Test::Unit::TestCase
445
447
  " return cmock_call_instance->ReturnVal;\n",
446
448
  "}\n\n"
447
449
  ]
448
- @plugins.expect.run(:mock_implementation_precheck, function).returns([" uno"])
449
- @plugins.expect.run(:mock_implementation, function).returns([" dos"," tres"])
450
+ @plugins.expect :run, [" uno"], [:mock_implementation_precheck, function]
451
+ @plugins.expect :run, [" dos"," tres"], [:mock_implementation, function]
450
452
 
451
453
  @cmock_generator.create_mock_implementation(output, function)
452
454
 
453
455
  assert_equal(expected.join, output.join)
454
456
  end
455
457
 
456
- should "create mock implementation functions in source file with different options" do
458
+ it "create mock implementation functions in source file with different options" do
457
459
  function = { :modifier => "",
458
460
  :c_calling_convention => "__stdcall",
459
461
  :return => test_return[:int],
@@ -477,8 +479,8 @@ class CMockGeneratorTest < Test::Unit::TestCase
477
479
  " return cmock_call_instance->ReturnVal;\n",
478
480
  "}\n\n"
479
481
  ]
480
- @plugins.expect.run(:mock_implementation_precheck, function).returns([" uno"])
481
- @plugins.expect.run(:mock_implementation, function).returns([" dos"," tres"])
482
+ @plugins.expect :run, [" uno"], [:mock_implementation_precheck, function]
483
+ @plugins.expect :run, [" dos"," tres"], [:mock_implementation, function]
482
484
 
483
485
  @cmock_generator.create_mock_implementation(output, function)
484
486
 
@@ -2,104 +2,123 @@
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_generator_plugin_array'
9
9
 
10
- class CMockGeneratorPluginArrayTest < Test::Unit::TestCase
11
- def setup
12
- create_mocks :config, :utils
13
-
10
+ describe CMockGeneratorPluginArray, "Verify CMockPGeneratorluginArray Module" do
11
+ before do
12
+ create_mocks :utils
13
+
14
14
  #no strict ordering
15
- @config.expect.when_ptr.returns(:compare_data)
16
- @config.expect.enforce_strict_ordering.returns(false)
17
- @config.stubs!(:respond_to?).returns(true)
18
- @utils.expect.helpers.returns({})
15
+ @config = create_stub(
16
+ :when_ptr => :compare_data,
17
+ :enforce_strict_ordering => false,
18
+ :respond_to? => true )
19
+
20
+ @utils = create_stub(
21
+ :helpers => {},
22
+ :code_add_base_expectation => "mock_retval_0"
23
+ )
24
+
19
25
  @cmock_generator_plugin_array = CMockGeneratorPluginArray.new(@config, @utils)
20
26
  end
21
27
 
22
- def teardown
28
+ after do
23
29
  end
24
-
25
- should "have set up internal accessors correctly on init" do
26
- assert_equal(@config, @cmock_generator_plugin_array.config)
27
- assert_equal(@utils, @cmock_generator_plugin_array.utils)
30
+
31
+ it "have set up internal priority" do
28
32
  assert_equal(nil, @cmock_generator_plugin_array.unity_helper)
29
33
  assert_equal(8, @cmock_generator_plugin_array.priority)
30
34
  end
31
-
32
- should "not include any additional include files" do
35
+
36
+ it "not include any additional include files" do
33
37
  assert(!@cmock_generator_plugin_array.respond_to?(:include_files))
34
38
  end
35
-
36
- should "not add to typedef structure for functions of style 'int* func(void)'" do
39
+
40
+ it "not add to typedef structure for functions of style 'int* func(void)'" do
37
41
  function = {:name => "Oak", :args => [], :return => test_return[:int_ptr]}
38
42
  returned = @cmock_generator_plugin_array.instance_typedefs(function)
39
43
  assert_equal("", returned)
40
44
  end
41
-
42
- should "add to tyepdef structure mock needs of functions of style 'void func(int chicken, int* pork)'" do
45
+
46
+ it "add to tyepdef structure mock needs of functions of style 'void func(int chicken, int* pork)'" do
43
47
  function = {:name => "Cedar", :args => [{ :name => "chicken", :type => "int", :ptr? => false}, { :name => "pork", :type => "int*", :ptr? => true}], :return => test_return[:void]}
44
48
  expected = " int Expected_pork_Depth;\n"
45
49
  returned = @cmock_generator_plugin_array.instance_typedefs(function)
46
50
  assert_equal(expected, returned)
47
51
  end
48
-
49
- should "not add an additional mock interface for functions not containing pointers" do
52
+
53
+ it "not add an additional mock interface for functions not containing pointers" do
50
54
  function = {:name => "Maple", :args_string => "int blah", :return => test_return[:string], :contains_ptr? => false}
51
55
  returned = @cmock_generator_plugin_array.mock_function_declarations(function)
52
56
  assert_nil(returned)
53
57
  end
54
-
55
- should "add another mock function declaration for functions of style 'void func(int* tofu)'" do
56
- function = {:name => "Pine",
58
+
59
+ it "add another mock function declaration for functions of style 'void func(int* tofu)'" do
60
+ function = {:name => "Pine",
57
61
  :args => [{ :type => "int*",
58
62
  :name => "tofu",
59
63
  :ptr? => true,
60
64
  }],
61
- :return => test_return[:void],
65
+ :return => test_return[:void],
62
66
  :contains_ptr? => true }
63
-
67
+
64
68
  expected = "#define #{function[:name]}_ExpectWithArray(tofu, tofu_Depth) #{function[:name]}_CMockExpectWithArray(__LINE__, tofu, tofu_Depth)\n" +
65
69
  "void #{function[:name]}_CMockExpectWithArray(UNITY_LINE_TYPE cmock_line, int* tofu, int tofu_Depth);\n"
66
70
  returned = @cmock_generator_plugin_array.mock_function_declarations(function)
67
71
  assert_equal(expected, returned)
68
72
  end
69
-
70
- should "add another mock function declaration for functions of style 'const char* func(int* tofu)'" do
71
- function = {:name => "Pine",
73
+
74
+ it "add another mock function declaration for functions of style 'const char* func(int* tofu)'" do
75
+ function = {:name => "Pine",
72
76
  :args => [{ :type => "int*",
73
77
  :name => "tofu",
74
78
  :ptr? => true,
75
79
  }],
76
80
  :return => test_return[:string],
77
81
  :contains_ptr? => true }
78
-
82
+
79
83
  expected = "#define #{function[:name]}_ExpectWithArrayAndReturn(tofu, tofu_Depth, cmock_retval) #{function[:name]}_CMockExpectWithArrayAndReturn(__LINE__, tofu, tofu_Depth, cmock_retval)\n" +
80
84
  "void #{function[:name]}_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, int* tofu, int tofu_Depth, const char* cmock_to_return);\n"
81
85
  returned = @cmock_generator_plugin_array.mock_function_declarations(function)
82
86
  assert_equal(expected, returned)
83
87
  end
84
-
85
- should "not have a mock function implementation" do
88
+
89
+ it "add another mock function declaration for functions of style 'const char* func(const int* tofu)'" do
90
+ function = {:name => "Pine",
91
+ :args => [{ :type => "int*",
92
+ :name => "tofu",
93
+ :ptr? => true,
94
+ :const? => true,
95
+ }],
96
+ :return => test_return[:string],
97
+ :contains_ptr? => true }
98
+
99
+ expected = "#define #{function[:name]}_ExpectWithArrayAndReturn(tofu, tofu_Depth, cmock_retval) #{function[:name]}_CMockExpectWithArrayAndReturn(__LINE__, tofu, tofu_Depth, cmock_retval)\n" +
100
+ "void #{function[:name]}_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, const int* tofu, int tofu_Depth, const char* cmock_to_return);\n"
101
+ returned = @cmock_generator_plugin_array.mock_function_declarations(function)
102
+ assert_equal(expected, returned)
103
+ end
104
+
105
+ it "not have a mock function implementation" do
86
106
  assert(!@cmock_generator_plugin_array.respond_to?(:mock_implementation))
87
107
  end
88
108
 
89
- should "not have a mock interfaces for functions of style 'int* func(void)'" do
109
+ it "not have a mock interfaces for functions of style 'int* func(void)'" do
90
110
  function = {:name => "Pear", :args => [], :args_string => "void", :return => test_return[:int_ptr]}
91
111
  returned = @cmock_generator_plugin_array.mock_interfaces(function)
92
112
  assert_nil(returned)
93
113
  end
94
-
95
- should "add mock interfaces for functions of style 'int* func(int* pescado, int pes)'" do
96
- function = {:name => "Lemon",
97
- :args => [{ :type => "int*", :name => "pescado", :ptr? => true}, { :type => "int", :name => "pes", :ptr? => false}],
98
- :args_string => "int* pescado, int pes",
99
- :return => test_return[:int_ptr],
114
+
115
+ it "add mock interfaces for functions of style 'int* func(int* pescado, int pes)'" do
116
+ function = {:name => "Lemon",
117
+ :args => [{ :type => "int*", :name => "pescado", :ptr? => true}, { :type => "int", :name => "pes", :ptr? => false}],
118
+ :args_string => "int* pescado, int pes",
119
+ :return => test_return[:int_ptr],
100
120
  :contains_ptr? => true }
101
- @utils.expect.code_add_base_expectation("Lemon").returns("mock_retval_0")
102
-
121
+
103
122
  expected = ["void Lemon_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, int* pescado, int pescado_Depth, int pes, int* cmock_to_return)\n",
104
123
  "{\n",
105
124
  "mock_retval_0",
@@ -110,5 +129,5 @@ class CMockGeneratorPluginArrayTest < Test::Unit::TestCase
110
129
  returned = @cmock_generator_plugin_array.mock_interfaces(function).join
111
130
  assert_equal(expected, returned)
112
131
  end
113
-
132
+
114
133
  end