ceedling 0.29.1 → 0.30.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1267) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +15 -16
  3. data/Gemfile.lock +1 -1
  4. data/README.md +108 -107
  5. data/Rakefile +11 -11
  6. data/assets/ceedling +3 -3
  7. data/assets/ceedling.cmd +0 -0
  8. data/assets/default_gitignore +5 -5
  9. data/assets/example_file.c +5 -5
  10. data/assets/example_file.h +6 -6
  11. data/assets/project_as_gem.yml +101 -97
  12. data/assets/project_with_guts.yml +102 -98
  13. data/assets/project_with_guts_gcov.yml +102 -98
  14. data/assets/project_with_guts_gcov_abortonuncovered.yml +93 -0
  15. data/assets/test_example_file.c +13 -13
  16. data/assets/test_example_file_boom.c +13 -13
  17. data/assets/test_example_file_success.c +14 -14
  18. data/assets/test_example_file_verbose.c +12 -12
  19. data/assets/uncovered_example_file.c +5 -0
  20. data/bin/ceedling +351 -339
  21. data/ceedling.gemspec +52 -36
  22. data/config/test_environment.rb +11 -11
  23. data/docs/Ceedling Basic Porting.pdf +0 -0
  24. data/docs/Ceedling Managing Release Code.pdf +0 -0
  25. data/docs/Ceedling Powerful Plugins.pdf +0 -0
  26. data/docs/Ceedling Working with IDEs.pdf +0 -0
  27. data/docs/CeedlingPacket.md +2213 -2134
  28. data/docs/CeedlingUpgrade.md +83 -83
  29. data/docs/ThrowTheSwitchCodingStandard.md +207 -207
  30. data/examples/blinky/project.yml +99 -99
  31. data/examples/blinky/rakefile.rb +31 -31
  32. data/examples/blinky/src/BlinkTask.c +21 -21
  33. data/examples/blinky/src/BlinkTask.h +6 -6
  34. data/examples/blinky/src/Configure.c +36 -36
  35. data/examples/blinky/src/Configure.h +6 -6
  36. data/examples/blinky/src/main.c +51 -51
  37. data/examples/blinky/src/main.h +9 -9
  38. data/examples/blinky/test/support/stub_interrupt.h +347 -347
  39. data/examples/blinky/test/support/stub_io.h +421 -421
  40. data/examples/blinky/test/support/stub_iom328p.h +883 -883
  41. data/examples/blinky/test/support/stub_sfr_defs.h +269 -269
  42. data/examples/blinky/test/test_BlinkTask.c +42 -42
  43. data/examples/blinky/test/test_Configure.c +29 -29
  44. data/examples/blinky/test/test_main.c +60 -60
  45. data/examples/temp_sensor/project.yml +66 -76
  46. data/examples/temp_sensor/rakefile.rb +6 -6
  47. data/examples/temp_sensor/src/AdcConductor.c +42 -42
  48. data/examples/temp_sensor/src/AdcConductor.h +13 -13
  49. data/examples/temp_sensor/src/AdcHardware.c +27 -27
  50. data/examples/temp_sensor/src/AdcHardware.h +11 -11
  51. data/examples/temp_sensor/src/AdcHardwareConfigurator.c +18 -18
  52. data/examples/temp_sensor/src/AdcHardwareConfigurator.h +10 -10
  53. data/examples/temp_sensor/src/AdcModel.c +33 -33
  54. data/examples/temp_sensor/src/AdcModel.h +13 -13
  55. data/examples/temp_sensor/src/AdcTemperatureSensor.c +51 -51
  56. data/examples/temp_sensor/src/AdcTemperatureSensor.h +10 -10
  57. data/examples/temp_sensor/src/Executor.c +25 -25
  58. data/examples/temp_sensor/src/Executor.h +9 -9
  59. data/examples/temp_sensor/src/IntrinsicsWrapper.c +18 -18
  60. data/examples/temp_sensor/src/IntrinsicsWrapper.h +7 -7
  61. data/examples/temp_sensor/src/Main.c +46 -46
  62. data/examples/temp_sensor/src/Main.h +7 -7
  63. data/examples/temp_sensor/src/Model.c +10 -10
  64. data/examples/temp_sensor/src/Model.h +8 -8
  65. data/examples/temp_sensor/src/ModelConfig.h +7 -7
  66. data/examples/temp_sensor/src/TaskScheduler.c +72 -72
  67. data/examples/temp_sensor/src/TaskScheduler.h +11 -11
  68. data/examples/temp_sensor/src/TemperatureCalculator.c +27 -27
  69. data/examples/temp_sensor/src/TemperatureCalculator.h +8 -8
  70. data/examples/temp_sensor/src/TemperatureFilter.c +38 -38
  71. data/examples/temp_sensor/src/TemperatureFilter.h +10 -10
  72. data/examples/temp_sensor/src/TimerConductor.c +15 -15
  73. data/examples/temp_sensor/src/TimerConductor.h +9 -9
  74. data/examples/temp_sensor/src/TimerConfigurator.c +51 -51
  75. data/examples/temp_sensor/src/TimerConfigurator.h +15 -15
  76. data/examples/temp_sensor/src/TimerHardware.c +15 -15
  77. data/examples/temp_sensor/src/TimerHardware.h +8 -8
  78. data/examples/temp_sensor/src/TimerInterruptConfigurator.c +55 -55
  79. data/examples/temp_sensor/src/TimerInterruptConfigurator.h +13 -13
  80. data/examples/temp_sensor/src/TimerInterruptHandler.c +25 -25
  81. data/examples/temp_sensor/src/TimerInterruptHandler.h +10 -10
  82. data/examples/temp_sensor/src/TimerModel.c +9 -9
  83. data/examples/temp_sensor/src/TimerModel.h +8 -8
  84. data/examples/temp_sensor/src/Types.h +90 -90
  85. data/examples/temp_sensor/src/UsartBaudRateRegisterCalculator.c +18 -18
  86. data/examples/temp_sensor/src/UsartBaudRateRegisterCalculator.h +8 -8
  87. data/examples/temp_sensor/src/UsartConductor.c +21 -21
  88. data/examples/temp_sensor/src/UsartConductor.h +7 -7
  89. data/examples/temp_sensor/src/UsartConfigurator.c +39 -39
  90. data/examples/temp_sensor/src/UsartConfigurator.h +13 -13
  91. data/examples/temp_sensor/src/UsartHardware.c +22 -22
  92. data/examples/temp_sensor/src/UsartHardware.h +9 -9
  93. data/examples/temp_sensor/src/UsartModel.c +34 -34
  94. data/examples/temp_sensor/src/UsartModel.h +10 -10
  95. data/examples/temp_sensor/src/UsartPutChar.c +16 -16
  96. data/examples/temp_sensor/src/UsartPutChar.h +8 -8
  97. data/examples/temp_sensor/src/UsartTransmitBufferStatus.c +7 -7
  98. data/examples/temp_sensor/src/UsartTransmitBufferStatus.h +8 -8
  99. data/examples/temp_sensor/test/TestAdcConductor.c +121 -121
  100. data/examples/temp_sensor/test/TestAdcHardware.c +44 -44
  101. data/examples/temp_sensor/test/TestAdcModel.c +33 -33
  102. data/examples/temp_sensor/test/TestExecutor.c +36 -36
  103. data/examples/temp_sensor/test/TestMain.c +24 -24
  104. data/examples/temp_sensor/test/TestModel.c +20 -20
  105. data/examples/temp_sensor/test/TestTaskScheduler.c +104 -104
  106. data/examples/temp_sensor/test/TestTemperatureCalculator.c +36 -36
  107. data/examples/temp_sensor/test/TestTemperatureFilter.c +79 -79
  108. data/examples/temp_sensor/test/TestTimerConductor.c +32 -32
  109. data/examples/temp_sensor/test/TestTimerHardware.c +26 -26
  110. data/examples/temp_sensor/test/TestTimerModel.c +18 -18
  111. data/examples/temp_sensor/test/TestUsartBaudRateRegisterCalculator.c +21 -21
  112. data/examples/temp_sensor/test/TestUsartConductor.c +40 -40
  113. data/examples/temp_sensor/test/TestUsartHardware.c +36 -36
  114. data/examples/temp_sensor/test/TestUsartModel.c +40 -40
  115. data/examples/temp_sensor/test/support/UnityHelper.c +12 -12
  116. data/examples/temp_sensor/test/support/UnityHelper.h +12 -12
  117. data/lib/ceedling.rb +99 -99
  118. data/lib/ceedling/build_invoker_utils.rb +39 -39
  119. data/lib/ceedling/cacheinator.rb +47 -47
  120. data/lib/ceedling/cacheinator_helper.rb +35 -31
  121. data/lib/ceedling/cmock_builder.rb +15 -15
  122. data/lib/ceedling/configurator.rb +372 -363
  123. data/lib/ceedling/configurator_builder.rb +463 -458
  124. data/lib/ceedling/configurator_plugins.rb +111 -111
  125. data/lib/ceedling/configurator_setup.rb +127 -127
  126. data/lib/ceedling/configurator_validator.rb +193 -193
  127. data/lib/ceedling/constants.rb +99 -97
  128. data/lib/ceedling/defaults.rb +447 -418
  129. data/lib/ceedling/dependinator.rb +97 -98
  130. data/lib/ceedling/erb_wrapper.rb +8 -8
  131. data/lib/ceedling/file_finder.rb +149 -149
  132. data/lib/ceedling/file_finder_helper.rb +56 -54
  133. data/lib/ceedling/file_path_utils.rb +202 -200
  134. data/lib/ceedling/file_system_utils.rb +69 -69
  135. data/lib/ceedling/file_system_wrapper.rb +9 -9
  136. data/lib/ceedling/file_wrapper.rb +83 -83
  137. data/lib/ceedling/flaginator.rb +74 -74
  138. data/lib/ceedling/generator.rb +186 -183
  139. data/lib/ceedling/generator_helper.rb +40 -40
  140. data/lib/ceedling/generator_test_results.rb +100 -100
  141. data/lib/ceedling/generator_test_results_sanity_checker.rb +65 -65
  142. data/lib/ceedling/generator_test_runner.rb +58 -56
  143. data/lib/ceedling/loginator.rb +31 -31
  144. data/lib/ceedling/makefile.rb +46 -46
  145. data/lib/ceedling/objects.yml +311 -310
  146. data/lib/ceedling/par_map.rb +19 -19
  147. data/lib/ceedling/plugin.rb +80 -80
  148. data/lib/ceedling/plugin_builder.rb +52 -52
  149. data/lib/ceedling/plugin_manager.rb +107 -107
  150. data/lib/ceedling/plugin_manager_helper.rb +19 -19
  151. data/lib/ceedling/plugin_reportinator.rb +76 -76
  152. data/lib/ceedling/plugin_reportinator_helper.rb +51 -51
  153. data/lib/ceedling/preprocessinator.rb +47 -42
  154. data/lib/ceedling/preprocessinator_extractor.rb +30 -30
  155. data/lib/ceedling/preprocessinator_file_handler.rb +21 -21
  156. data/lib/ceedling/preprocessinator_helper.rb +50 -46
  157. data/lib/ceedling/preprocessinator_includes_handler.rb +181 -181
  158. data/lib/ceedling/project_config_manager.rb +52 -46
  159. data/lib/ceedling/project_file_loader.rb +99 -99
  160. data/lib/ceedling/rake_utils.rb +17 -17
  161. data/lib/ceedling/rake_wrapper.rb +33 -33
  162. data/lib/ceedling/rakefile.rb +86 -86
  163. data/lib/ceedling/release_invoker.rb +98 -73
  164. data/lib/ceedling/release_invoker_helper.rb +19 -19
  165. data/lib/ceedling/reportinator.rb +26 -26
  166. data/lib/ceedling/rules_cmock.rake +9 -9
  167. data/lib/ceedling/rules_preprocess.rake +26 -26
  168. data/lib/ceedling/rules_release.rake +99 -86
  169. data/lib/ceedling/rules_release_deep_dependencies.rake +15 -15
  170. data/lib/ceedling/rules_tests.rake +73 -74
  171. data/lib/ceedling/rules_tests_deep_dependencies.rake +15 -15
  172. data/lib/ceedling/setupinator.rb +53 -53
  173. data/lib/ceedling/stream_wrapper.rb +28 -28
  174. data/lib/ceedling/streaminator.rb +40 -40
  175. data/lib/ceedling/streaminator_helper.rb +15 -15
  176. data/lib/ceedling/system_utils.rb +37 -37
  177. data/lib/ceedling/system_wrapper.rb +80 -80
  178. data/lib/ceedling/target_loader.rb +38 -38
  179. data/lib/ceedling/task_invoker.rb +122 -117
  180. data/lib/ceedling/tasks_base.rake +116 -105
  181. data/lib/ceedling/tasks_filesystem.rake +113 -112
  182. data/lib/ceedling/tasks_release.rake +30 -30
  183. data/lib/ceedling/tasks_release_deep_dependencies.rake +9 -9
  184. data/lib/ceedling/tasks_tests.rake +60 -60
  185. data/lib/ceedling/tasks_tests_deep_dependencies.rake +9 -9
  186. data/lib/ceedling/tasks_vendor.rake +35 -35
  187. data/lib/ceedling/test_includes_extractor.rb +111 -85
  188. data/lib/ceedling/test_invoker.rb +164 -188
  189. data/lib/ceedling/test_invoker_helper.rb +32 -32
  190. data/lib/ceedling/tool_executor.rb +229 -229
  191. data/lib/ceedling/tool_executor_helper.rb +164 -164
  192. data/lib/ceedling/verbosinator.rb +10 -10
  193. data/lib/ceedling/version.rb +50 -50
  194. data/lib/ceedling/yaml_wrapper.rb +17 -17
  195. data/license.txt +31 -31
  196. data/plugins/beep/README.md +22 -22
  197. data/plugins/beep/lib/beep.rb +40 -40
  198. data/plugins/bullseye/README.md +76 -0
  199. data/plugins/bullseye/assets/template.erb +15 -15
  200. data/plugins/bullseye/bullseye.rake +173 -169
  201. data/plugins/bullseye/config/defaults.yml +57 -57
  202. data/plugins/bullseye/lib/bullseye.rb +194 -194
  203. data/plugins/colour_report/README.md +20 -0
  204. data/plugins/colour_report/lib/colour_report.rb +16 -16
  205. data/plugins/command_hooks/README.md +53 -53
  206. data/plugins/command_hooks/lib/command_hooks.rb +92 -92
  207. data/plugins/compile_commands_json/README.md +29 -0
  208. data/plugins/compile_commands_json/lib/compile_commands_json.rb +35 -0
  209. data/plugins/dependencies/README.md +254 -0
  210. data/plugins/dependencies/config/defaults.yml +5 -0
  211. data/plugins/dependencies/dependencies.rake +144 -0
  212. data/plugins/dependencies/lib/dependencies.rb +231 -0
  213. data/plugins/fake_function_framework/README.md +250 -250
  214. data/plugins/fake_function_framework/Rakefile +18 -18
  215. data/plugins/fake_function_framework/examples/fff_example/project.yml +71 -71
  216. data/plugins/fake_function_framework/examples/fff_example/rakefile.rb +7 -7
  217. data/plugins/fake_function_framework/examples/fff_example/src/bar.c +1 -1
  218. data/plugins/fake_function_framework/examples/fff_example/src/bar.h +14 -14
  219. data/plugins/fake_function_framework/examples/fff_example/src/custom_types.h +6 -6
  220. data/plugins/fake_function_framework/examples/fff_example/src/display.c +6 -6
  221. data/plugins/fake_function_framework/examples/fff_example/src/display.h +16 -16
  222. data/plugins/fake_function_framework/examples/fff_example/src/event_processor.c +93 -93
  223. data/plugins/fake_function_framework/examples/fff_example/src/event_processor.h +11 -11
  224. data/plugins/fake_function_framework/examples/fff_example/src/foo.c +16 -16
  225. data/plugins/fake_function_framework/examples/fff_example/src/foo.h +8 -8
  226. data/plugins/fake_function_framework/examples/fff_example/src/subfolder/zzz.c +1 -1
  227. data/plugins/fake_function_framework/examples/fff_example/src/subfolder/zzz.h +6 -6
  228. data/plugins/fake_function_framework/examples/fff_example/test/test_event_processor.c +155 -155
  229. data/plugins/fake_function_framework/examples/fff_example/test/test_foo.c +47 -47
  230. data/plugins/fake_function_framework/lib/fake_function_framework.rb +87 -87
  231. data/plugins/fake_function_framework/lib/fff_mock_generator.rb +163 -163
  232. data/plugins/fake_function_framework/spec/fff_mock_header_generator_spec.rb +304 -304
  233. data/plugins/fake_function_framework/spec/fff_mock_source_generator_spec.rb +148 -148
  234. data/plugins/fake_function_framework/spec/header_generator.rb +50 -50
  235. data/plugins/fake_function_framework/spec/spec_helper.rb +96 -96
  236. data/plugins/fake_function_framework/src/fff_unity_helper.h +32 -32
  237. data/plugins/gcov/README.md +412 -101
  238. data/plugins/gcov/assets/template.erb +15 -15
  239. data/plugins/gcov/config/defaults.yml +51 -73
  240. data/plugins/gcov/gcov.rake +209 -220
  241. data/plugins/gcov/lib/gcov.rb +133 -113
  242. data/plugins/gcov/lib/gcov_constants.rb +48 -19
  243. data/plugins/gcov/lib/gcovr_reportinator.rb +331 -0
  244. data/plugins/gcov/lib/reportgenerator_reportinator.rb +153 -0
  245. data/plugins/gcov/lib/reportinator_helper.rb +15 -0
  246. data/plugins/json_tests_report/README.md +36 -0
  247. data/plugins/json_tests_report/lib/json_tests_report.rb +83 -0
  248. data/plugins/junit_tests_report/README.md +36 -36
  249. data/plugins/junit_tests_report/lib/junit_tests_report.rb +134 -130
  250. data/plugins/module_generator/README.md +105 -0
  251. data/plugins/module_generator/config/module_generator.yml +3 -3
  252. data/plugins/module_generator/lib/module_generator.rb +79 -70
  253. data/plugins/module_generator/module_generator.rake +62 -47
  254. data/plugins/raw_output_report/README.md +19 -0
  255. data/plugins/raw_output_report/lib/raw_output_report.rb +41 -41
  256. data/plugins/stdout_gtestlike_tests_report/README.md +19 -0
  257. data/plugins/stdout_gtestlike_tests_report/assets/template.erb +84 -84
  258. data/plugins/stdout_gtestlike_tests_report/assets/template.erb copy +59 -59
  259. data/plugins/stdout_gtestlike_tests_report/config/stdout_gtestlike_tests_report.yml +4 -4
  260. data/plugins/stdout_gtestlike_tests_report/lib/stdout_gtestlike_tests_report.rb +43 -43
  261. data/plugins/stdout_ide_tests_report/README.md +18 -0
  262. data/plugins/stdout_ide_tests_report/config/stdout_ide_tests_report.yml +4 -4
  263. data/plugins/stdout_ide_tests_report/lib/stdout_ide_tests_report.rb +44 -44
  264. data/plugins/stdout_pretty_tests_report/README.md +20 -0
  265. data/plugins/stdout_pretty_tests_report/assets/template.erb +59 -59
  266. data/plugins/stdout_pretty_tests_report/config/stdout_pretty_tests_report.yml +4 -4
  267. data/plugins/stdout_pretty_tests_report/lib/stdout_pretty_tests_report.rb +47 -47
  268. data/plugins/subprojects/README.md +63 -63
  269. data/plugins/subprojects/config/defaults.yml +33 -33
  270. data/plugins/subprojects/lib/subprojects.rb +92 -92
  271. data/plugins/subprojects/subprojects.rake +78 -78
  272. data/plugins/teamcity_tests_report/README.md +18 -0
  273. data/plugins/teamcity_tests_report/config/teamcity_tests_report.yml +4 -4
  274. data/plugins/teamcity_tests_report/lib/teamcity_tests_report.rb +57 -57
  275. data/plugins/warnings_report/README.md +19 -0
  276. data/plugins/warnings_report/lib/warnings_report.rb +69 -69
  277. data/plugins/xml_tests_report/README.md +36 -36
  278. data/plugins/xml_tests_report/lib/xml_tests_report.rb +110 -110
  279. data/spec/build_invoker_utils_spec.rb +54 -54
  280. data/spec/ceedling_spec.rb +154 -154
  281. data/spec/configurator_builder_spec.rb +6 -6
  282. data/spec/configurator_helper_spec.rb +4 -4
  283. data/spec/configurator_spec.rb +9 -9
  284. data/spec/file_finder_helper_spec.rb +53 -53
  285. data/spec/gcov/gcov_deployment_spec.rb +72 -70
  286. data/spec/gcov/gcov_test_cases_spec.rb +128 -91
  287. data/spec/generator_test_results_sanity_checker_spec.rb +88 -88
  288. data/spec/generator_test_results_spec.rb +107 -107
  289. data/spec/par_map_spec.rb +57 -57
  290. data/spec/preprocessinator_extractor_spec.rb +45 -45
  291. data/spec/preprocessinator_includes_handler_spec.rb +202 -202
  292. data/spec/reportinator_spec.rb +19 -19
  293. data/spec/spec_helper.rb +27 -27
  294. data/spec/spec_system_helper.rb +616 -615
  295. data/spec/support/test_example.fail +24 -24
  296. data/spec/support/test_example.pass +24 -24
  297. data/spec/support/test_example_empty.pass +14 -14
  298. data/spec/support/test_example_ignore.pass +24 -24
  299. data/spec/support/test_example_mangled.pass +21 -21
  300. data/spec/support/test_example_with_time.pass +24 -24
  301. data/spec/system/deployment_spec.rb +225 -225
  302. data/spec/system_utils_spec.rb +56 -56
  303. data/spec/target_loader_spec.rb +30 -30
  304. data/spec/tool_executor_helper_spec.rb +310 -310
  305. data/spec/uncatagorized_specs_spec.rb +8 -8
  306. data/vendor/behaviors/Manifest.txt +9 -9
  307. data/vendor/behaviors/Rakefile +19 -19
  308. data/vendor/behaviors/lib/behaviors.rb +76 -76
  309. data/vendor/behaviors/lib/behaviors/reporttask.rb +158 -158
  310. data/vendor/behaviors/test/behaviors_tasks_test.rb +73 -73
  311. data/vendor/behaviors/test/behaviors_test.rb +50 -50
  312. data/vendor/behaviors/test/tasks_test/Rakefile +19 -19
  313. data/vendor/behaviors/test/tasks_test/lib/user.rb +2 -2
  314. data/vendor/behaviors/test/tasks_test/test/user_test.rb +17 -17
  315. data/vendor/c_exception/Gemfile +4 -4
  316. data/vendor/c_exception/Gemfile.lock +12 -12
  317. data/vendor/c_exception/README.md +249 -162
  318. data/vendor/c_exception/docs/CException.md +332 -292
  319. data/vendor/c_exception/docs/ThrowTheSwitchCodingStandard.md +207 -207
  320. data/vendor/c_exception/lib/CException.c +46 -46
  321. data/vendor/c_exception/lib/CException.h +115 -115
  322. data/vendor/c_exception/lib/meson.build +11 -0
  323. data/vendor/c_exception/meson.build +48 -0
  324. data/vendor/c_exception/project.yml +37 -0
  325. data/vendor/c_exception/test/TestException.c +391 -391
  326. data/vendor/{cmock/vendor/c_exception/test → c_exception/test/support}/CExceptionConfig.h +46 -46
  327. data/vendor/c_exception/vendor/unity/README.md +220 -220
  328. data/vendor/c_exception/vendor/unity/auto/colour_prompt.rb +118 -118
  329. data/vendor/c_exception/vendor/unity/auto/colour_reporter.rb +39 -39
  330. data/vendor/c_exception/vendor/unity/auto/generate_config.yml +36 -36
  331. data/vendor/c_exception/vendor/unity/auto/generate_module.rb +308 -308
  332. data/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +437 -437
  333. data/vendor/c_exception/vendor/unity/auto/parse_output.rb +220 -220
  334. data/vendor/c_exception/vendor/unity/auto/stylize_as_junit.rb +252 -252
  335. data/vendor/c_exception/vendor/unity/auto/test_file_filter.rb +25 -25
  336. data/vendor/c_exception/vendor/unity/auto/type_sanitizer.rb +6 -6
  337. data/vendor/c_exception/vendor/unity/auto/unity_test_summary.py +139 -139
  338. data/vendor/c_exception/vendor/unity/auto/unity_test_summary.rb +136 -136
  339. data/vendor/c_exception/vendor/unity/auto/unity_to_junit.py +146 -146
  340. data/vendor/c_exception/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +207 -207
  341. data/vendor/c_exception/vendor/unity/docs/UnityAssertionsReference.md +716 -716
  342. data/vendor/c_exception/vendor/unity/docs/UnityConfigurationGuide.md +398 -398
  343. data/vendor/c_exception/vendor/unity/docs/UnityGettingStartedGuide.md +191 -191
  344. data/vendor/c_exception/vendor/unity/docs/UnityHelperScriptsGuide.md +242 -242
  345. data/vendor/c_exception/vendor/unity/docs/license.txt +21 -21
  346. data/vendor/c_exception/vendor/unity/examples/example_1/makefile +71 -71
  347. data/vendor/c_exception/vendor/unity/examples/example_1/readme.txt +4 -4
  348. data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode.c +24 -24
  349. data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode.h +3 -3
  350. data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.c +11 -11
  351. data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.h +2 -2
  352. data/vendor/c_exception/vendor/unity/examples/example_1/test/TestProductionCode.c +62 -62
  353. data/vendor/c_exception/vendor/unity/examples/example_1/test/TestProductionCode2.c +31 -31
  354. data/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -53
  355. data/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -57
  356. data/vendor/c_exception/vendor/unity/examples/example_2/makefile +70 -70
  357. data/vendor/c_exception/vendor/unity/examples/example_2/readme.txt +4 -4
  358. data/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode.c +24 -24
  359. data/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode.h +3 -3
  360. data/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode2.c +11 -11
  361. data/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode2.h +2 -2
  362. data/vendor/c_exception/vendor/unity/examples/example_2/test/TestProductionCode.c +64 -64
  363. data/vendor/c_exception/vendor/unity/examples/example_2/test/TestProductionCode2.c +33 -33
  364. data/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +8 -8
  365. data/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +10 -10
  366. data/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/all_tests.c +12 -12
  367. data/vendor/c_exception/vendor/unity/examples/example_3/helper/UnityHelper.c +10 -10
  368. data/vendor/c_exception/vendor/unity/examples/example_3/helper/UnityHelper.h +12 -12
  369. data/vendor/c_exception/vendor/unity/examples/example_3/rakefile.rb +43 -43
  370. data/vendor/c_exception/vendor/unity/examples/example_3/rakefile_helper.rb +249 -249
  371. data/vendor/c_exception/vendor/unity/examples/example_3/readme.txt +13 -13
  372. data/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode.c +24 -24
  373. data/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode.h +3 -3
  374. data/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode2.c +11 -11
  375. data/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode2.h +2 -2
  376. data/vendor/c_exception/vendor/unity/examples/example_3/target_gcc_32.yml +46 -46
  377. data/vendor/c_exception/vendor/unity/examples/example_3/test/TestProductionCode.c +62 -62
  378. data/vendor/c_exception/vendor/unity/examples/example_3/test/TestProductionCode2.c +31 -31
  379. data/vendor/c_exception/vendor/unity/examples/unity_config.h +237 -237
  380. data/vendor/c_exception/vendor/unity/extras/eclipse/error_parsers.txt +26 -26
  381. data/vendor/c_exception/vendor/unity/extras/fixture/rakefile.rb +48 -48
  382. data/vendor/c_exception/vendor/unity/extras/fixture/rakefile_helper.rb +178 -178
  383. data/vendor/c_exception/vendor/unity/extras/fixture/readme.txt +8 -8
  384. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +432 -432
  385. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +83 -83
  386. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +51 -51
  387. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +47 -47
  388. data/vendor/c_exception/vendor/unity/extras/fixture/test/Makefile +74 -74
  389. data/vendor/c_exception/vendor/unity/extras/fixture/test/main/AllTests.c +22 -22
  390. data/vendor/c_exception/vendor/unity/extras/fixture/test/template_fixture_tests.c +39 -39
  391. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +543 -543
  392. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +57 -57
  393. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +57 -57
  394. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +17 -17
  395. data/vendor/c_exception/vendor/unity/release/build.info +2 -2
  396. data/vendor/c_exception/vendor/unity/release/version.info +2 -2
  397. data/vendor/c_exception/vendor/unity/src/unity.c +1517 -1517
  398. data/vendor/c_exception/vendor/unity/src/unity.h +339 -339
  399. data/vendor/c_exception/vendor/unity/src/unity_internals.h +784 -784
  400. data/vendor/c_exception/vendor/unity/test/Makefile +63 -63
  401. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_cmd.c +61 -61
  402. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_def.c +57 -57
  403. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.c +55 -55
  404. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.h +15 -15
  405. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_cmd.c +80 -80
  406. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_def.c +76 -76
  407. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.c +75 -75
  408. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.h +13 -13
  409. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new1.c +89 -89
  410. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new2.c +89 -89
  411. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_param.c +77 -77
  412. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run1.c +89 -89
  413. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run2.c +89 -89
  414. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_yaml.c +90 -90
  415. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_new1.c +67 -67
  416. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_new2.c +70 -70
  417. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_param.c +58 -58
  418. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_run1.c +67 -67
  419. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_run2.c +70 -70
  420. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_yaml.c +71 -71
  421. data/vendor/c_exception/vendor/unity/test/rakefile +125 -125
  422. data/vendor/c_exception/vendor/unity/test/rakefile_helper.rb +260 -260
  423. data/vendor/c_exception/vendor/unity/test/spec/generate_module_existing_file_spec.rb +158 -158
  424. data/vendor/c_exception/vendor/unity/test/targets/clang_file.yml +78 -78
  425. data/vendor/c_exception/vendor/unity/test/targets/clang_strict.yml +78 -78
  426. data/vendor/c_exception/vendor/unity/test/targets/gcc_32.yml +49 -49
  427. data/vendor/c_exception/vendor/unity/test/targets/gcc_64.yml +50 -50
  428. data/vendor/c_exception/vendor/unity/test/targets/gcc_auto_limits.yml +47 -47
  429. data/vendor/c_exception/vendor/unity/test/targets/gcc_auto_stdint.yml +59 -59
  430. data/vendor/c_exception/vendor/unity/test/targets/gcc_manual_math.yml +47 -47
  431. data/vendor/c_exception/vendor/unity/test/targets/hitech_picc18.yml +101 -101
  432. data/vendor/c_exception/vendor/unity/test/targets/iar_arm_v4.yml +90 -90
  433. data/vendor/c_exception/vendor/unity/test/targets/iar_arm_v5.yml +80 -80
  434. data/vendor/c_exception/vendor/unity/test/targets/iar_arm_v5_3.yml +80 -80
  435. data/vendor/c_exception/vendor/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +94 -94
  436. data/vendor/c_exception/vendor/unity/test/targets/iar_cortexm3_v5.yml +84 -84
  437. data/vendor/c_exception/vendor/unity/test/targets/iar_msp430.yml +95 -95
  438. data/vendor/c_exception/vendor/unity/test/targets/iar_sh2a_v6.yml +86 -86
  439. data/vendor/c_exception/vendor/unity/test/testdata/CException.h +11 -11
  440. data/vendor/c_exception/vendor/unity/test/testdata/Defs.h +8 -8
  441. data/vendor/c_exception/vendor/unity/test/testdata/cmock.h +14 -14
  442. data/vendor/c_exception/vendor/unity/test/testdata/mockMock.h +13 -13
  443. data/vendor/c_exception/vendor/unity/test/testdata/testRunnerGenerator.c +183 -183
  444. data/vendor/c_exception/vendor/unity/test/testdata/testRunnerGeneratorSmall.c +67 -67
  445. data/vendor/c_exception/vendor/unity/test/testdata/testRunnerGeneratorWithMocks.c +192 -192
  446. data/vendor/c_exception/vendor/unity/test/tests/test_generate_test_runner.rb +1252 -1252
  447. data/vendor/c_exception/vendor/unity/test/tests/testparameterized.c +110 -110
  448. data/vendor/c_exception/vendor/unity/test/tests/testunity.c +4993 -4993
  449. data/vendor/cmock/Gemfile +8 -9
  450. data/vendor/cmock/LICENSE.txt +18 -18
  451. data/vendor/cmock/README.md +34 -34
  452. data/vendor/cmock/config/production_environment.rb +12 -14
  453. data/vendor/cmock/config/test_environment.rb +16 -16
  454. data/vendor/cmock/docs/CMock_Summary.md +806 -696
  455. data/vendor/cmock/docs/ThrowTheSwitchCodingStandard.md +207 -207
  456. data/vendor/cmock/examples/make_example/Makefile +30 -30
  457. data/vendor/cmock/examples/make_example/src/foo.c +5 -5
  458. data/vendor/cmock/examples/make_example/src/foo.h +5 -5
  459. data/vendor/cmock/examples/make_example/src/main.c +15 -15
  460. data/vendor/cmock/examples/make_example/test/test_foo.c +17 -17
  461. data/vendor/cmock/examples/make_example/test/test_main.c +15 -15
  462. data/vendor/cmock/examples/temp_sensor/gcc.yml +44 -44
  463. data/vendor/cmock/examples/temp_sensor/iar_v4.yml +92 -92
  464. data/vendor/cmock/examples/temp_sensor/iar_v5.yml +81 -81
  465. data/vendor/cmock/examples/temp_sensor/rakefile.rb +42 -42
  466. data/vendor/cmock/examples/temp_sensor/rakefile_helper.rb +268 -272
  467. data/vendor/cmock/examples/temp_sensor/src/AT91SAM7X256.h +2556 -2556
  468. data/vendor/cmock/examples/temp_sensor/src/AdcConductor.c +42 -42
  469. data/vendor/cmock/examples/temp_sensor/src/AdcConductor.h +11 -11
  470. data/vendor/cmock/examples/temp_sensor/src/AdcHardware.c +27 -27
  471. data/vendor/cmock/examples/temp_sensor/src/AdcHardware.h +9 -9
  472. data/vendor/cmock/examples/temp_sensor/src/AdcHardwareConfigurator.c +18 -18
  473. data/vendor/cmock/examples/temp_sensor/src/AdcHardwareConfigurator.h +10 -10
  474. data/vendor/cmock/examples/temp_sensor/src/AdcModel.c +33 -33
  475. data/vendor/cmock/examples/temp_sensor/src/AdcModel.h +13 -13
  476. data/vendor/cmock/examples/temp_sensor/src/AdcTemperatureSensor.c +51 -51
  477. data/vendor/cmock/examples/temp_sensor/src/AdcTemperatureSensor.h +10 -10
  478. data/vendor/cmock/examples/temp_sensor/src/Executor.c +25 -25
  479. data/vendor/cmock/examples/temp_sensor/src/Executor.h +9 -9
  480. data/vendor/cmock/examples/temp_sensor/src/IntrinsicsWrapper.c +18 -18
  481. data/vendor/cmock/examples/temp_sensor/src/IntrinsicsWrapper.h +7 -7
  482. data/vendor/cmock/examples/temp_sensor/src/Main.c +46 -46
  483. data/vendor/cmock/examples/temp_sensor/src/Main.h +7 -7
  484. data/vendor/cmock/examples/temp_sensor/src/Model.c +10 -10
  485. data/vendor/cmock/examples/temp_sensor/src/Model.h +8 -8
  486. data/vendor/cmock/examples/temp_sensor/src/ModelConfig.h +7 -7
  487. data/vendor/cmock/examples/temp_sensor/src/TaskScheduler.c +72 -72
  488. data/vendor/cmock/examples/temp_sensor/src/TaskScheduler.h +11 -11
  489. data/vendor/cmock/examples/temp_sensor/src/TemperatureCalculator.c +27 -27
  490. data/vendor/cmock/examples/temp_sensor/src/TemperatureCalculator.h +6 -6
  491. data/vendor/cmock/examples/temp_sensor/src/TemperatureFilter.c +39 -39
  492. data/vendor/cmock/examples/temp_sensor/src/TemperatureFilter.h +10 -10
  493. data/vendor/cmock/examples/temp_sensor/src/TimerConductor.c +15 -15
  494. data/vendor/cmock/examples/temp_sensor/src/TimerConductor.h +9 -9
  495. data/vendor/cmock/examples/temp_sensor/src/TimerConfigurator.c +51 -51
  496. data/vendor/cmock/examples/temp_sensor/src/TimerConfigurator.h +15 -15
  497. data/vendor/cmock/examples/temp_sensor/src/TimerHardware.c +15 -15
  498. data/vendor/cmock/examples/temp_sensor/src/TimerHardware.h +8 -8
  499. data/vendor/cmock/examples/temp_sensor/src/TimerInterruptConfigurator.c +55 -55
  500. data/vendor/cmock/examples/temp_sensor/src/TimerInterruptConfigurator.h +13 -13
  501. data/vendor/cmock/examples/temp_sensor/src/TimerInterruptHandler.c +25 -25
  502. data/vendor/cmock/examples/temp_sensor/src/TimerInterruptHandler.h +10 -10
  503. data/vendor/cmock/examples/temp_sensor/src/TimerModel.c +9 -9
  504. data/vendor/cmock/examples/temp_sensor/src/TimerModel.h +8 -8
  505. data/vendor/cmock/examples/temp_sensor/src/Types.h +103 -103
  506. data/vendor/cmock/examples/temp_sensor/src/UsartBaudRateRegisterCalculator.c +18 -18
  507. data/vendor/cmock/examples/temp_sensor/src/UsartBaudRateRegisterCalculator.h +6 -6
  508. data/vendor/cmock/examples/temp_sensor/src/UsartConductor.c +21 -21
  509. data/vendor/cmock/examples/temp_sensor/src/UsartConductor.h +7 -7
  510. data/vendor/cmock/examples/temp_sensor/src/UsartConfigurator.c +39 -39
  511. data/vendor/cmock/examples/temp_sensor/src/UsartConfigurator.h +13 -13
  512. data/vendor/cmock/examples/temp_sensor/src/UsartHardware.c +22 -22
  513. data/vendor/cmock/examples/temp_sensor/src/UsartHardware.h +9 -9
  514. data/vendor/cmock/examples/temp_sensor/src/UsartModel.c +34 -34
  515. data/vendor/cmock/examples/temp_sensor/src/UsartModel.h +10 -10
  516. data/vendor/cmock/examples/temp_sensor/src/UsartPutChar.c +16 -16
  517. data/vendor/cmock/examples/temp_sensor/src/UsartPutChar.h +8 -8
  518. data/vendor/cmock/examples/temp_sensor/src/UsartTransmitBufferStatus.c +7 -7
  519. data/vendor/cmock/examples/temp_sensor/src/UsartTransmitBufferStatus.h +8 -8
  520. data/vendor/cmock/examples/temp_sensor/test/TestAdcConductor.c +121 -121
  521. data/vendor/cmock/examples/temp_sensor/test/TestAdcHardware.c +44 -44
  522. data/vendor/cmock/examples/temp_sensor/test/TestAdcHardwareConfigurator.c +43 -43
  523. data/vendor/cmock/examples/temp_sensor/test/TestAdcModel.c +33 -33
  524. data/vendor/cmock/examples/temp_sensor/test/TestAdcTemperatureSensor.c +47 -47
  525. data/vendor/cmock/examples/temp_sensor/test/TestExecutor.c +36 -36
  526. data/vendor/cmock/examples/temp_sensor/test/TestMain.c +24 -24
  527. data/vendor/cmock/examples/temp_sensor/test/TestModel.c +20 -20
  528. data/vendor/cmock/examples/temp_sensor/test/TestTaskScheduler.c +104 -104
  529. data/vendor/cmock/examples/temp_sensor/test/TestTemperatureCalculator.c +33 -33
  530. data/vendor/cmock/examples/temp_sensor/test/TestTemperatureFilter.c +69 -69
  531. data/vendor/cmock/examples/temp_sensor/test/TestTimerConductor.c +32 -32
  532. data/vendor/cmock/examples/temp_sensor/test/TestTimerConfigurator.c +112 -112
  533. data/vendor/cmock/examples/temp_sensor/test/TestTimerHardware.c +26 -26
  534. data/vendor/cmock/examples/temp_sensor/test/TestTimerInterruptConfigurator.c +78 -78
  535. data/vendor/cmock/examples/temp_sensor/test/TestTimerInterruptHandler.c +66 -66
  536. data/vendor/cmock/examples/temp_sensor/test/TestTimerModel.c +18 -18
  537. data/vendor/cmock/examples/temp_sensor/test/TestUsartBaudRateRegisterCalculator.c +21 -21
  538. data/vendor/cmock/examples/temp_sensor/test/TestUsartConductor.c +40 -40
  539. data/vendor/cmock/examples/temp_sensor/test/TestUsartConfigurator.c +77 -77
  540. data/vendor/cmock/examples/temp_sensor/test/TestUsartHardware.c +37 -37
  541. data/vendor/cmock/examples/temp_sensor/test/TestUsartModel.c +40 -40
  542. data/vendor/cmock/examples/temp_sensor/test/TestUsartPutChar.c +43 -43
  543. data/vendor/cmock/examples/temp_sensor/test/TestUsartTransmitBufferStatus.c +22 -22
  544. data/vendor/cmock/lib/cmock.rb +104 -86
  545. data/vendor/cmock/lib/cmock_config.rb +173 -163
  546. data/vendor/cmock/lib/cmock_file_writer.rb +48 -44
  547. data/vendor/cmock/lib/cmock_generator.rb +333 -275
  548. data/vendor/cmock/lib/cmock_generator_plugin_array.rb +63 -63
  549. data/vendor/cmock/lib/cmock_generator_plugin_callback.rb +88 -88
  550. data/vendor/cmock/lib/cmock_generator_plugin_cexception.rb +49 -51
  551. data/vendor/cmock/lib/cmock_generator_plugin_expect.rb +100 -103
  552. data/vendor/cmock/lib/cmock_generator_plugin_expect_any_args.rb +50 -53
  553. data/vendor/cmock/lib/cmock_generator_plugin_ignore.rb +88 -75
  554. data/vendor/cmock/lib/cmock_generator_plugin_ignore_arg.rb +42 -42
  555. data/vendor/cmock/lib/cmock_generator_plugin_return_thru_ptr.rb +79 -79
  556. data/vendor/cmock/lib/cmock_generator_utils.rb +247 -253
  557. data/vendor/cmock/lib/cmock_header_parser.rb +595 -474
  558. data/vendor/cmock/lib/cmock_plugin_manager.rb +50 -55
  559. data/vendor/cmock/lib/cmock_unityhelper_parser.rb +77 -75
  560. data/vendor/cmock/meson.build +53 -72
  561. data/vendor/cmock/scripts/create_makefile.rb +203 -202
  562. data/vendor/cmock/scripts/create_mock.rb +8 -8
  563. data/vendor/cmock/scripts/create_runner.rb +18 -20
  564. data/vendor/cmock/scripts/test_summary.rb +18 -19
  565. data/vendor/cmock/src/cmock.c +216 -216
  566. data/vendor/cmock/src/cmock.h +41 -40
  567. data/vendor/cmock/src/cmock_internals.h +91 -91
  568. data/vendor/cmock/src/meson.build +12 -17
  569. data/vendor/cmock/test/c/TestCMockC.c +333 -333
  570. data/vendor/cmock/test/c/TestCMockC.yml +14 -14
  571. data/vendor/cmock/test/c/TestCMockCDynamic.c +186 -186
  572. data/vendor/cmock/test/c/TestCMockCDynamic.yml +12 -12
  573. data/vendor/cmock/test/c/TestCMockCDynamic_Runner.c +36 -36
  574. data/vendor/cmock/test/c/TestCMockC_Runner.c +41 -41
  575. data/vendor/cmock/test/iar/iar_v4/Resource/at91SAM7X256_FLASH.xcl +185 -185
  576. data/vendor/cmock/test/iar/iar_v4/Resource/at91SAM7X256_RAM.xcl +185 -185
  577. data/vendor/cmock/test/iar/iar_v4/Resource/ioat91sam7x256.ddf +2259 -2259
  578. data/vendor/cmock/test/iar/iar_v4/cmock_demo.dep +3691 -3691
  579. data/vendor/cmock/test/iar/iar_v4/cmock_demo.ewp +2581 -2581
  580. data/vendor/cmock/test/iar/iar_v4/incIAR/AT91SAM7X-EK.h +61 -61
  581. data/vendor/cmock/test/iar/iar_v4/incIAR/AT91SAM7X256.inc +2314 -2314
  582. data/vendor/cmock/test/iar/iar_v4/incIAR/AT91SAM7X256.rdf +4704 -4704
  583. data/vendor/cmock/test/iar/iar_v4/incIAR/AT91SAM7X256.tcl +3407 -3407
  584. data/vendor/cmock/test/iar/iar_v4/incIAR/AT91SAM7X256_inc.h +2268 -2268
  585. data/vendor/cmock/test/iar/iar_v4/incIAR/ioat91sam7x256.h +4380 -4380
  586. data/vendor/cmock/test/iar/iar_v4/incIAR/lib_AT91SAM7X256.h +4211 -4211
  587. data/vendor/cmock/test/iar/iar_v4/settings/cmock_demo.cspy.bat +32 -32
  588. data/vendor/cmock/test/iar/iar_v4/srcIAR/Cstartup.s79 +265 -265
  589. data/vendor/cmock/test/iar/iar_v4/srcIAR/Cstartup_SAM7.c +98 -98
  590. data/vendor/cmock/test/iar/iar_v5/Resource/at91SAM7X256_FLASH.icf +43 -43
  591. data/vendor/cmock/test/iar/iar_v5/Resource/at91SAM7X256_RAM.icf +42 -42
  592. data/vendor/cmock/test/iar/iar_v5/cmock_demo.dep +4204 -4204
  593. data/vendor/cmock/test/iar/iar_v5/cmock_demo.ewp +2426 -2426
  594. data/vendor/cmock/test/iar/iar_v5/incIAR/AT91SAM7X-EK.h +61 -61
  595. data/vendor/cmock/test/iar/iar_v5/incIAR/AT91SAM7X256_inc.h +2268 -2268
  596. data/vendor/cmock/test/iar/iar_v5/incIAR/lib_AT91SAM7X256.h +4211 -4211
  597. data/vendor/cmock/test/iar/iar_v5/incIAR/project.h +30 -30
  598. data/vendor/cmock/test/iar/iar_v5/settings/BasicInterrupt_SAM7X.cspy.bat +33 -33
  599. data/vendor/cmock/test/iar/iar_v5/settings/BasicInterrupt_SAM7X_FLASH_Debug.jlink +12 -12
  600. data/vendor/cmock/test/iar/iar_v5/settings/cmock_demo.cspy.bat +33 -33
  601. data/vendor/cmock/test/iar/iar_v5/settings/cmock_demo_Binary.jlink +12 -12
  602. data/vendor/cmock/test/iar/iar_v5/settings/cmock_demo_FLASH_Debug.jlink +12 -12
  603. data/vendor/cmock/test/iar/iar_v5/settings/cmock_demo_RAM_Debug.jlink +12 -12
  604. data/vendor/cmock/test/iar/iar_v5/srcIAR/Cstartup.s +299 -299
  605. data/vendor/cmock/test/iar/iar_v5/srcIAR/Cstartup_SAM7.c +98 -98
  606. data/vendor/cmock/test/rakefile +147 -106
  607. data/vendor/cmock/test/rakefile_helper.rb +403 -382
  608. data/vendor/cmock/test/system/systest_generator.rb +205 -193
  609. data/vendor/cmock/test/system/test_compilation/callingconv.h +11 -11
  610. data/vendor/cmock/test/system/test_compilation/config.yml +10 -10
  611. data/vendor/cmock/test/system/test_compilation/const.h +37 -37
  612. data/vendor/cmock/test/system/test_compilation/inline.h +23 -23
  613. data/vendor/cmock/test/system/test_compilation/osek.h +275 -275
  614. data/vendor/cmock/test/system/test_compilation/parsing.h +89 -89
  615. data/vendor/cmock/test/system/test_interactions/all_plugins_but_other_limits.yml +375 -375
  616. data/vendor/cmock/test/system/test_interactions/all_plugins_coexist.yml +460 -460
  617. data/vendor/cmock/test/system/test_interactions/array_and_pointer_handling.yml +446 -446
  618. data/vendor/cmock/test/system/test_interactions/basic_expect_and_return.yml +124 -124
  619. data/vendor/cmock/test/system/test_interactions/const_primitives_handling.yml +87 -87
  620. data/vendor/cmock/test/system/test_interactions/doesnt_leave_details_behind.yml +308 -308
  621. data/vendor/cmock/test/system/test_interactions/enforce_strict_ordering.yml +247 -247
  622. data/vendor/cmock/test/system/test_interactions/expect_and_return_custom_types.yml +108 -108
  623. data/vendor/cmock/test/system/test_interactions/expect_and_return_treat_as.yml +173 -173
  624. data/vendor/cmock/test/system/test_interactions/expect_and_throw.yml +170 -170
  625. data/vendor/cmock/test/system/test_interactions/expect_any_args.yml +238 -238
  626. data/vendor/cmock/test/system/test_interactions/fancy_pointer_handling.yml +210 -210
  627. data/vendor/cmock/test/system/test_interactions/function_pointer_handling.yml +83 -82
  628. data/vendor/cmock/test/system/test_interactions/ignore_and_return.yml +329 -329
  629. data/vendor/cmock/test/system/test_interactions/ignore_strict_mock_calling.yml +37 -37
  630. data/vendor/cmock/test/system/test_interactions/newer_standards_stuff1.yml +52 -52
  631. data/vendor/cmock/test/system/test_interactions/nonstandard_parsed_stuff_1.yml +91 -91
  632. data/vendor/cmock/test/system/test_interactions/nonstandard_parsed_stuff_2.yml +59 -59
  633. data/vendor/cmock/test/system/test_interactions/out_of_memory.yml +65 -65
  634. data/vendor/cmock/test/system/test_interactions/parsing_challenges.yml +242 -242
  635. data/vendor/cmock/test/system/test_interactions/return_thru_ptr_and_expect_any_args.yml +235 -235
  636. data/vendor/cmock/test/system/test_interactions/return_thru_ptr_ignore_arg.yml +231 -231
  637. data/vendor/cmock/test/system/test_interactions/skeleton.yml +55 -0
  638. data/vendor/cmock/test/system/test_interactions/skeleton_update.yml +76 -0
  639. data/vendor/cmock/test/system/test_interactions/struct_union_enum_expect_and_return.yml +277 -277
  640. data/vendor/cmock/test/system/test_interactions/struct_union_enum_expect_and_return_with_plugins.yml +280 -280
  641. data/vendor/cmock/test/system/test_interactions/stubs_with_callbacks.yml +221 -221
  642. data/vendor/cmock/test/system/test_interactions/unity_64bit_support.yml +77 -77
  643. data/vendor/cmock/test/system/test_interactions/unity_ignores.yml +139 -139
  644. data/vendor/cmock/test/system/test_interactions/unity_void_pointer_compare.yml +91 -91
  645. data/vendor/cmock/test/targets/clang_strict.yml +90 -90
  646. data/vendor/cmock/test/targets/gcc.yml +58 -58
  647. data/vendor/cmock/test/targets/gcc_64.yml +58 -58
  648. data/vendor/cmock/test/targets/gcc_tiny.yml +80 -80
  649. data/vendor/cmock/test/targets/iar_arm_v4.yml +110 -110
  650. data/vendor/cmock/test/targets/iar_arm_v5.yml +95 -95
  651. data/vendor/cmock/test/test_helper.rb +44 -44
  652. data/vendor/cmock/test/unit/cmock_config_test.rb +126 -123
  653. data/vendor/cmock/test/unit/cmock_config_test.yml +7 -6
  654. data/vendor/cmock/test/unit/cmock_file_writer_test.rb +27 -27
  655. data/vendor/cmock/test/unit/cmock_generator_main_test.rb +686 -551
  656. data/vendor/cmock/test/unit/cmock_generator_plugin_array_test.rb +141 -141
  657. data/vendor/cmock/test/unit/cmock_generator_plugin_callback_test.rb +281 -281
  658. data/vendor/cmock/test/unit/cmock_generator_plugin_cexception_test.rb +96 -96
  659. data/vendor/cmock/test/unit/cmock_generator_plugin_expect_a_test.rb +185 -183
  660. data/vendor/cmock/test/unit/cmock_generator_plugin_expect_any_args_test.rb +67 -67
  661. data/vendor/cmock/test/unit/cmock_generator_plugin_expect_b_test.rb +201 -200
  662. data/vendor/cmock/test/unit/cmock_generator_plugin_ignore_arg_test.rb +116 -116
  663. data/vendor/cmock/test/unit/cmock_generator_plugin_ignore_test.rb +119 -105
  664. data/vendor/cmock/test/unit/cmock_generator_plugin_return_thru_ptr_test.rb +136 -136
  665. data/vendor/cmock/test/unit/cmock_generator_utils_test.rb +398 -415
  666. data/vendor/cmock/test/unit/cmock_header_parser_test.rb +2717 -2000
  667. data/vendor/cmock/test/unit/cmock_plugin_manager_test.rb +100 -100
  668. data/vendor/cmock/test/unit/cmock_unityhelper_parser_test.rb +223 -223
  669. data/vendor/cmock/vendor/behaviors/Manifest.txt +9 -9
  670. data/vendor/cmock/vendor/behaviors/Rakefile +19 -19
  671. data/vendor/cmock/vendor/behaviors/lib/behaviors.rb +76 -76
  672. data/vendor/cmock/vendor/behaviors/lib/behaviors/reporttask.rb +158 -158
  673. data/vendor/cmock/vendor/behaviors/test/behaviors_tasks_test.rb +73 -73
  674. data/vendor/cmock/vendor/behaviors/test/behaviors_test.rb +50 -50
  675. data/vendor/cmock/vendor/behaviors/test/tasks_test/Rakefile +19 -19
  676. data/vendor/cmock/vendor/behaviors/test/tasks_test/lib/user.rb +2 -2
  677. data/vendor/cmock/vendor/behaviors/test/tasks_test/test/user_test.rb +17 -17
  678. data/vendor/cmock/vendor/c_exception/Gemfile +4 -4
  679. data/vendor/cmock/vendor/c_exception/Gemfile.lock +12 -12
  680. data/vendor/cmock/vendor/c_exception/README.md +249 -162
  681. data/vendor/cmock/vendor/c_exception/docs/CException.md +332 -292
  682. data/vendor/cmock/vendor/c_exception/docs/ThrowTheSwitchCodingStandard.md +207 -207
  683. data/vendor/cmock/vendor/c_exception/lib/CException.c +46 -46
  684. data/vendor/cmock/vendor/c_exception/lib/CException.h +115 -115
  685. data/vendor/cmock/vendor/c_exception/lib/meson.build +11 -0
  686. data/vendor/cmock/vendor/c_exception/meson.build +48 -0
  687. data/vendor/cmock/vendor/c_exception/project.yml +37 -0
  688. data/vendor/cmock/vendor/c_exception/test/TestException.c +391 -391
  689. data/vendor/{c_exception/test → cmock/vendor/c_exception/test/support}/CExceptionConfig.h +46 -46
  690. data/vendor/cmock/vendor/c_exception/vendor/unity/README.md +220 -0
  691. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/colour_prompt.rb +118 -0
  692. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/colour_reporter.rb +39 -0
  693. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_config.yml +36 -0
  694. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_module.rb +308 -0
  695. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +437 -0
  696. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/parse_output.rb +220 -0
  697. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/stylize_as_junit.rb +252 -0
  698. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/test_file_filter.rb +25 -0
  699. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/type_sanitizer.rb +6 -0
  700. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/unity_test_summary.py +139 -0
  701. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/unity_test_summary.rb +136 -0
  702. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/unity_to_junit.py +146 -0
  703. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +207 -0
  704. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityAssertionsCheatSheetSuitableforPrintingandPossiblyFraming.pdf +0 -0
  705. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityAssertionsReference.md +716 -0
  706. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityConfigurationGuide.md +398 -0
  707. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityGettingStartedGuide.md +191 -0
  708. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityHelperScriptsGuide.md +242 -0
  709. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/license.txt +21 -0
  710. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/makefile +71 -0
  711. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/readme.txt +5 -0
  712. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode.c +24 -0
  713. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode.h +3 -0
  714. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.c +11 -0
  715. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.h +2 -0
  716. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/TestProductionCode.c +62 -0
  717. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/TestProductionCode2.c +31 -0
  718. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -0
  719. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -0
  720. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/makefile +70 -0
  721. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/readme.txt +5 -0
  722. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode.c +24 -0
  723. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode.h +3 -0
  724. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode2.c +11 -0
  725. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode2.h +2 -0
  726. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/test/TestProductionCode.c +64 -0
  727. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/test/TestProductionCode2.c +33 -0
  728. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +9 -0
  729. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +11 -0
  730. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/all_tests.c +12 -0
  731. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/helper/UnityHelper.c +10 -0
  732. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/helper/UnityHelper.h +12 -0
  733. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/rakefile.rb +43 -0
  734. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/rakefile_helper.rb +249 -0
  735. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/readme.txt +13 -0
  736. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode.c +24 -0
  737. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode.h +3 -0
  738. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode2.c +11 -0
  739. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode2.h +2 -0
  740. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/target_gcc_32.yml +46 -0
  741. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/test/TestProductionCode.c +62 -0
  742. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/test/TestProductionCode2.c +31 -0
  743. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/unity_config.h +237 -0
  744. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/eclipse/error_parsers.txt +26 -0
  745. data/vendor/cmock/vendor/{unity → c_exception/vendor/unity}/extras/fixture/rakefile.rb +48 -44
  746. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/rakefile_helper.rb +178 -0
  747. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/readme.txt +9 -0
  748. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +432 -0
  749. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +83 -0
  750. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +51 -0
  751. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +47 -0
  752. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/Makefile +74 -0
  753. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/main/AllTests.c +22 -0
  754. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/template_fixture_tests.c +39 -0
  755. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +543 -0
  756. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +57 -0
  757. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +57 -0
  758. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +17 -0
  759. data/vendor/cmock/vendor/c_exception/vendor/unity/release/build.info +2 -0
  760. data/vendor/cmock/vendor/c_exception/vendor/unity/release/version.info +2 -0
  761. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.c +1517 -0
  762. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.h +339 -0
  763. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity_internals.h +784 -0
  764. data/vendor/cmock/vendor/c_exception/vendor/unity/test/Makefile +63 -0
  765. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_cmd.c +61 -0
  766. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_def.c +57 -0
  767. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.c +55 -0
  768. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.h +15 -0
  769. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_cmd.c +80 -0
  770. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_def.c +76 -0
  771. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.c +75 -0
  772. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.h +13 -0
  773. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new1.c +89 -0
  774. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new2.c +89 -0
  775. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_param.c +77 -0
  776. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run1.c +89 -0
  777. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run2.c +89 -0
  778. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_yaml.c +90 -0
  779. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_new1.c +67 -0
  780. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_new2.c +70 -0
  781. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_param.c +58 -0
  782. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_run1.c +67 -0
  783. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_run2.c +70 -0
  784. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_yaml.c +71 -0
  785. data/vendor/cmock/vendor/c_exception/vendor/unity/test/rakefile +125 -0
  786. data/vendor/cmock/vendor/c_exception/vendor/unity/test/rakefile_helper.rb +260 -0
  787. data/vendor/cmock/vendor/c_exception/vendor/unity/test/spec/generate_module_existing_file_spec.rb +158 -0
  788. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/clang_file.yml +78 -0
  789. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/clang_strict.yml +78 -0
  790. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_32.yml +49 -0
  791. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_64.yml +50 -0
  792. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_auto_limits.yml +47 -0
  793. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_auto_stdint.yml +59 -0
  794. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_manual_math.yml +47 -0
  795. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/hitech_picc18.yml +101 -0
  796. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/iar_arm_v4.yml +90 -0
  797. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/iar_arm_v5.yml +80 -0
  798. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/iar_arm_v5_3.yml +80 -0
  799. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +94 -0
  800. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/iar_cortexm3_v5.yml +84 -0
  801. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/iar_msp430.yml +95 -0
  802. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/iar_sh2a_v6.yml +86 -0
  803. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/CException.h +11 -0
  804. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/Defs.h +8 -0
  805. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/cmock.h +14 -0
  806. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/mockMock.h +13 -0
  807. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/testRunnerGenerator.c +183 -0
  808. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/testRunnerGeneratorSmall.c +67 -0
  809. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/testRunnerGeneratorWithMocks.c +192 -0
  810. data/vendor/cmock/vendor/c_exception/vendor/unity/test/tests/test_generate_test_runner.rb +1252 -0
  811. data/vendor/cmock/vendor/c_exception/vendor/unity/test/tests/testparameterized.c +110 -0
  812. data/vendor/cmock/vendor/{unity → c_exception/vendor/unity}/test/tests/testunity.c +4993 -8168
  813. data/vendor/cmock/vendor/unity/CMakeLists.txt +133 -31
  814. data/vendor/cmock/vendor/unity/LICENSE.txt +21 -21
  815. data/vendor/cmock/vendor/unity/README.md +191 -191
  816. data/vendor/cmock/vendor/unity/auto/colour_prompt.rb +119 -119
  817. data/vendor/cmock/vendor/unity/auto/colour_reporter.rb +39 -39
  818. data/vendor/cmock/vendor/unity/auto/generate_config.yml +36 -36
  819. data/vendor/cmock/vendor/unity/auto/generate_module.rb +312 -309
  820. data/vendor/cmock/vendor/unity/auto/generate_test_runner.rb +511 -495
  821. data/vendor/cmock/vendor/unity/auto/parse_output.rb +322 -322
  822. data/vendor/cmock/vendor/unity/auto/run_test.erb +37 -36
  823. data/vendor/cmock/vendor/unity/auto/stylize_as_junit.rb +251 -251
  824. data/vendor/cmock/vendor/unity/auto/test_file_filter.rb +25 -25
  825. data/vendor/cmock/vendor/unity/auto/type_sanitizer.rb +6 -6
  826. data/vendor/cmock/vendor/unity/auto/unity_test_summary.py +139 -139
  827. data/vendor/cmock/vendor/unity/auto/unity_test_summary.rb +135 -135
  828. data/vendor/cmock/vendor/unity/auto/unity_to_junit.py +146 -146
  829. data/vendor/cmock/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +206 -206
  830. data/vendor/cmock/vendor/unity/docs/UnityAssertionsReference.md +831 -850
  831. data/vendor/cmock/vendor/unity/docs/UnityConfigurationGuide.md +563 -541
  832. data/vendor/cmock/vendor/unity/docs/UnityGettingStartedGuide.md +251 -251
  833. data/vendor/cmock/vendor/unity/docs/UnityHelperScriptsGuide.md +278 -266
  834. data/vendor/cmock/vendor/unity/examples/example_1/makefile +72 -72
  835. data/vendor/cmock/vendor/unity/examples/example_1/readme.txt +4 -4
  836. data/vendor/cmock/vendor/unity/examples/example_1/src/ProductionCode.c +24 -24
  837. data/vendor/cmock/vendor/unity/examples/example_1/src/ProductionCode.h +3 -3
  838. data/vendor/cmock/vendor/unity/examples/example_1/src/ProductionCode2.c +11 -11
  839. data/vendor/cmock/vendor/unity/examples/example_1/src/ProductionCode2.h +2 -2
  840. data/vendor/cmock/vendor/unity/examples/example_1/test/TestProductionCode.c +62 -62
  841. data/vendor/cmock/vendor/unity/examples/example_1/test/TestProductionCode2.c +31 -31
  842. data/vendor/cmock/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -53
  843. data/vendor/cmock/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -57
  844. data/vendor/cmock/vendor/unity/examples/example_2/makefile +71 -71
  845. data/vendor/cmock/vendor/unity/examples/example_2/readme.txt +4 -4
  846. data/vendor/cmock/vendor/unity/examples/example_2/src/ProductionCode.c +24 -24
  847. data/vendor/cmock/vendor/unity/examples/example_2/src/ProductionCode.h +3 -3
  848. data/vendor/cmock/vendor/unity/examples/example_2/src/ProductionCode2.c +11 -11
  849. data/vendor/cmock/vendor/unity/examples/example_2/src/ProductionCode2.h +2 -2
  850. data/vendor/cmock/vendor/unity/examples/example_2/test/TestProductionCode.c +64 -64
  851. data/vendor/cmock/vendor/unity/examples/example_2/test/TestProductionCode2.c +33 -33
  852. data/vendor/cmock/vendor/unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +8 -8
  853. data/vendor/cmock/vendor/unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +10 -10
  854. data/vendor/cmock/vendor/unity/examples/example_2/test/test_runners/all_tests.c +12 -12
  855. data/vendor/cmock/vendor/unity/examples/example_3/helper/UnityHelper.c +10 -10
  856. data/vendor/cmock/vendor/unity/examples/example_3/helper/UnityHelper.h +12 -12
  857. data/vendor/cmock/vendor/unity/examples/example_3/rakefile.rb +38 -38
  858. data/vendor/cmock/vendor/unity/examples/example_3/rakefile_helper.rb +250 -250
  859. data/vendor/cmock/vendor/unity/examples/example_3/readme.txt +13 -13
  860. data/vendor/cmock/vendor/unity/examples/example_3/src/ProductionCode.c +24 -24
  861. data/vendor/cmock/vendor/unity/examples/example_3/src/ProductionCode.h +3 -3
  862. data/vendor/cmock/vendor/unity/examples/example_3/src/ProductionCode2.c +11 -11
  863. data/vendor/cmock/vendor/unity/examples/example_3/src/ProductionCode2.h +2 -2
  864. data/vendor/cmock/vendor/unity/examples/example_3/target_gcc_32.yml +47 -47
  865. data/vendor/cmock/vendor/unity/examples/example_3/test/TestProductionCode.c +62 -62
  866. data/vendor/cmock/vendor/unity/examples/example_3/test/TestProductionCode2.c +31 -31
  867. data/vendor/cmock/vendor/unity/examples/example_4/meson.build +12 -17
  868. data/vendor/cmock/vendor/unity/examples/example_4/readme.txt +14 -14
  869. data/vendor/cmock/vendor/unity/examples/example_4/src/ProductionCode.c +24 -24
  870. data/vendor/cmock/vendor/unity/examples/example_4/src/ProductionCode.h +3 -3
  871. data/vendor/cmock/vendor/unity/examples/example_4/src/ProductionCode2.c +11 -11
  872. data/vendor/cmock/vendor/unity/examples/example_4/src/ProductionCode2.h +2 -2
  873. data/vendor/cmock/vendor/unity/examples/example_4/src/meson.build +16 -21
  874. data/vendor/cmock/vendor/unity/examples/example_4/subprojects/unity.wrap +4 -4
  875. data/vendor/cmock/vendor/unity/examples/example_4/test/TestProductionCode.c +63 -63
  876. data/vendor/cmock/vendor/unity/examples/example_4/test/TestProductionCode2.c +35 -35
  877. data/vendor/cmock/vendor/unity/examples/example_4/test/meson.build +7 -12
  878. data/vendor/cmock/vendor/unity/examples/example_4/test/test_runners/TestProductionCode2_Runner.c +53 -53
  879. data/vendor/cmock/vendor/unity/examples/example_4/test/test_runners/TestProductionCode_Runner.c +57 -57
  880. data/vendor/cmock/vendor/unity/examples/example_4/test/test_runners/meson.build +13 -16
  881. data/vendor/cmock/vendor/unity/examples/unity_config.h +244 -263
  882. data/vendor/cmock/vendor/unity/extras/eclipse/error_parsers.txt +26 -26
  883. data/vendor/cmock/vendor/unity/extras/fixture/readme.md +29 -17
  884. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.c +310 -275
  885. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.h +83 -83
  886. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_internals.h +50 -50
  887. data/vendor/cmock/vendor/unity/extras/fixture/test/Makefile +72 -72
  888. data/vendor/cmock/vendor/unity/extras/fixture/test/main/AllTests.c +20 -20
  889. data/vendor/cmock/vendor/unity/extras/fixture/test/template_fixture_tests.c +39 -39
  890. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_Test.c +245 -245
  891. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +32 -32
  892. data/vendor/cmock/vendor/unity/extras/memory/readme.md +49 -49
  893. data/vendor/cmock/vendor/unity/extras/memory/src/unity_memory.c +202 -202
  894. data/vendor/cmock/vendor/unity/extras/memory/src/unity_memory.h +60 -60
  895. data/vendor/cmock/vendor/unity/extras/memory/test/Makefile +78 -78
  896. data/vendor/cmock/vendor/unity/extras/memory/test/unity_memory_Test.c +325 -325
  897. data/vendor/cmock/vendor/unity/extras/memory/test/unity_memory_TestRunner.c +49 -49
  898. data/vendor/cmock/vendor/unity/extras/memory/test/unity_output_Spy.c +56 -56
  899. data/vendor/cmock/vendor/unity/extras/memory/test/unity_output_Spy.h +16 -16
  900. data/vendor/cmock/vendor/unity/meson.build +48 -69
  901. data/vendor/cmock/vendor/unity/src/meson.build +11 -16
  902. data/vendor/cmock/vendor/unity/src/unity.c +2109 -2085
  903. data/vendor/cmock/vendor/unity/src/unity.h +661 -617
  904. data/vendor/cmock/vendor/unity/src/unity_internals.h +1030 -1002
  905. data/vendor/cmock/vendor/unity/test/Makefile +159 -67
  906. data/vendor/cmock/vendor/unity/test/expectdata/testsample_cmd.c +61 -61
  907. data/vendor/cmock/vendor/unity/test/expectdata/testsample_def.c +57 -57
  908. data/vendor/cmock/vendor/unity/test/expectdata/testsample_head1.c +55 -55
  909. data/vendor/cmock/vendor/unity/test/expectdata/testsample_head1.h +15 -15
  910. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_cmd.c +80 -80
  911. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_def.c +76 -76
  912. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_head1.c +75 -75
  913. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_head1.h +13 -13
  914. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_new1.c +89 -89
  915. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_new2.c +89 -89
  916. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_param.c +77 -77
  917. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_run1.c +89 -89
  918. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_run2.c +89 -89
  919. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_yaml.c +90 -90
  920. data/vendor/cmock/vendor/unity/test/expectdata/testsample_new1.c +67 -67
  921. data/vendor/cmock/vendor/unity/test/expectdata/testsample_new2.c +70 -70
  922. data/vendor/cmock/vendor/unity/test/expectdata/testsample_param.c +58 -58
  923. data/vendor/cmock/vendor/unity/test/expectdata/testsample_run1.c +67 -67
  924. data/vendor/cmock/vendor/unity/test/expectdata/testsample_run2.c +70 -70
  925. data/vendor/cmock/vendor/unity/test/expectdata/testsample_yaml.c +71 -71
  926. data/vendor/cmock/vendor/unity/test/rakefile +163 -124
  927. data/vendor/cmock/vendor/unity/test/rakefile_helper.rb +315 -269
  928. data/vendor/cmock/vendor/unity/test/spec/generate_module_existing_file_spec.rb +158 -158
  929. data/vendor/cmock/vendor/unity/test/targets/ansi.yml +44 -49
  930. data/vendor/cmock/vendor/unity/test/targets/clang_file.yml +72 -78
  931. data/vendor/cmock/vendor/unity/test/targets/clang_strict.yml +71 -78
  932. data/vendor/cmock/vendor/unity/test/targets/gcc_32.yml +45 -49
  933. data/vendor/cmock/vendor/unity/test/targets/gcc_64.yml +46 -50
  934. data/vendor/cmock/vendor/unity/test/targets/gcc_auto_limits.yml +43 -47
  935. data/vendor/cmock/vendor/unity/test/targets/gcc_auto_stdint.yml +55 -59
  936. data/vendor/cmock/vendor/unity/test/targets/gcc_manual_math.yml +43 -47
  937. data/vendor/cmock/vendor/unity/test/targets/hitech_picc18.yml +91 -101
  938. data/vendor/cmock/vendor/unity/test/targets/iar_arm_v4.yml +98 -90
  939. data/vendor/cmock/vendor/unity/test/targets/iar_arm_v5.yml +92 -80
  940. data/vendor/cmock/vendor/unity/test/targets/iar_arm_v5_3.yml +92 -80
  941. data/vendor/cmock/vendor/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +90 -94
  942. data/vendor/cmock/vendor/unity/test/targets/iar_cortexm3_v5.yml +94 -84
  943. data/vendor/cmock/vendor/unity/test/targets/iar_msp430.yml +112 -95
  944. data/vendor/cmock/vendor/unity/test/targets/iar_sh2a_v6.yml +99 -86
  945. data/vendor/cmock/vendor/unity/test/testdata/CException.h +11 -11
  946. data/vendor/cmock/vendor/unity/test/testdata/Defs.h +8 -8
  947. data/vendor/cmock/vendor/unity/test/testdata/cmock.h +14 -14
  948. data/vendor/cmock/vendor/unity/test/testdata/mockMock.h +13 -13
  949. data/vendor/cmock/vendor/unity/test/testdata/testRunnerGenerator.c +189 -189
  950. data/vendor/cmock/vendor/unity/test/testdata/testRunnerGeneratorSmall.c +70 -70
  951. data/vendor/cmock/vendor/unity/test/testdata/testRunnerGeneratorWithMocks.c +197 -197
  952. data/vendor/cmock/vendor/unity/test/tests/self_assessment_utils.h +144 -0
  953. data/vendor/cmock/vendor/unity/test/tests/test_generate_test_runner.rb +1260 -1268
  954. data/vendor/cmock/vendor/unity/test/tests/test_unity_arrays.c +2874 -0
  955. data/vendor/cmock/vendor/unity/test/tests/test_unity_core.c +371 -0
  956. data/vendor/cmock/vendor/unity/test/tests/test_unity_doubles.c +773 -0
  957. data/vendor/cmock/vendor/unity/test/tests/test_unity_floats.c +884 -0
  958. data/vendor/cmock/vendor/unity/test/tests/test_unity_integers.c +2847 -0
  959. data/vendor/cmock/vendor/unity/test/tests/test_unity_integers_64.c +773 -0
  960. data/vendor/cmock/vendor/unity/test/tests/test_unity_memory.c +81 -0
  961. data/vendor/{unity/test/tests/testparameterized.c → cmock/vendor/unity/test/tests/test_unity_parameterized.c} +171 -171
  962. data/vendor/cmock/vendor/unity/test/tests/test_unity_strings.c +329 -0
  963. data/vendor/cmock/vendor/unity/unityConfig.cmake +1 -0
  964. data/vendor/deep_merge/MIT-LICENSE +20 -20
  965. data/vendor/deep_merge/README +94 -94
  966. data/vendor/deep_merge/Rakefile +28 -28
  967. data/vendor/deep_merge/lib/deep_merge.rb +211 -211
  968. data/vendor/deep_merge/test/test_deep_merge.rb +553 -553
  969. data/vendor/diy/History.txt +28 -28
  970. data/vendor/diy/README.rdoc +233 -233
  971. data/vendor/diy/Rakefile +33 -33
  972. data/vendor/diy/TODO.txt +9 -9
  973. data/vendor/diy/diy.gemspec +131 -131
  974. data/vendor/diy/lib/diy.rb +403 -403
  975. data/vendor/diy/lib/diy/factory.rb +36 -36
  976. data/vendor/diy/sample_code/car.rb +7 -7
  977. data/vendor/diy/sample_code/chassis.rb +5 -5
  978. data/vendor/diy/sample_code/diy_example.rb +26 -26
  979. data/vendor/diy/sample_code/engine.rb +5 -5
  980. data/vendor/diy/sample_code/objects.yml +10 -10
  981. data/vendor/diy/test/constructor.rb +119 -119
  982. data/vendor/diy/test/diy_test.rb +608 -608
  983. data/vendor/diy/test/factory_test.rb +79 -79
  984. data/vendor/diy/test/files/broken_construction.yml +7 -7
  985. data/vendor/diy/test/files/cat/cat.rb +3 -3
  986. data/vendor/diy/test/files/cat/extra_conflict.yml +5 -5
  987. data/vendor/diy/test/files/cat/heritage.rb +2 -2
  988. data/vendor/diy/test/files/cat/needs_input.yml +3 -3
  989. data/vendor/diy/test/files/cat/the_cat_lineage.rb +1 -1
  990. data/vendor/diy/test/files/dog/dog_model.rb +3 -3
  991. data/vendor/diy/test/files/dog/dog_presenter.rb +3 -3
  992. data/vendor/diy/test/files/dog/dog_view.rb +2 -2
  993. data/vendor/diy/test/files/dog/file_resolver.rb +2 -2
  994. data/vendor/diy/test/files/dog/other_thing.rb +2 -2
  995. data/vendor/diy/test/files/dog/simple.yml +11 -11
  996. data/vendor/diy/test/files/donkey/foo.rb +8 -8
  997. data/vendor/diy/test/files/donkey/foo/bar/qux.rb +7 -7
  998. data/vendor/diy/test/files/factory/beef.rb +5 -5
  999. data/vendor/diy/test/files/factory/dog.rb +6 -6
  1000. data/vendor/diy/test/files/factory/factory.yml +19 -19
  1001. data/vendor/diy/test/files/factory/farm/llama.rb +7 -7
  1002. data/vendor/diy/test/files/factory/farm/pork.rb +7 -7
  1003. data/vendor/diy/test/files/factory/kitten.rb +13 -13
  1004. data/vendor/diy/test/files/fud/objects.yml +13 -13
  1005. data/vendor/diy/test/files/fud/toy.rb +14 -14
  1006. data/vendor/diy/test/files/functions/attached_things_builder.rb +1 -1
  1007. data/vendor/diy/test/files/functions/invalid_method.yml +4 -4
  1008. data/vendor/diy/test/files/functions/method_extractor.rb +2 -2
  1009. data/vendor/diy/test/files/functions/nonsingleton_objects.yml +5 -5
  1010. data/vendor/diy/test/files/functions/objects.yml +21 -21
  1011. data/vendor/diy/test/files/functions/thing.rb +2 -2
  1012. data/vendor/diy/test/files/functions/thing_builder.rb +24 -24
  1013. data/vendor/diy/test/files/functions/things_builder.rb +2 -2
  1014. data/vendor/diy/test/files/gnu/objects.yml +14 -14
  1015. data/vendor/diy/test/files/gnu/thinger.rb +7 -7
  1016. data/vendor/diy/test/files/goat/base.rb +8 -8
  1017. data/vendor/diy/test/files/goat/can.rb +6 -6
  1018. data/vendor/diy/test/files/goat/goat.rb +6 -6
  1019. data/vendor/diy/test/files/goat/objects.yml +12 -12
  1020. data/vendor/diy/test/files/goat/paper.rb +6 -6
  1021. data/vendor/diy/test/files/goat/plane.rb +7 -7
  1022. data/vendor/diy/test/files/goat/shirt.rb +6 -6
  1023. data/vendor/diy/test/files/goat/wings.rb +8 -8
  1024. data/vendor/diy/test/files/horse/holder_thing.rb +3 -3
  1025. data/vendor/diy/test/files/horse/objects.yml +7 -7
  1026. data/vendor/diy/test/files/namespace/animal/bird.rb +5 -5
  1027. data/vendor/diy/test/files/namespace/animal/cat.rb +5 -5
  1028. data/vendor/diy/test/files/namespace/animal/reptile/hardshell/turtle.rb +8 -8
  1029. data/vendor/diy/test/files/namespace/animal/reptile/lizard.rb +7 -7
  1030. data/vendor/diy/test/files/namespace/bad_module_specified.yml +8 -8
  1031. data/vendor/diy/test/files/namespace/class_name_combine.yml +8 -8
  1032. data/vendor/diy/test/files/namespace/no_module_specified.yml +8 -8
  1033. data/vendor/diy/test/files/namespace/objects.yml +21 -21
  1034. data/vendor/diy/test/files/namespace/road.rb +2 -2
  1035. data/vendor/diy/test/files/namespace/sky.rb +2 -2
  1036. data/vendor/diy/test/files/namespace/subcontext.yml +22 -22
  1037. data/vendor/diy/test/files/non_singleton/air.rb +2 -2
  1038. data/vendor/diy/test/files/non_singleton/fat_cat.rb +3 -3
  1039. data/vendor/diy/test/files/non_singleton/objects.yml +19 -19
  1040. data/vendor/diy/test/files/non_singleton/pig.rb +3 -3
  1041. data/vendor/diy/test/files/non_singleton/thread_spinner.rb +3 -3
  1042. data/vendor/diy/test/files/non_singleton/tick.rb +3 -3
  1043. data/vendor/diy/test/files/non_singleton/yard.rb +2 -2
  1044. data/vendor/diy/test/files/yak/core_model.rb +3 -3
  1045. data/vendor/diy/test/files/yak/core_presenter.rb +3 -3
  1046. data/vendor/diy/test/files/yak/core_view.rb +1 -1
  1047. data/vendor/diy/test/files/yak/data_source.rb +1 -1
  1048. data/vendor/diy/test/files/yak/fringe_model.rb +3 -3
  1049. data/vendor/diy/test/files/yak/fringe_presenter.rb +3 -3
  1050. data/vendor/diy/test/files/yak/fringe_view.rb +1 -1
  1051. data/vendor/diy/test/files/yak/giant_squid.rb +3 -3
  1052. data/vendor/diy/test/files/yak/krill.rb +2 -2
  1053. data/vendor/diy/test/files/yak/my_objects.yml +21 -21
  1054. data/vendor/diy/test/files/yak/sub_sub_context_test.yml +27 -27
  1055. data/vendor/diy/test/test_helper.rb +55 -55
  1056. data/vendor/hardmock/CHANGES +78 -78
  1057. data/vendor/hardmock/LICENSE +7 -7
  1058. data/vendor/hardmock/README +70 -70
  1059. data/vendor/hardmock/Rakefile +8 -8
  1060. data/vendor/hardmock/config/environment.rb +12 -12
  1061. data/vendor/hardmock/lib/assert_error.rb +23 -23
  1062. data/vendor/hardmock/lib/extend_test_unit.rb +14 -14
  1063. data/vendor/hardmock/lib/hardmock.rb +86 -86
  1064. data/vendor/hardmock/lib/hardmock/errors.rb +22 -22
  1065. data/vendor/hardmock/lib/hardmock/expectation.rb +229 -229
  1066. data/vendor/hardmock/lib/hardmock/expectation_builder.rb +9 -9
  1067. data/vendor/hardmock/lib/hardmock/expector.rb +26 -26
  1068. data/vendor/hardmock/lib/hardmock/method_cleanout.rb +33 -33
  1069. data/vendor/hardmock/lib/hardmock/mock.rb +180 -180
  1070. data/vendor/hardmock/lib/hardmock/mock_control.rb +53 -53
  1071. data/vendor/hardmock/lib/hardmock/stubbing.rb +210 -210
  1072. data/vendor/hardmock/lib/hardmock/trapper.rb +31 -31
  1073. data/vendor/hardmock/lib/hardmock/utils.rb +9 -9
  1074. data/vendor/hardmock/lib/test_unit_before_after.rb +169 -169
  1075. data/vendor/hardmock/rake_tasks/rdoc.rake +19 -19
  1076. data/vendor/hardmock/rake_tasks/rdoc_options.rb +4 -4
  1077. data/vendor/hardmock/rake_tasks/test.rake +22 -22
  1078. data/vendor/hardmock/test/functional/assert_error_test.rb +52 -52
  1079. data/vendor/hardmock/test/functional/auto_verify_test.rb +178 -178
  1080. data/vendor/hardmock/test/functional/direct_mock_usage_test.rb +396 -396
  1081. data/vendor/hardmock/test/functional/hardmock_test.rb +434 -434
  1082. data/vendor/hardmock/test/functional/stubbing_test.rb +479 -479
  1083. data/vendor/hardmock/test/test_helper.rb +43 -43
  1084. data/vendor/hardmock/test/unit/expectation_builder_test.rb +19 -19
  1085. data/vendor/hardmock/test/unit/expectation_test.rb +372 -372
  1086. data/vendor/hardmock/test/unit/expector_test.rb +57 -57
  1087. data/vendor/hardmock/test/unit/method_cleanout_test.rb +36 -36
  1088. data/vendor/hardmock/test/unit/mock_control_test.rb +175 -175
  1089. data/vendor/hardmock/test/unit/mock_test.rb +279 -279
  1090. data/vendor/hardmock/test/unit/test_unit_before_after_test.rb +452 -452
  1091. data/vendor/hardmock/test/unit/trapper_test.rb +62 -62
  1092. data/vendor/hardmock/test/unit/verify_error_test.rb +40 -40
  1093. data/vendor/unity/CMakeLists.txt +133 -31
  1094. data/vendor/unity/LICENSE.txt +21 -21
  1095. data/vendor/unity/README.md +191 -191
  1096. data/vendor/unity/auto/colour_prompt.rb +119 -119
  1097. data/vendor/unity/auto/colour_reporter.rb +39 -39
  1098. data/vendor/unity/auto/generate_config.yml +36 -36
  1099. data/vendor/unity/auto/generate_module.rb +312 -309
  1100. data/vendor/unity/auto/generate_test_runner.rb +511 -495
  1101. data/vendor/unity/auto/parse_output.rb +322 -322
  1102. data/vendor/unity/auto/run_test.erb +37 -36
  1103. data/vendor/unity/auto/stylize_as_junit.rb +251 -251
  1104. data/vendor/unity/auto/test_file_filter.rb +25 -25
  1105. data/vendor/unity/auto/type_sanitizer.rb +6 -6
  1106. data/vendor/unity/auto/unity_test_summary.py +139 -139
  1107. data/vendor/unity/auto/unity_test_summary.rb +135 -135
  1108. data/vendor/unity/auto/unity_to_junit.py +146 -146
  1109. data/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +206 -206
  1110. data/vendor/unity/docs/UnityAssertionsReference.md +831 -850
  1111. data/vendor/unity/docs/UnityConfigurationGuide.md +563 -541
  1112. data/vendor/unity/docs/UnityGettingStartedGuide.md +251 -251
  1113. data/vendor/unity/docs/UnityHelperScriptsGuide.md +278 -266
  1114. data/vendor/unity/examples/example_1/makefile +72 -72
  1115. data/vendor/unity/examples/example_1/readme.txt +4 -4
  1116. data/vendor/unity/examples/example_1/src/ProductionCode.c +24 -24
  1117. data/vendor/unity/examples/example_1/src/ProductionCode.h +3 -3
  1118. data/vendor/unity/examples/example_1/src/ProductionCode2.c +11 -11
  1119. data/vendor/unity/examples/example_1/src/ProductionCode2.h +2 -2
  1120. data/vendor/unity/examples/example_1/test/TestProductionCode.c +62 -62
  1121. data/vendor/unity/examples/example_1/test/TestProductionCode2.c +31 -31
  1122. data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -53
  1123. data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -57
  1124. data/vendor/unity/examples/example_2/makefile +71 -71
  1125. data/vendor/unity/examples/example_2/readme.txt +4 -4
  1126. data/vendor/unity/examples/example_2/src/ProductionCode.c +24 -24
  1127. data/vendor/unity/examples/example_2/src/ProductionCode.h +3 -3
  1128. data/vendor/unity/examples/example_2/src/ProductionCode2.c +11 -11
  1129. data/vendor/unity/examples/example_2/src/ProductionCode2.h +2 -2
  1130. data/vendor/unity/examples/example_2/test/TestProductionCode.c +64 -64
  1131. data/vendor/unity/examples/example_2/test/TestProductionCode2.c +33 -33
  1132. data/vendor/unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +8 -8
  1133. data/vendor/unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +10 -10
  1134. data/vendor/unity/examples/example_2/test/test_runners/all_tests.c +12 -12
  1135. data/vendor/unity/examples/example_3/helper/UnityHelper.c +10 -10
  1136. data/vendor/unity/examples/example_3/helper/UnityHelper.h +12 -12
  1137. data/vendor/unity/examples/example_3/rakefile.rb +38 -38
  1138. data/vendor/unity/examples/example_3/rakefile_helper.rb +250 -250
  1139. data/vendor/unity/examples/example_3/readme.txt +13 -13
  1140. data/vendor/unity/examples/example_3/src/ProductionCode.c +24 -24
  1141. data/vendor/unity/examples/example_3/src/ProductionCode.h +3 -3
  1142. data/vendor/unity/examples/example_3/src/ProductionCode2.c +11 -11
  1143. data/vendor/unity/examples/example_3/src/ProductionCode2.h +2 -2
  1144. data/vendor/unity/examples/example_3/target_gcc_32.yml +47 -47
  1145. data/vendor/unity/examples/example_3/test/TestProductionCode.c +62 -62
  1146. data/vendor/unity/examples/example_3/test/TestProductionCode2.c +31 -31
  1147. data/vendor/unity/examples/example_4/meson.build +12 -17
  1148. data/vendor/unity/examples/example_4/readme.txt +14 -14
  1149. data/vendor/unity/examples/example_4/src/ProductionCode.c +24 -24
  1150. data/vendor/unity/examples/example_4/src/ProductionCode.h +3 -3
  1151. data/vendor/unity/examples/example_4/src/ProductionCode2.c +11 -11
  1152. data/vendor/unity/examples/example_4/src/ProductionCode2.h +2 -2
  1153. data/vendor/unity/examples/example_4/src/meson.build +16 -21
  1154. data/vendor/unity/examples/example_4/subprojects/unity.wrap +4 -4
  1155. data/vendor/unity/examples/example_4/test/TestProductionCode.c +63 -63
  1156. data/vendor/unity/examples/example_4/test/TestProductionCode2.c +35 -35
  1157. data/vendor/unity/examples/example_4/test/meson.build +7 -12
  1158. data/vendor/unity/examples/example_4/test/test_runners/TestProductionCode2_Runner.c +53 -53
  1159. data/vendor/unity/examples/example_4/test/test_runners/TestProductionCode_Runner.c +57 -57
  1160. data/vendor/unity/examples/example_4/test/test_runners/meson.build +13 -16
  1161. data/vendor/unity/examples/unity_config.h +244 -263
  1162. data/vendor/unity/extras/eclipse/error_parsers.txt +26 -26
  1163. data/vendor/unity/extras/fixture/readme.md +29 -17
  1164. data/vendor/unity/extras/fixture/src/unity_fixture.c +310 -275
  1165. data/vendor/unity/extras/fixture/src/unity_fixture.h +83 -83
  1166. data/vendor/unity/extras/fixture/src/unity_fixture_internals.h +50 -50
  1167. data/vendor/unity/extras/fixture/test/Makefile +72 -72
  1168. data/vendor/unity/extras/fixture/test/main/AllTests.c +20 -20
  1169. data/vendor/unity/extras/fixture/test/template_fixture_tests.c +39 -39
  1170. data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +245 -245
  1171. data/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +32 -32
  1172. data/vendor/unity/extras/memory/readme.md +49 -49
  1173. data/vendor/unity/extras/memory/src/unity_memory.c +202 -202
  1174. data/vendor/unity/extras/memory/src/unity_memory.h +60 -60
  1175. data/vendor/unity/extras/memory/test/Makefile +78 -78
  1176. data/vendor/unity/extras/memory/test/unity_memory_Test.c +325 -325
  1177. data/vendor/unity/extras/memory/test/unity_memory_TestRunner.c +49 -49
  1178. data/vendor/unity/extras/memory/test/unity_output_Spy.c +56 -56
  1179. data/vendor/unity/extras/memory/test/unity_output_Spy.h +16 -16
  1180. data/vendor/unity/meson.build +48 -69
  1181. data/vendor/unity/src/meson.build +11 -16
  1182. data/vendor/unity/src/unity.c +2109 -2085
  1183. data/vendor/unity/src/unity.h +661 -617
  1184. data/vendor/unity/src/unity_internals.h +1030 -1002
  1185. data/vendor/unity/test/Makefile +159 -67
  1186. data/vendor/unity/test/expectdata/testsample_cmd.c +61 -61
  1187. data/vendor/unity/test/expectdata/testsample_def.c +57 -57
  1188. data/vendor/unity/test/expectdata/testsample_head1.c +55 -55
  1189. data/vendor/unity/test/expectdata/testsample_head1.h +15 -15
  1190. data/vendor/unity/test/expectdata/testsample_mock_cmd.c +80 -80
  1191. data/vendor/unity/test/expectdata/testsample_mock_def.c +76 -76
  1192. data/vendor/unity/test/expectdata/testsample_mock_head1.c +75 -75
  1193. data/vendor/unity/test/expectdata/testsample_mock_head1.h +13 -13
  1194. data/vendor/unity/test/expectdata/testsample_mock_new1.c +89 -89
  1195. data/vendor/unity/test/expectdata/testsample_mock_new2.c +89 -89
  1196. data/vendor/unity/test/expectdata/testsample_mock_param.c +77 -77
  1197. data/vendor/unity/test/expectdata/testsample_mock_run1.c +89 -89
  1198. data/vendor/unity/test/expectdata/testsample_mock_run2.c +89 -89
  1199. data/vendor/unity/test/expectdata/testsample_mock_yaml.c +90 -90
  1200. data/vendor/unity/test/expectdata/testsample_new1.c +67 -67
  1201. data/vendor/unity/test/expectdata/testsample_new2.c +70 -70
  1202. data/vendor/unity/test/expectdata/testsample_param.c +58 -58
  1203. data/vendor/unity/test/expectdata/testsample_run1.c +67 -67
  1204. data/vendor/unity/test/expectdata/testsample_run2.c +70 -70
  1205. data/vendor/unity/test/expectdata/testsample_yaml.c +71 -71
  1206. data/vendor/unity/test/rakefile +163 -124
  1207. data/vendor/unity/test/rakefile_helper.rb +315 -269
  1208. data/vendor/unity/test/spec/generate_module_existing_file_spec.rb +158 -158
  1209. data/vendor/unity/test/targets/ansi.yml +44 -49
  1210. data/vendor/unity/test/targets/clang_file.yml +72 -78
  1211. data/vendor/unity/test/targets/clang_strict.yml +71 -78
  1212. data/vendor/unity/test/targets/gcc_32.yml +45 -49
  1213. data/vendor/unity/test/targets/gcc_64.yml +46 -50
  1214. data/vendor/unity/test/targets/gcc_auto_limits.yml +43 -47
  1215. data/vendor/unity/test/targets/gcc_auto_stdint.yml +55 -59
  1216. data/vendor/unity/test/targets/gcc_manual_math.yml +43 -47
  1217. data/vendor/unity/test/targets/hitech_picc18.yml +91 -101
  1218. data/vendor/unity/test/targets/iar_arm_v4.yml +98 -90
  1219. data/vendor/unity/test/targets/iar_arm_v5.yml +92 -80
  1220. data/vendor/unity/test/targets/iar_arm_v5_3.yml +92 -80
  1221. data/vendor/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +90 -94
  1222. data/vendor/unity/test/targets/iar_cortexm3_v5.yml +94 -84
  1223. data/vendor/unity/test/targets/iar_msp430.yml +112 -95
  1224. data/vendor/unity/test/targets/iar_sh2a_v6.yml +99 -86
  1225. data/vendor/unity/test/testdata/CException.h +11 -11
  1226. data/vendor/unity/test/testdata/Defs.h +8 -8
  1227. data/vendor/unity/test/testdata/cmock.h +14 -14
  1228. data/vendor/unity/test/testdata/mockMock.h +13 -13
  1229. data/vendor/unity/test/testdata/testRunnerGenerator.c +189 -189
  1230. data/vendor/unity/test/testdata/testRunnerGeneratorSmall.c +70 -70
  1231. data/vendor/unity/test/testdata/testRunnerGeneratorWithMocks.c +197 -197
  1232. data/vendor/unity/test/tests/self_assessment_utils.h +144 -0
  1233. data/vendor/unity/test/tests/test_generate_test_runner.rb +1260 -1268
  1234. data/vendor/unity/test/tests/test_unity_arrays.c +2874 -0
  1235. data/vendor/unity/test/tests/test_unity_core.c +371 -0
  1236. data/vendor/unity/test/tests/test_unity_doubles.c +773 -0
  1237. data/vendor/unity/test/tests/test_unity_floats.c +884 -0
  1238. data/vendor/unity/test/tests/test_unity_integers.c +2847 -0
  1239. data/vendor/unity/test/tests/test_unity_integers_64.c +773 -0
  1240. data/vendor/unity/test/tests/test_unity_memory.c +81 -0
  1241. data/vendor/{cmock/vendor/unity/test/tests/testparameterized.c → unity/test/tests/test_unity_parameterized.c} +171 -171
  1242. data/vendor/unity/test/tests/test_unity_strings.c +329 -0
  1243. data/vendor/unity/unityConfig.cmake +1 -0
  1244. metadata +225 -62
  1245. data/ceedling.sublime-project +0 -28
  1246. data/ceedling.sublime-workspace +0 -1276
  1247. data/docs/CeedlingPacket.odt +0 -0
  1248. data/docs/CeedlingPacket.pdf +0 -0
  1249. data/plugins/bullseye/readme.txt +0 -0
  1250. data/vendor/c_exception/LICENSE.txt +0 -30
  1251. data/vendor/c_exception/Rakefile +0 -42
  1252. data/vendor/c_exception/makefile +0 -24
  1253. data/vendor/c_exception/test/TestException_Runner.c +0 -67
  1254. data/vendor/cmock/vendor/c_exception/LICENSE.txt +0 -30
  1255. data/vendor/cmock/vendor/c_exception/Rakefile +0 -42
  1256. data/vendor/cmock/vendor/c_exception/makefile +0 -24
  1257. data/vendor/cmock/vendor/c_exception/test/TestException_Runner.c +0 -67
  1258. data/vendor/cmock/vendor/unity/extras/fixture/rakefile_helper.rb +0 -183
  1259. data/vendor/cmock/vendor/unity/extras/memory/rakefile.rb +0 -45
  1260. data/vendor/cmock/vendor/unity/extras/memory/rakefile_helper.rb +0 -187
  1261. data/vendor/cmock/vendor/unity/src/CMakeLists.txt +0 -22
  1262. data/vendor/unity/extras/fixture/rakefile.rb +0 -44
  1263. data/vendor/unity/extras/fixture/rakefile_helper.rb +0 -183
  1264. data/vendor/unity/extras/memory/rakefile.rb +0 -45
  1265. data/vendor/unity/extras/memory/rakefile_helper.rb +0 -187
  1266. data/vendor/unity/src/CMakeLists.txt +0 -22
  1267. data/vendor/unity/test/tests/testunity.c +0 -8168
@@ -1,2000 +1,2717 @@
1
- # ==========================================
2
- # CMock Project - Automatic Mock Generation for C
3
- # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
4
- # [Released under MIT License. Please refer to license.txt for details]
5
- # ==========================================
6
-
7
- $ThisIsOnlyATest = true
8
-
9
- require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
10
- require File.expand_path(File.dirname(__FILE__)) + '/../../lib/cmock_header_parser'
11
-
12
- describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
13
-
14
- before do
15
- create_mocks :config
16
- @test_name = 'test_file.h'
17
- @config.expect :strippables, ["STRIPPABLE"]
18
- @config.expect :attributes, ['__ramfunc', 'funky_attrib', 'SQLITE_API']
19
- @config.expect :c_calling_conventions, ['__stdcall']
20
- @config.expect :treat_as_void, ['MY_FUNKY_VOID']
21
- @config.expect :treat_as, { "BANJOS" => "INT", "TUBAS" => "HEX16"}
22
- @config.expect :treat_as_array, {"IntArray" => "int", "Book" => "Page"}
23
- @config.expect :when_no_prototypes, :error
24
- @config.expect :verbosity, 1
25
- @config.expect :treat_externs, :exclude
26
- @config.expect :treat_inlines, :exclude
27
- @config.expect :array_size_type, ['int', 'size_t']
28
- @config.expect :array_size_name, 'size|len'
29
-
30
- @parser = CMockHeaderParser.new(@config)
31
- end
32
-
33
- after do
34
- end
35
-
36
- it "create and initialize variables to defaults appropriately" do
37
- assert_equal([], @parser.funcs)
38
- assert_equal(['const', '__ramfunc', 'funky_attrib', 'SQLITE_API'], @parser.c_attributes)
39
- assert_equal(['void','MY_FUNKY_VOID'], @parser.treat_as_void)
40
- end
41
-
42
- it "strip out line comments" do
43
- source =
44
- " abcd;\n" +
45
- "// hello;\n" +
46
- "who // is you\n"
47
-
48
- expected =
49
- [
50
- "abcd",
51
- "who"
52
- ]
53
-
54
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
55
- end
56
-
57
- it "remove block comments" do
58
- source =
59
- " no_comments;\n" +
60
- "// basic_line_comment;\n" +
61
- "/* basic_block_comment;*/\n" +
62
- "pre_block; /* start_of_block_comment;\n" +
63
- "// embedded_line_comment_in_block_comment; */\n" +
64
- "// /* commented_out_block_comment_line\n" +
65
- "shown_because_block_comment_invalid_from_line_comment;\n" +
66
- "// */\n" +
67
- "//* shorter_commented_out_block_comment_line; \n" +
68
- "shown_because_block_comment_invalid_from_shorter_line_comment;\n" +
69
- "/*/\n" +
70
- "not_shown_because_line_above_started_comment;\n" +
71
- "//*/\n" +
72
- "/* \n" +
73
- "not_shown_because_block_comment_started_this_time;\n" +
74
- "/*/\n" +
75
- "shown_because_line_above_ended_comment_this_time;\n" +
76
- "//*/\n"
77
-
78
- expected =
79
- [
80
- "no_comments",
81
- "pre_block",
82
- "shown_because_block_comment_invalid_from_line_comment",
83
- "shown_because_block_comment_invalid_from_shorter_line_comment",
84
- "shown_because_line_above_ended_comment_this_time"
85
- ]
86
-
87
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
88
- end
89
-
90
- it "remove strippables from the beginning or end of function declarations" do
91
- source =
92
- "void* my_calloc(size_t, size_t) STRIPPABLE;\n" +
93
- "void\n" +
94
- " my_realloc(void*, size_t) STRIPPABLE;\n" +
95
- "extern int\n" +
96
- " my_printf (void *my_object, const char *my_format, ...)\n" +
97
- " STRIPPABLE;\n" +
98
- " void STRIPPABLE universal_handler ();\n"
99
-
100
- expected =
101
- [
102
- "void* my_calloc(size_t, size_t)",
103
- "void my_realloc(void*, size_t)",
104
- "void universal_handler()"
105
- ]
106
-
107
- assert_equal(expected, @parser.import_source(source))
108
- end
109
-
110
- it "remove gcc's function __attribute__'s" do
111
- source =
112
- "void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)));\n" +
113
- "void\n" +
114
- " my_realloc(void*, size_t) __attribute__((alloc_size(2)));\n" +
115
- "extern int\n" +
116
- " my_printf (void *my_object, const char *my_format, ...)\n" +
117
- " __attribute__ ((format (printf, 2, 3)));\n" +
118
- " void __attribute__ ((interrupt)) universal_handler ();\n"
119
-
120
- expected =
121
- [
122
- "void* my_calloc(size_t, size_t)",
123
- "void my_realloc(void*, size_t)",
124
- "void universal_handler()"
125
- ]
126
-
127
- assert_equal(expected, @parser.import_source(source))
128
- end
129
-
130
- it "remove preprocessor directives" do
131
- source =
132
- "#when stuff_happens\n" +
133
- "#ifdef _TEST\n" +
134
- "#pragma stack_switch"
135
-
136
- expected = []
137
-
138
- assert_equal(expected, @parser.import_source(source))
139
- end
140
-
141
-
142
- it "remove assembler pragma sections" do
143
- source =
144
- " #pragma\tasm\n" +
145
- " .foo\n" +
146
- " lda %m\n" +
147
- " nop\n" +
148
- "# pragma endasm \n" +
149
- "foo"
150
-
151
- expected = ["foo"]
152
-
153
- assert_equal(expected, @parser.import_source(source))
154
- end
155
-
156
-
157
- it "smush lines together that contain continuation characters" do
158
- source =
159
- "hoo hah \\\n" +
160
- "when \\ \n"
161
-
162
- expected =
163
- [
164
- "hoo hah when"
165
- ]
166
-
167
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
168
- end
169
-
170
-
171
- it "remove C macro definitions" do
172
- source =
173
- "#define this is the first line\\\n" +
174
- "and the second\\\n" +
175
- "and the third that should be removed\n" +
176
- "but I'm here\n"
177
-
178
- expected = ["but I'm here"]
179
-
180
- assert_equal(expected, @parser.import_source(source))
181
- end
182
-
183
-
184
- it "remove typedef statements" do
185
- source =
186
- "typedef uint32 (unsigned int);\n" +
187
- "const typedef int INT;\n" +
188
- "int notatypedef;\n" +
189
- "int typedef_isnt_me;\n" +
190
- " typedef who cares what really comes here \n" + # exercise multiline typedef
191
- " continuation;\n" +
192
- "this should remain!;\n" +
193
- "typedef blah bleh;\n" +
194
- "typedef struct shell_command_struct {\n" +
195
- " char_ptr COMMAND;\n" +
196
- " int_32 (*SHELL_FUNC)(int_32 argc);\n" +
197
- "} SHELL_COMMAND_STRUCT, * SHELL_COMMAND_PTR;\n" +
198
- "typedef struct shell_command_struct {\n" +
199
- " char_ptr COMMAND;\n" +
200
- " int_32 (*SHELL_FUNC)(int_32 argc, char_ptr argv[]);\n" +
201
- "} SHELL_COMMAND_STRUCT, * SHELL_COMMAND_PTR;\n" +
202
- "typedef struct shell_command_struct {\n" +
203
- " char_ptr COMMAND;\n" +
204
- " int_32 (*SHELL_FUNC)(int_32 argc);\n" +
205
- "};\n"
206
-
207
- expected =
208
- [
209
- "int notatypedef",
210
- "int typedef_isnt_me",
211
- "this should remain!"
212
- ]
213
-
214
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
215
- end
216
-
217
-
218
- it "remove enum statements" do
219
- source =
220
- "enum _NamedEnum {\n" +
221
- " THING1 = (0x0001),\n" +
222
- " THING2 = (0x0001 << 5),\n" +
223
- "}ListOValues;\n\n" +
224
- "don't delete me!!\n" +
225
- " modifier_str enum _NamedEnum {THING1 = (0x0001), THING2 = (0x0001 << 5)} ListOValues;\n\n" +
226
- "typedef enum {\n" +
227
- " THING1,\n" +
228
- " THING2,\n" +
229
- "} Thinger;\n" +
230
- "or me!!\n"
231
-
232
- assert_equal(["don't delete me!! or me!!"], @parser.import_source(source).map!{|s|s.strip})
233
- end
234
-
235
-
236
- it "remove union statements" do
237
- source =
238
- "union _NamedDoohicky {\n" +
239
- " unsigned int a;\n" +
240
- " char b;\n" +
241
- "} Doohicky;\n\n" +
242
- "I want to live!!\n" +
243
- "some_modifier union { unsigned int a; char b;} Whatever;\n" +
244
- "typedef union {\n" +
245
- " unsigned int a;\n" +
246
- " char b;\n" +
247
- "} Whatever;\n" +
248
- "me too!!\n"
249
-
250
- assert_equal(["I want to live!! me too!!"], @parser.import_source(source).map!{|s|s.strip})
251
- end
252
-
253
-
254
- it "remove struct statements" do
255
- source =
256
- "struct _NamedStruct1 {\n" +
257
- " unsigned int a;\n" +
258
- " signed long int b;\n" +
259
- "} Thing ;\n\n" +
260
- "extern struct ForwardDeclared_t TestDataType1;\n" +
261
- "void foo(void);\n" +
262
- "struct\n"+
263
- " MultilineForwardDeclared_t\n" +
264
- " TestDataType2;\n" +
265
- "struct THINGER foo(void);\n" +
266
- "typedef struct {\n" +
267
- " unsigned int a;\n" +
268
- " signed char b;\n" +
269
- "}Thinger;\n" +
270
- "I want to live!!\n"
271
-
272
- assert_equal(["void foo(void)", "struct THINGER foo(void)", "I want to live!!"],
273
- @parser.import_source(source).map!{|s|s.strip})
274
- end
275
-
276
- it "remove externed and inline functions" do
277
- source =
278
- " extern uint32 foobar(unsigned int);\n" +
279
- "uint32 extern_name_func(unsigned int);\n" +
280
- "uint32 funcinline(unsigned int);\n" +
281
- "extern void bar(unsigned int);\n" +
282
- "inline void bar(unsigned int);\n" +
283
- "extern\n" +
284
- "void kinda_ugly_on_the_next_line(unsigned int);\n"
285
-
286
- expected =
287
- [
288
- "uint32 extern_name_func(unsigned int)",
289
- "uint32 funcinline(unsigned int)"
290
- ]
291
-
292
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
293
- end
294
-
295
- it "remove function definitions but keep function declarations" do
296
- source =
297
- "uint32 func_with_decl_a(unsigned int);\n" +
298
- "uint32 func_with_decl_a(unsigned int a) { return a; }\n" +
299
- "uint32 func_with_decl_b(unsigned int);\n" +
300
- "uint32 func_with_decl_b(unsigned int a)\n" +
301
- "{\n" +
302
- " bar((unsigned int) a);\n" +
303
- " stripme(a);\n" +
304
- "}\n"
305
-
306
- expected =
307
- [
308
- "uint32 func_with_decl_a(unsigned int)",
309
- "uint32 func_with_decl_a", #okay. it's not going to be interpretted as another function
310
- "uint32 func_with_decl_b(unsigned int)",
311
- "uint32 func_with_decl_b", #okay. it's not going to be interpretted as another function
312
- ]
313
-
314
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
315
- end
316
-
317
- it "remove function definitions with nested braces but keep function declarations" do
318
- source =
319
- "uint32 func_with_decl_a(unsigned int);\n" +
320
- "uint32 func_with_decl_a(unsigned int a) {\n" +
321
- " while (stuff) {\n" +
322
- " not_a_definition1(void);\n" +
323
- " }\n" +
324
- " not_a_definition2(blah, bleh);\n" +
325
- " return a;\n" +
326
- "}\n" +
327
- "uint32 func_with_decl_b(unsigned int);\n" +
328
- "uint32 func_with_decl_b(unsigned int a)\n" +
329
- "{\n" +
330
- " bar((unsigned int) a);\n" +
331
- " stripme(a);\n" +
332
- "}\n" +
333
- "uint32 func_with_decl_c(unsigned int);\n" +
334
- "uint32 func_with_decl_c(unsigned int a)\n" +
335
- "{\n" +
336
- " if(a > 0)\n" +
337
- " {\n" +
338
- " return 1;\n" +
339
- " }\n" +
340
- " else\n"+
341
- " {\n" +
342
- " return 2;\n" +
343
- " }\n" +
344
- "}\n"
345
-
346
- expected =
347
- [
348
- "uint32 func_with_decl_a(unsigned int)",
349
- "uint32 func_with_decl_a", #okay. it's not going to be interpretted as another function
350
- "uint32 func_with_decl_b(unsigned int)",
351
- "uint32 func_with_decl_b", #okay. it's not going to be interpretted as another function
352
- "uint32 func_with_decl_c(unsigned int)",
353
- "uint32 func_with_decl_c", #okay. it's not going to be interpretted as another function
354
- ]
355
-
356
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
357
- end
358
-
359
- it "remove a fully defined inline function" do
360
- source =
361
- "inline void foo(unsigned int a) { oranges = a; }\n" +
362
- "inline void bar(unsigned int a) { apples = a; };\n" +
363
- "inline void bar(unsigned int a)\n" +
364
- "{" +
365
- " bananas = a;\n" +
366
- "}"
367
-
368
- # ensure it's expected type of exception
369
- assert_raises RuntimeError do
370
- @parser.parse("module", source)
371
- end
372
-
373
- assert_equal([], @parser.funcs)
374
-
375
- # verify exception message
376
- begin
377
- @parser.parse("module", source)
378
- rescue RuntimeError => e
379
- assert_equal("ERROR: No function prototypes found!", e.message)
380
- end
381
- end
382
-
383
- it "remove a fully defined inline function that is multiple lines" do
384
- source =
385
- "inline void bar(unsigned int a)\n" +
386
- "{" +
387
- " bananas = a;\n" +
388
- " grapes = a;\n" +
389
- " apples(bananas, grapes);\n" +
390
- "}"
391
-
392
- # ensure it's expected type of exception
393
- assert_raises RuntimeError do
394
- @parser.parse("module", source)
395
- end
396
-
397
- assert_equal([], @parser.funcs)
398
-
399
- # verify exception message
400
- begin
401
- @parser.parse("module", source)
402
- rescue RuntimeError => e
403
- assert_equal("ERROR: No function prototypes found!", e.message)
404
- end
405
- end
406
-
407
- it "remove a fully defined inline function that contains nested braces" do
408
- source =
409
- "inline void bar(unsigned int a)\n" +
410
- "{" +
411
- " apples(bananas, grapes);\n" +
412
- " if (bananas == a)\n" +
413
- " {\n" +
414
- " oranges(a);\n" +
415
- " grapes = a;\n" +
416
- " }\n" +
417
- " grapefruit(bananas, grapes);\n" +
418
- "}"
419
-
420
- # ensure it's expected type of exception
421
- assert_raises RuntimeError do
422
- @parser.parse("module", source)
423
- end
424
-
425
- assert_equal([], @parser.funcs)
426
-
427
- # verify exception message
428
- begin
429
- @parser.parse("module", source)
430
- rescue RuntimeError => e
431
- assert_equal("ERROR: No function prototypes found!", e.message)
432
- end
433
- end
434
-
435
- it "remove just inline functions if externs to be included" do
436
- source =
437
- " extern uint32 foobar(unsigned int);\n" +
438
- "uint32 extern_name_func(unsigned int);\n" +
439
- "uint32 funcinline(unsigned int);\n" +
440
- "extern void bar(unsigned int);\n" +
441
- "inline void bar(unsigned int);\n" +
442
- "extern\n" +
443
- "void kinda_ugly_on_the_next_line(unsigned int);\n"
444
-
445
- expected =
446
- [ "extern uint32 foobar(unsigned int)",
447
- "uint32 extern_name_func(unsigned int)",
448
- "uint32 funcinline(unsigned int)",
449
- "extern void bar(unsigned int)",
450
- "extern void kinda_ugly_on_the_next_line(unsigned int)"
451
- ]
452
-
453
- @parser.treat_externs = :include
454
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
455
- end
456
-
457
- it "leave inline functions if inline to be included" do
458
- source =
459
- "extern uint32 foobar(unsigned int);\n" +
460
- "uint32 extern_name_func(unsigned int);\n" +
461
- "uint32 funcinline(unsigned int);\n" +
462
- "inline void inlineBar(unsigned int);\n" +
463
- "extern int extern_bar(void);\n" +
464
- "static inline void staticinlineBar(unsigned int);\n" +
465
- "static inline void bar(unsigned int);\n" +
466
- "static inline void bar(unsigned int)\n" +
467
- "{\n" +
468
- " // NOP\n" +
469
- "}\n"
470
-
471
- expected =
472
- [ "uint32 extern_name_func(unsigned int)",
473
- "uint32 funcinline(unsigned int)",
474
- "void inlineBar(unsigned int)",
475
- "void staticinlineBar(unsigned int)",
476
- "void bar(unsigned int)"
477
- ]
478
-
479
- @parser.treat_inlines = :include
480
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
481
- end
482
-
483
- it "leave inline and extern functions if inline and extern to be included" do
484
- source =
485
- "extern uint32 foobar(unsigned int);\n" +
486
- "uint32 extern_name_func(unsigned int);\n" +
487
- "uint32 funcinline(unsigned int);\n" +
488
- "inline void inlineBar(unsigned int);\n" +
489
- "extern int extern_bar(void);\n" +
490
- "static inline void staticinlineBar(unsigned int);\n" +
491
- "static inline void bar(unsigned int);\n" +
492
- "static inline void bar(unsigned int)\n" +
493
- "{\n" +
494
- " // NOP\n" +
495
- "}\n"
496
-
497
- expected =
498
- [ "extern uint32 foobar(unsigned int)",
499
- "uint32 extern_name_func(unsigned int)",
500
- "uint32 funcinline(unsigned int)",
501
- "void inlineBar(unsigned int)",
502
- "extern int extern_bar(void)",
503
- "void staticinlineBar(unsigned int)",
504
- "void bar(unsigned int)"
505
- ]
506
-
507
- @parser.treat_externs = :include
508
- @parser.treat_inlines = :include
509
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
510
- end
511
-
512
- it "remove defines" do
513
- source =
514
- "#define whatever you feel like defining\n" +
515
- "void hello(void);\n" +
516
- "#DEFINE I JUST DON'T CARE\n" +
517
- "#deFINE\n" +
518
- "#define get_foo() \\\n ((Thing)foo.bar)" # exercise multiline define
519
-
520
- expected =
521
- [
522
- "void hello(void)",
523
- ]
524
-
525
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
526
- end
527
-
528
-
529
- it "remove keywords that would keep things from going smoothly in the future" do
530
- source =
531
- "const int TheMatrix(register int Trinity, unsigned int *restrict Neo)"
532
-
533
- expected =
534
- [
535
- "const int TheMatrix(int Trinity, unsigned int * Neo)",
536
- ]
537
-
538
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
539
- end
540
-
541
-
542
- # some code actually typedef's void even though it's not ANSI C and is, frankly, weird
543
- # since cmock treats void specially, we can't let void be obfuscated
544
- it "handle odd case of typedef'd void returned" do
545
- source = "MY_FUNKY_VOID FunkyVoidReturned(int a)"
546
- expected = { :var_arg=>nil,
547
- :name=>"FunkyVoidReturned",
548
- :return=>{ :type => "void",
549
- :name => 'cmock_to_return',
550
- :ptr? => false,
551
- :const? => false,
552
- :const_ptr? => false,
553
- :str => "void cmock_to_return",
554
- :void? => true
555
- },
556
- :modifier=>"",
557
- :contains_ptr? => false,
558
- :args=>[{:type=>"int", :name=>"a", :ptr? => false, :const? => false, :const_ptr? => false}],
559
- :args_string=>"int a",
560
- :args_call=>"a"}
561
- assert_equal(expected, @parser.parse_declaration(source))
562
- end
563
-
564
- it "handle odd case of typedef'd void as arg" do
565
- source = "int FunkyVoidAsArg(MY_FUNKY_VOID)"
566
- expected = { :var_arg=>nil,
567
- :name=>"FunkyVoidAsArg",
568
- :return=>{ :type => "int",
569
- :name => 'cmock_to_return',
570
- :ptr? => false,
571
- :const? => false,
572
- :const_ptr? => false,
573
- :str => "int cmock_to_return",
574
- :void? => false
575
- },
576
- :modifier=>"",
577
- :contains_ptr? => false,
578
- :args=>[],
579
- :args_string=>"void",
580
- :args_call=>"" }
581
- assert_equal(expected, @parser.parse_declaration(source))
582
- end
583
-
584
- it "handle odd case of typedef'd void as arg pointer" do
585
- source = "char FunkyVoidPointer(MY_FUNKY_VOID* bluh)"
586
- expected = { :var_arg=>nil,
587
- :name=>"FunkyVoidPointer",
588
- :return=>{ :type => "char",
589
- :name => 'cmock_to_return',
590
- :ptr? => false,
591
- :const? => false,
592
- :const_ptr? => false,
593
- :str => "char cmock_to_return",
594
- :void? => false
595
- },
596
- :modifier=>"",
597
- :contains_ptr? => true,
598
- :args=>[{:type=>"MY_FUNKY_VOID*", :name=>"bluh", :ptr? => true, :const? => false, :const_ptr? => false}],
599
- :args_string=>"MY_FUNKY_VOID* bluh",
600
- :args_call=>"bluh" }
601
- assert_equal(expected, @parser.parse_declaration(source))
602
- end
603
-
604
-
605
- it "strip default values from function parameter lists" do
606
- source =
607
- "void Foo(int a = 57, float b=37.52, char c= 'd', char* e=\"junk\");\n"
608
-
609
- expected =
610
- [
611
- "void Foo(int a, float b, char c, char* e)"
612
- ]
613
-
614
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
615
- end
616
-
617
-
618
- it "raise upon empty file" do
619
- source = ''
620
-
621
- # ensure it's expected type of exception
622
- assert_raises RuntimeError do
623
- @parser.parse("module", source)
624
- end
625
-
626
- assert_equal([], @parser.funcs)
627
-
628
- # verify exception message
629
- begin
630
- @parser.parse("module", source)
631
- rescue RuntimeError => e
632
- assert_equal("ERROR: No function prototypes found!", e.message)
633
- end
634
- end
635
-
636
- it "clean up module names that contain spaces, dashes, and such" do
637
- source = 'void meh(int (*func)(int));'
638
-
639
- retval = @parser.parse("C:\Ugly Module-Name", source)
640
- assert (retval[:typedefs][0] =~ /CUglyModuleName/)
641
- end
642
-
643
- it "raise upon no function prototypes found in file" do
644
- source =
645
- "typedef void SILLY_VOID_TYPE1;\n" +
646
- "typedef (void) SILLY_VOID_TYPE2 ;\n" +
647
- "typedef ( void ) (*FUNCPTR)(void);\n\n" +
648
- "#define get_foo() \\\n ((Thing)foo.bar)"
649
-
650
- # ensure it's expected type of exception
651
- assert_raises(RuntimeError) do
652
- @parser.parse("module", source)
653
- end
654
-
655
- assert_equal([], @parser.funcs)
656
-
657
- # verify exception message
658
- begin
659
- @parser.parse("module", source)
660
- rescue RuntimeError => e
661
- assert_equal("ERROR: No function prototypes found!", e.message)
662
- end
663
- end
664
-
665
-
666
- it "raise upon prototype parsing failure" do
667
- source = "void (int, )"
668
-
669
- # ensure it's expected type of exception
670
- assert_raises(RuntimeError) do
671
- @parser.parse("module", source)
672
- end
673
-
674
- # verify exception message
675
- begin
676
- @parser.parse("module", source)
677
- rescue RuntimeError => e
678
- assert(e.message.include?("Failed Parsing Declaration Prototype!"))
679
- end
680
- end
681
-
682
- it "extract and return function declarations with retval and args" do
683
-
684
- source = "int Foo(int a, unsigned int b)"
685
- expected = { :var_arg=>nil,
686
- :name=>"Foo",
687
- :return=>{ :type => "int",
688
- :name => 'cmock_to_return',
689
- :ptr? => false,
690
- :const? => false,
691
- :const_ptr? => false,
692
- :str => "int cmock_to_return",
693
- :void? => false
694
- },
695
- :modifier=>"",
696
- :contains_ptr? => false,
697
- :args=>[ {:type=>"int", :name=>"a", :ptr? => false, :const? => false, :const_ptr? => false},
698
- {:type=>"unsigned int", :name=>"b", :ptr? => false, :const? => false, :const_ptr? => false}
699
- ],
700
- :args_string=>"int a, unsigned int b",
701
- :args_call=>"a, b" }
702
- assert_equal(expected, @parser.parse_declaration(source))
703
- end
704
-
705
- it "extract and return function declarations with no retval" do
706
-
707
- source = "void FunkyChicken( uint la, int de, bool da)"
708
- expected = { :var_arg=>nil,
709
- :return=>{ :type => "void",
710
- :name => 'cmock_to_return',
711
- :ptr? => false,
712
- :const? => false,
713
- :const_ptr? => false,
714
- :str => "void cmock_to_return",
715
- :void? => true
716
- },
717
- :name=>"FunkyChicken",
718
- :modifier=>"",
719
- :contains_ptr? => false,
720
- :args=>[ {:type=>"uint", :name=>"la", :ptr? => false, :const? => false, :const_ptr? => false},
721
- {:type=>"int", :name=>"de", :ptr? => false, :const? => false, :const_ptr? => false},
722
- {:type=>"bool", :name=>"da", :ptr? => false, :const? => false, :const_ptr? => false}
723
- ],
724
- :args_string=>"uint la, int de, bool da",
725
- :args_call=>"la, de, da" }
726
- assert_equal(expected, @parser.parse_declaration(source))
727
- end
728
-
729
- it "extract and return function declarations with implied voids" do
730
-
731
- source = "void tat()"
732
- expected = { :var_arg=>nil,
733
- :return=>{ :type => "void",
734
- :name => 'cmock_to_return',
735
- :ptr? => false,
736
- :const? => false,
737
- :const_ptr? => false,
738
- :str => "void cmock_to_return",
739
- :void? => true
740
- },
741
- :name=>"tat",
742
- :modifier=>"",
743
- :contains_ptr? => false,
744
- :args=>[ ],
745
- :args_string=>"void",
746
- :args_call=>"" }
747
- assert_equal(expected, @parser.parse_declaration(source))
748
- end
749
-
750
- it "extract modifiers properly" do
751
-
752
- source = "const int TheMatrix(int Trinity, unsigned int * Neo)"
753
- expected = { :var_arg=>nil,
754
- :return=>{ :type => "int",
755
- :name => 'cmock_to_return',
756
- :ptr? => false,
757
- :const? => true,
758
- :const_ptr? => false,
759
- :str => "int cmock_to_return",
760
- :void? => false
761
- },
762
- :name=>"TheMatrix",
763
- :modifier=>"const",
764
- :contains_ptr? => true,
765
- :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
766
- {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
767
- ],
768
- :args_string=>"int Trinity, unsigned int* Neo",
769
- :args_call=>"Trinity, Neo" }
770
- assert_equal(expected, @parser.parse_declaration(source))
771
- end
772
-
773
- it "extract c calling conventions properly" do
774
-
775
- source = "const int __stdcall TheMatrix(int Trinity, unsigned int * Neo)"
776
- expected = { :var_arg=>nil,
777
- :return=>{ :type => "int",
778
- :name => 'cmock_to_return',
779
- :ptr? => false,
780
- :const? => true,
781
- :const_ptr? => false,
782
- :str => "int cmock_to_return",
783
- :void? => false
784
- },
785
- :name=>"TheMatrix",
786
- :modifier=>"const",
787
- :c_calling_convention=>"__stdcall",
788
- :contains_ptr? => true,
789
- :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
790
- {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
791
- ],
792
- :args_string=>"int Trinity, unsigned int* Neo",
793
- :args_call=>"Trinity, Neo" }
794
- assert_equal(expected, @parser.parse_declaration(source))
795
- end
796
-
797
- it "fully parse multiple prototypes" do
798
-
799
- source = "const int TheMatrix(int Trinity, unsigned int * Neo);\n" +
800
- "int Morpheus(int, unsigned int*);\n"
801
-
802
- expected = [{ :var_arg=>nil,
803
- :return=> { :type => "int",
804
- :name => 'cmock_to_return',
805
- :ptr? => false,
806
- :const? => true,
807
- :const_ptr? => false,
808
- :str => "int cmock_to_return",
809
- :void? => false
810
- },
811
- :name=>"TheMatrix",
812
- :modifier=>"const",
813
- :contains_ptr? => true,
814
- :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
815
- {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
816
- ],
817
- :args_string=>"int Trinity, unsigned int* Neo",
818
- :args_call=>"Trinity, Neo" },
819
- { :var_arg=>nil,
820
- :return=> { :type => "int",
821
- :name => 'cmock_to_return',
822
- :ptr? => false,
823
- :const? => false,
824
- :const_ptr? => false,
825
- :str => "int cmock_to_return",
826
- :void? => false
827
- },
828
- :name=>"Morpheus",
829
- :modifier=>"",
830
- :contains_ptr? => true,
831
- :args=>[ {:type=>"int", :name=>"cmock_arg1", :ptr? => false, :const? => false, :const_ptr? => false},
832
- {:type=>"unsigned int*", :name=>"cmock_arg2", :ptr? => true, :const? => false, :const_ptr? => false}
833
- ],
834
- :args_string=>"int cmock_arg1, unsigned int* cmock_arg2",
835
- :args_call=>"cmock_arg1, cmock_arg2"
836
- }]
837
- assert_equal(expected, @parser.parse("module", source)[:functions])
838
- end
839
-
840
- it "not extract for mocking multiply defined prototypes" do
841
-
842
- source = "const int TheMatrix(int Trinity, unsigned int * Neo);\n" +
843
- "const int TheMatrix(int, unsigned int*);\n"
844
-
845
- expected = [{ :var_arg=>nil,
846
- :name=>"TheMatrix",
847
- :return=> { :type => "int",
848
- :name => 'cmock_to_return',
849
- :ptr? => false,
850
- :const? => true,
851
- :const_ptr? => false,
852
- :str => "int cmock_to_return",
853
- :void? => false
854
- },
855
- :modifier=>"const",
856
- :contains_ptr? => true,
857
- :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
858
- {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
859
- ],
860
- :args_string=>"int Trinity, unsigned int* Neo",
861
- :args_call=>"Trinity, Neo"
862
- }]
863
- assert_equal(expected, @parser.parse("module", source)[:functions])
864
- end
865
-
866
- it "should properly handle const before return type" do
867
- sources = [
868
- "const int * PorkRoast(void);\n",
869
- "const int* PorkRoast(void);\n",
870
- "const int *PorkRoast(void);\n"
871
- ]
872
-
873
- expected = [{ :var_arg => nil,
874
- :name => "PorkRoast",
875
- :return => { :type => "const int*",
876
- :name => 'cmock_to_return',
877
- :ptr? => true,
878
- :const? => true,
879
- :const_ptr? => false,
880
- :str => "const int* cmock_to_return",
881
- :void? => false
882
- },
883
- :modifier => "",
884
- :contains_ptr? => false,
885
- :args => [],
886
- :args_string => "void",
887
- :args_call => ""
888
- }]
889
-
890
- sources.each do |source|
891
- assert_equal(expected, @parser.parse("module", source)[:functions])
892
- end
893
- end
894
-
895
- it "should properly handle const before return type" do
896
- sources = [
897
- "int const * PorkRoast(void);\n",
898
- "int const* PorkRoast(void);\n",
899
- "int const *PorkRoast(void);\n"
900
- ]
901
-
902
- expected = [{ :var_arg => nil,
903
- :name => "PorkRoast",
904
- :return => { :type => "int const*",
905
- :name => 'cmock_to_return',
906
- :ptr? => true,
907
- :const? => true,
908
- :const_ptr? => false,
909
- :str => "int const* cmock_to_return",
910
- :void? => false
911
- },
912
- :modifier => "",
913
- :contains_ptr? => false,
914
- :args => [],
915
- :args_string => "void",
916
- :args_call => ""
917
- }]
918
-
919
- sources.each do |source|
920
- assert_equal(expected, @parser.parse("module", source)[:functions])
921
- end
922
- end
923
-
924
- it "should properly handle const applied after asterisk in return type (not legal C, but sometimes used)" do
925
-
926
- source = "int * const PorkRoast(void);\n"
927
-
928
- expected = [{ :var_arg=>nil,
929
- :name=>"PorkRoast",
930
- :return=> { :type => "int*",
931
- :name => 'cmock_to_return',
932
- :ptr? => true,
933
- :const? => false,
934
- :const_ptr? => true,
935
- :str => "int* cmock_to_return",
936
- :void? => false
937
- },
938
- :modifier=>"const",
939
- :contains_ptr? => false,
940
- :args=>[],
941
- :args_string=>"void",
942
- :args_call=>""
943
- }]
944
- assert_equal(expected, @parser.parse("module", source)[:functions])
945
- end
946
-
947
- it "properly parse const and pointer argument types with no arg names" do
948
-
949
- source = "void foo(int const*, int*const, const int*, const int*const, int const*const, int*, int, const int);\n"
950
-
951
- expected = [{ :name => "foo",
952
- :modifier => "",
953
- :return => { :type => "void",
954
- :name => "cmock_to_return",
955
- :str => "void cmock_to_return",
956
- :void? => true,
957
- :ptr? => false,
958
- :const? => false,
959
- :const_ptr? => false
960
- },
961
- :var_arg => nil,
962
- :args_string => "int const* cmock_arg1, int* const cmock_arg2, const int* cmock_arg3, const int* const cmock_arg4, " +
963
- "int const* const cmock_arg5, int* cmock_arg6, int cmock_arg7, const int cmock_arg8",
964
- :args => [{ :type=>"int const*", :name => "cmock_arg1", :ptr? => true, :const? => true, :const_ptr? => false },
965
- { :type=>"int*", :name => "cmock_arg2", :ptr? => true, :const? => false, :const_ptr? => true },
966
- { :type=>"const int*", :name => "cmock_arg3", :ptr? => true, :const? => true, :const_ptr? => false },
967
- { :type=>"const int*", :name => "cmock_arg4", :ptr? => true, :const? => true, :const_ptr? => true },
968
- { :type=>"int const*", :name => "cmock_arg5", :ptr? => true, :const? => true, :const_ptr? => true },
969
- { :type=>"int*", :name => "cmock_arg6", :ptr? => true, :const? => false, :const_ptr? => false },
970
- { :type=>"int", :name => "cmock_arg7", :ptr? => false, :const? => false, :const_ptr? => false },
971
- { :type=>"int", :name => "cmock_arg8", :ptr? => false, :const? => true, :const_ptr? => false }],
972
- :args_call => "cmock_arg1, cmock_arg2, cmock_arg3, cmock_arg4, cmock_arg5, cmock_arg6, cmock_arg7, cmock_arg8",
973
- :contains_ptr? => true
974
- }]
975
- assert_equal(expected, @parser.parse("module", source)[:functions])
976
- end
977
-
978
- it "properly parse const and pointer argument types with arg names" do
979
-
980
- source = "void bar(int const* param1, int*const param2, const int* param3, const int*const param4,\n" +
981
- " int const*const param5, int*param6, int param7, const int param8);\n"
982
-
983
- expected = [{ :name => "bar",
984
- :modifier => "",
985
- :return => { :type => "void",
986
- :name => "cmock_to_return",
987
- :str => "void cmock_to_return",
988
- :void? => true,
989
- :ptr? => false,
990
- :const? => false,
991
- :const_ptr? => false
992
- },
993
- :var_arg => nil,
994
- :args_string => "int const* param1, int* const param2, const int* param3, const int* const param4, " +
995
- "int const* const param5, int* param6, int param7, const int param8",
996
- :args => [{ :type=>"int const*", :name => "param1", :ptr? => true, :const? => true, :const_ptr? => false },
997
- { :type=>"int*", :name => "param2", :ptr? => true, :const? => false, :const_ptr? => true },
998
- { :type=>"const int*", :name => "param3", :ptr? => true, :const? => true, :const_ptr? => false },
999
- { :type=>"const int*", :name => "param4", :ptr? => true, :const? => true, :const_ptr? => true },
1000
- { :type=>"int const*", :name => "param5", :ptr? => true, :const? => true, :const_ptr? => true },
1001
- { :type=>"int*", :name => "param6", :ptr? => true, :const? => false, :const_ptr? => false },
1002
- { :type=>"int", :name => "param7", :ptr? => false, :const? => false, :const_ptr? => false },
1003
- { :type=>"int", :name => "param8", :ptr? => false, :const? => true, :const_ptr? => false }],
1004
- :args_call => "param1, param2, param3, param4, param5, param6, param7, param8",
1005
- :contains_ptr? => true
1006
- }]
1007
- assert_equal(expected, @parser.parse("module", source)[:functions])
1008
- end
1009
-
1010
- it "converts typedef'd array arguments to pointers" do
1011
-
1012
- source = "Book AddToBook(Book book, const IntArray values);\n"
1013
-
1014
- expected = [{ :name => "AddToBook",
1015
- :modifier=>"",
1016
- :return => { :type => "Book",
1017
- :name => "cmock_to_return",
1018
- :str => "Book cmock_to_return",
1019
- :void? => false,
1020
- :ptr? => false,
1021
- :const? => false,
1022
- :const_ptr? => false
1023
- },
1024
- :var_arg => nil,
1025
- :args => [{ :type => "Page*", :name => "book", :ptr? => true, :const? => false, :const_ptr? => false },
1026
- { :type => "const int*", :name => "values", :ptr? => true, :const? => true, :const_ptr? => false }],
1027
- :args_string => "Book book, const IntArray values",
1028
- :args_call => "book, values",
1029
- :contains_ptr? => true
1030
- }]
1031
-
1032
- assert_equal(expected, @parser.parse("module", source)[:functions])
1033
-
1034
- end
1035
-
1036
- it "properly detect typedef'd variants of void and use those" do
1037
-
1038
- source = "typedef (void) FUNKY_VOID_T;\n" +
1039
- "typedef void CHUNKY_VOID_T;\n" +
1040
- "FUNKY_VOID_T DrHorrible(int SingAlong);\n" +
1041
- "int CaptainHammer(CHUNKY_VOID_T);\n"
1042
-
1043
- expected = [{ :var_arg=>nil,
1044
- :name=>"DrHorrible",
1045
- :return => { :type => "void",
1046
- :name => 'cmock_to_return',
1047
- :ptr? => false,
1048
- :const? => false,
1049
- :const_ptr? => false,
1050
- :str => "void cmock_to_return",
1051
- :void? => true
1052
- },
1053
- :modifier=>"",
1054
- :contains_ptr? => false,
1055
- :args=>[ {:type=>"int", :name=>"SingAlong", :ptr? => false, :const? => false, :const_ptr? => false} ],
1056
- :args_string=>"int SingAlong",
1057
- :args_call=>"SingAlong"
1058
- },
1059
- { :var_arg=>nil,
1060
- :return=> { :type => "int",
1061
- :name => 'cmock_to_return',
1062
- :ptr? => false,
1063
- :const? => false,
1064
- :const_ptr? => false,
1065
- :str => "int cmock_to_return",
1066
- :void? => false
1067
- },
1068
- :name=>"CaptainHammer",
1069
- :modifier=>"",
1070
- :contains_ptr? => false,
1071
- :args=>[ ],
1072
- :args_string=>"void",
1073
- :args_call=>""
1074
- }]
1075
- assert_equal(expected, @parser.parse("module", source)[:functions])
1076
- end
1077
-
1078
- it "be ok with structs inside of function declarations" do
1079
-
1080
- source = "int DrHorrible(struct SingAlong Blog);\n" +
1081
- "void Penny(struct const _KeepYourHeadUp_ * const BillyBuddy);\n" +
1082
- "struct TheseArentTheHammer CaptainHammer(void);\n"
1083
-
1084
- expected = [{ :var_arg=>nil,
1085
- :return =>{ :type => "int",
1086
- :name => 'cmock_to_return',
1087
- :ptr? => false,
1088
- :const? => false,
1089
- :const_ptr? => false,
1090
- :str => "int cmock_to_return",
1091
- :void? => false
1092
- },
1093
- :name=>"DrHorrible",
1094
- :modifier=>"",
1095
- :contains_ptr? => false,
1096
- :args=>[ {:type=>"struct SingAlong", :name=>"Blog", :ptr? => false, :const? => false, :const_ptr? => false} ],
1097
- :args_string=>"struct SingAlong Blog",
1098
- :args_call=>"Blog"
1099
- },
1100
- { :var_arg=>nil,
1101
- :return=> { :type => "void",
1102
- :name => 'cmock_to_return',
1103
- :ptr? => false,
1104
- :const? => false,
1105
- :const_ptr? => false,
1106
- :str => "void cmock_to_return",
1107
- :void? => true
1108
- },
1109
- :name=>"Penny",
1110
- :modifier=>"",
1111
- :contains_ptr? => true,
1112
- :args=>[ {:type=>"struct const _KeepYourHeadUp_*", :name=>"BillyBuddy", :ptr? => true, :const? => true, :const_ptr? => true} ],
1113
- :args_string=>"struct const _KeepYourHeadUp_* const BillyBuddy",
1114
- :args_call=>"BillyBuddy"
1115
- },
1116
- { :var_arg=>nil,
1117
- :return=> { :type => "struct TheseArentTheHammer",
1118
- :name => 'cmock_to_return',
1119
- :ptr? => false,
1120
- :const? => false,
1121
- :const_ptr? => false,
1122
- :str => "struct TheseArentTheHammer cmock_to_return",
1123
- :void? => false
1124
- },
1125
- :name=>"CaptainHammer",
1126
- :modifier=>"",
1127
- :contains_ptr? => false,
1128
- :args=>[ ],
1129
- :args_string=>"void",
1130
- :args_call=>""
1131
- }]
1132
- assert_equal(expected, @parser.parse("module", source)[:functions])
1133
- end
1134
-
1135
- it "extract functions containing unions with union specifier" do
1136
- source = "void OrangePeel(union STARS_AND_STRIPES * a, union AFL_CIO b)"
1137
- expected = [{ :var_arg=>nil,
1138
- :return=>{ :type => "void",
1139
- :name => 'cmock_to_return',
1140
- :ptr? => false,
1141
- :const? => false,
1142
- :const_ptr? => false,
1143
- :str => "void cmock_to_return",
1144
- :void? => true
1145
- },
1146
- :name=>"OrangePeel",
1147
- :modifier=>"",
1148
- :contains_ptr? => true,
1149
- :args=>[ {:type=>"union STARS_AND_STRIPES*", :name=>"a", :ptr? => true, :const? => false, :const_ptr? => false},
1150
- {:type=>"union AFL_CIO", :name=>"b", :ptr? => false, :const? => false, :const_ptr? => false}
1151
- ],
1152
- :args_string=>"union STARS_AND_STRIPES* a, union AFL_CIO b",
1153
- :args_call=>"a, b" }]
1154
- result = @parser.parse("module", source)
1155
- assert_equal(expected, result[:functions])
1156
- end
1157
-
1158
- it "not be thwarted by variables named with primitive types as part of the name" do
1159
- source = "void ApplePeel(const unsigned int const_param, int int_param, int integer, char character, int* const constant)"
1160
- expected = [{ :var_arg=>nil,
1161
- :return=>{ :type => "void",
1162
- :name => 'cmock_to_return',
1163
- :ptr? => false,
1164
- :const? => false,
1165
- :const_ptr? => false,
1166
- :str => "void cmock_to_return",
1167
- :void? => true
1168
- },
1169
- :name=>"ApplePeel",
1170
- :modifier=>"",
1171
- :contains_ptr? => true,
1172
- :args=>[ {:type=> "unsigned int", :name=>"const_param", :ptr? => false, :const? => true, :const_ptr? => false},
1173
- {:type=>"int", :name=>"int_param", :ptr? => false, :const? => false, :const_ptr? => false},
1174
- {:type=>"int", :name=>"integer", :ptr? => false, :const? => false, :const_ptr? => false},
1175
- {:type=>"char", :name=>"character", :ptr? => false, :const? => false, :const_ptr? => false},
1176
- {:type=>"int*", :name=>"constant", :ptr? => true, :const? => false, :const_ptr? => true}
1177
- ],
1178
- :args_string=>"const unsigned int const_param, int int_param, int integer, char character, int* const constant",
1179
- :args_call=>"const_param, int_param, integer, character, constant" }]
1180
- result = @parser.parse("module", source)
1181
- assert_equal(expected, result[:functions])
1182
- end
1183
-
1184
- it "not be thwarted by custom types named similarly to primitive types" do
1185
- source = "void LemonPeel(integer param, character thing, longint * junk, constant value, int32_t const number)"
1186
- expected = [{:var_arg=>nil,
1187
- :return=>{ :type => "void",
1188
- :name => 'cmock_to_return',
1189
- :ptr? => false,
1190
- :const? => false,
1191
- :const_ptr? => false,
1192
- :str => "void cmock_to_return",
1193
- :void? => true
1194
- },
1195
- :name=>"LemonPeel",
1196
- :modifier=>"",
1197
- :contains_ptr? => true,
1198
- :args=>[ {:type=>"integer", :name=>"param", :ptr? => false, :const? => false, :const_ptr? => false},
1199
- {:type=>"character", :name=>"thing", :ptr? => false, :const? => false, :const_ptr? => false},
1200
- {:type=>"longint*", :name=>"junk", :ptr? => true, :const? => false, :const_ptr? => false},
1201
- {:type=>"constant", :name=>"value", :ptr? => false, :const? => false, :const_ptr? => false},
1202
- {:type=>"int32_t", :name=>"number", :ptr? => false, :const? => true, :const_ptr? => false}
1203
- ],
1204
- :args_string=>"integer param, character thing, longint* junk, constant value, int32_t const number",
1205
- :args_call=>"param, thing, junk, value, number" }]
1206
- result = @parser.parse("module", source)
1207
- assert_equal(expected, result[:functions])
1208
- end
1209
-
1210
- it "handle some of those chains of C name specifiers naturally" do
1211
- source = "void CoinOperated(signed char abc, const unsigned long int xyz_123, unsigned int const abc_123, long long arm_of_the_law)"
1212
- expected = [{:var_arg=>nil,
1213
- :return=>{ :type => "void",
1214
- :name => 'cmock_to_return',
1215
- :ptr? => false,
1216
- :const? => false,
1217
- :const_ptr? => false,
1218
- :str => "void cmock_to_return",
1219
- :void? => true
1220
- },
1221
- :name=>"CoinOperated",
1222
- :modifier=>"",
1223
- :contains_ptr? => false,
1224
- :args=>[ {:type=>"signed char", :name=>"abc", :ptr? => false, :const? => false, :const_ptr? => false},
1225
- {:type=>"unsigned long int", :name=>"xyz_123", :ptr? => false, :const? => true, :const_ptr? => false},
1226
- {:type=>"unsigned int", :name=>"abc_123", :ptr? => false, :const? => true, :const_ptr? => false},
1227
- {:type=>"long long", :name=>"arm_of_the_law", :ptr? => false, :const? => false, :const_ptr? => false}
1228
- ],
1229
- :args_string=>"signed char abc, const unsigned long int xyz_123, unsigned int const abc_123, long long arm_of_the_law",
1230
- :args_call=>"abc, xyz_123, abc_123, arm_of_the_law" }]
1231
- result = @parser.parse("module", source)
1232
- assert_equal(expected, result[:functions])
1233
- end
1234
-
1235
- it "handle custom types of various formats" do
1236
- source = "void CardOperated(CUSTOM_TYPE abc, CUSTOM_TYPE* xyz_123, CUSTOM_TYPE const abcxyz, struct CUSTOM_TYPE const * const abc123)"
1237
- expected = [{:var_arg=>nil,
1238
- :return=>{ :type => "void",
1239
- :name => 'cmock_to_return',
1240
- :ptr? => false,
1241
- :const? => false,
1242
- :const_ptr? => false,
1243
- :str => "void cmock_to_return",
1244
- :void? => true
1245
- },
1246
- :name=>"CardOperated",
1247
- :modifier=>"",
1248
- :contains_ptr? => true,
1249
- :args=>[ {:type=>"CUSTOM_TYPE", :name=>"abc", :ptr? => false, :const? => false, :const_ptr? => false},
1250
- {:type=>"CUSTOM_TYPE*", :name=>"xyz_123", :ptr? => true, :const? => false, :const_ptr? => false},
1251
- {:type=>"CUSTOM_TYPE", :name=>"abcxyz", :ptr? => false, :const? => true, :const_ptr? => false},
1252
- {:type=>"struct CUSTOM_TYPE const*", :name=>"abc123", :ptr? => true, :const? => true, :const_ptr? => true}
1253
- ],
1254
- :args_string=>"CUSTOM_TYPE abc, CUSTOM_TYPE* xyz_123, CUSTOM_TYPE const abcxyz, struct CUSTOM_TYPE const* const abc123",
1255
- :args_call=>"abc, xyz_123, abcxyz, abc123" }]
1256
- result = @parser.parse("module", source)
1257
- assert_equal(expected, result[:functions])
1258
- end
1259
-
1260
- it "handle arrays and treat them as pointers or strings" do
1261
- source = "void KeyOperated(CUSTOM_TYPE thing1[], int thing2 [ ], char thing3 [][2 ][ 3], int* thing4[4])"
1262
- expected = [{:var_arg=>nil,
1263
- :return=>{ :type => "void",
1264
- :name => 'cmock_to_return',
1265
- :ptr? => false,
1266
- :const? => false,
1267
- :const_ptr? => false,
1268
- :str => "void cmock_to_return",
1269
- :void? => true
1270
- },
1271
- :name=>"KeyOperated",
1272
- :modifier=>"",
1273
- :contains_ptr? => true,
1274
- :args=>[ {:type=>"CUSTOM_TYPE*", :name=>"thing1", :ptr? => true, :const? => false, :const_ptr? => false},
1275
- {:type=>"int*", :name=>"thing2", :ptr? => true, :const? => false, :const_ptr? => false},
1276
- {:type=>"char*", :name=>"thing3", :ptr? => false, :const? => false, :const_ptr? => false}, #THIS one will likely change in the future when we improve multidimensional array support
1277
- {:type=>"int**", :name=>"thing4", :ptr? => true, :const? => false, :const_ptr? => false} #THIS one will likely change in the future when we improve multidimensional array support
1278
- ],
1279
- :args_string=>"CUSTOM_TYPE* thing1, int* thing2, char* thing3, int** thing4",
1280
- :args_call=>"thing1, thing2, thing3, thing4" }]
1281
- result = @parser.parse("module", source)
1282
- assert_equal(expected, result[:functions])
1283
- end
1284
-
1285
- it "give a reasonable guess when dealing with weird combinations of custom types and modifiers" do
1286
- source = "void Cheese(unsigned CUSTOM_TYPE abc, unsigned xyz, CUSTOM_TYPE1 CUSTOM_TYPE2 pdq)"
1287
- expected = [{:var_arg=>nil,
1288
- :return=>{ :type => "void",
1289
- :name => 'cmock_to_return',
1290
- :ptr? => false,
1291
- :const? => false,
1292
- :const_ptr? => false,
1293
- :str => "void cmock_to_return",
1294
- :void? => true
1295
- },
1296
- :name=>"Cheese",
1297
- :modifier=>"",
1298
- :contains_ptr? => false,
1299
- :args=>[ {:type=>"unsigned CUSTOM_TYPE", :name=>"abc", :ptr? => false, :const? => false, :const_ptr? => false},
1300
- {:type=>"unsigned", :name=>"xyz", :ptr? => false, :const? => false, :const_ptr? => false},
1301
- {:type=>"CUSTOM_TYPE1 CUSTOM_TYPE2", :name=>"pdq", :ptr? => false, :const? => false, :const_ptr? => false}
1302
- ],
1303
- :args_string=>"unsigned CUSTOM_TYPE abc, unsigned xyz, CUSTOM_TYPE1 CUSTOM_TYPE2 pdq",
1304
- :args_call=>"abc, xyz, pdq" }]
1305
- result = @parser.parse("module", source)
1306
- assert_equal(expected, result[:functions])
1307
- end
1308
-
1309
- it "extract functions containing a function pointer" do
1310
- source = "void FunkyTurkey(unsigned int (*func_ptr)(int, char))"
1311
- expected = [{ :var_arg=>nil,
1312
- :return=>{ :type => "void",
1313
- :name => 'cmock_to_return',
1314
- :ptr? => false,
1315
- :const? => false,
1316
- :const_ptr? => false,
1317
- :str => "void cmock_to_return",
1318
- :void? => true
1319
- },
1320
- :name=>"FunkyTurkey",
1321
- :modifier=>"",
1322
- :contains_ptr? => false,
1323
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1324
- ],
1325
- :args_string=>"cmock_module_func_ptr1 func_ptr",
1326
- :args_call=>"func_ptr" }]
1327
- typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char);"]
1328
- result = @parser.parse("module", source)
1329
- assert_equal(expected, result[:functions])
1330
- assert_equal(typedefs, result[:typedefs])
1331
- end
1332
-
1333
- it "extract functions containing a function pointer with a void" do
1334
- source = "void FunkyTurkey(void (*func_ptr)(void))"
1335
- expected = [{ :var_arg=>nil,
1336
- :return=>{ :type => "void",
1337
- :name => 'cmock_to_return',
1338
- :ptr? => false,
1339
- :const? => false,
1340
- :const_ptr? => false,
1341
- :str => "void cmock_to_return",
1342
- :void? => true
1343
- },
1344
- :name=>"FunkyTurkey",
1345
- :modifier=>"",
1346
- :contains_ptr? => false,
1347
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1348
- ],
1349
- :args_string=>"cmock_module_func_ptr1 func_ptr",
1350
- :args_call=>"func_ptr" }]
1351
- typedefs = ["typedef void(*cmock_module_func_ptr1)(void);"]
1352
- result = @parser.parse("module", source)
1353
- assert_equal(expected, result[:functions])
1354
- assert_equal(typedefs, result[:typedefs])
1355
- end
1356
-
1357
- it "extract functions containing a function pointer with an implied void" do
1358
- source = "void FunkyTurkey(unsigned int (*func_ptr)())"
1359
- expected = [{ :var_arg=>nil,
1360
- :return=>{ :type => "void",
1361
- :name => 'cmock_to_return',
1362
- :ptr? => false,
1363
- :const? => false,
1364
- :const_ptr? => false,
1365
- :str => "void cmock_to_return",
1366
- :void? => true
1367
- },
1368
- :name=>"FunkyTurkey",
1369
- :modifier=>"",
1370
- :contains_ptr? => false,
1371
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1372
- ],
1373
- :args_string=>"cmock_module_func_ptr1 func_ptr",
1374
- :args_call=>"func_ptr" }]
1375
- typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)();"]
1376
- result = @parser.parse("module", source)
1377
- assert_equal(expected, result[:functions])
1378
- assert_equal(typedefs, result[:typedefs])
1379
- end
1380
-
1381
- it "extract functions containing a constant function pointer and a pointer in the nested arg list" do
1382
- source = "void FunkyChicken(unsigned int (* const func_ptr)(unsigned long int * , char))"
1383
- expected = [{ :var_arg=>nil,
1384
- :return=>{ :type => "void",
1385
- :name => 'cmock_to_return',
1386
- :ptr? => false,
1387
- :const? => false,
1388
- :const_ptr? => false,
1389
- :str => "void cmock_to_return",
1390
- :void? => true
1391
- },
1392
- :name=>"FunkyChicken",
1393
- :modifier=>"",
1394
- :contains_ptr? => false,
1395
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => true, :const_ptr? => false}
1396
- ],
1397
- :args_string=>"cmock_module_func_ptr1 const func_ptr",
1398
- :args_call=>"func_ptr" }]
1399
- typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(unsigned long int* , char);"]
1400
- result = @parser.parse("module", source)
1401
- assert_equal(expected, result[:functions])
1402
- assert_equal(typedefs, result[:typedefs])
1403
- end
1404
-
1405
- # it "extract functions containing a function pointer taking a vararg" do
1406
- # source = "void FunkyParrot(unsigned int (*func_ptr)(int, char, ...))"
1407
- # expected = [{ :var_arg=>nil,
1408
- # :return=>{ :type => "void",
1409
- # :name => 'cmock_to_return',
1410
- # :ptr? => false,
1411
- # :const? => false,
1412
- # :const_ptr? => false,
1413
- # :str => "void cmock_to_return",
1414
- # :void? => true
1415
- # },
1416
- # :name=>"FunkyParrot",
1417
- # :modifier=>"",
1418
- # :contains_ptr? => false,
1419
- # :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1420
- # ],
1421
- # :args_string=>"cmock_module_func_ptr1 func_ptr",
1422
- # :args_call=>"func_ptr" }]
1423
- # typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char, ...);"]
1424
- # result = @parser.parse("module", source)
1425
- # assert_equal(expected, result[:functions])
1426
- # assert_equal(typedefs, result[:typedefs])
1427
- # end
1428
-
1429
- it "extract functions containing a function pointer with extra parenthesis and two sets" do
1430
- source = "void FunkyBudgie(int (((* func_ptr1)(int, char))), void (*func_ptr2)(void))"
1431
- expected = [{ :var_arg=>nil,
1432
- :return=>{ :type => "void",
1433
- :name => 'cmock_to_return',
1434
- :ptr? => false,
1435
- :const? => false,
1436
- :const_ptr? => false,
1437
- :str => "void cmock_to_return",
1438
- :void? => true
1439
- },
1440
- :name=>"FunkyBudgie",
1441
- :modifier=>"",
1442
- :contains_ptr? => false,
1443
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr1", :ptr? => false, :const? => false, :const_ptr? => false},
1444
- {:type=>"cmock_module_func_ptr2", :name=>"func_ptr2", :ptr? => false, :const? => false, :const_ptr? => false}
1445
- ],
1446
- :args_string=>"cmock_module_func_ptr1 func_ptr1, cmock_module_func_ptr2 func_ptr2",
1447
- :args_call=>"func_ptr1, func_ptr2" }]
1448
- typedefs = ["typedef int(*cmock_module_func_ptr1)(int, char);", "typedef void(*cmock_module_func_ptr2)(void);"]
1449
- result = @parser.parse("module", source)
1450
- assert_equal(expected, result[:functions])
1451
- assert_equal(typedefs, result[:typedefs])
1452
- end
1453
-
1454
- it "extract functions containing a function pointers, structs and other things" do
1455
- source = "struct mytype *FunkyRobin(uint16_t num1, uint16_t num2, void (*func_ptr1)(uint16_t num3, struct mytype2 *s));"
1456
- expected = [{ :var_arg=>nil,
1457
- :return=>{ :type => "struct mytype*",
1458
- :name => 'cmock_to_return',
1459
- :ptr? => true,
1460
- :const? => false,
1461
- :const_ptr? => false,
1462
- :str => "struct mytype* cmock_to_return",
1463
- :void? => false
1464
- },
1465
- :name=>"FunkyRobin",
1466
- :modifier=>"",
1467
- :contains_ptr? => false,
1468
- :args=>[ {:type=>"uint16_t", :name=>"num1", :ptr? => false, :const? => false, :const_ptr? => false},
1469
- {:type=>"uint16_t", :name=>"num2", :ptr? => false, :const? => false, :const_ptr? => false},
1470
- {:type=>"cmock_module_func_ptr1", :name=>"func_ptr1", :ptr? => false, :const? => false, :const_ptr? => false}
1471
- ],
1472
- :args_string=>"uint16_t num1, uint16_t num2, cmock_module_func_ptr1 func_ptr1",
1473
- :args_call=>"num1, num2, func_ptr1" }]
1474
- typedefs = ["typedef void(*cmock_module_func_ptr1)(uint16_t num3, struct mytype2* s);"]
1475
- result = @parser.parse("module", source)
1476
- assert_equal(expected, result[:functions])
1477
- assert_equal(typedefs, result[:typedefs])
1478
- end
1479
-
1480
- it "extract functions containing an anonymous function pointer" do
1481
- source = "void FunkyFowl(unsigned int (* const)(int, char))"
1482
- expected = [{ :var_arg=>nil,
1483
- :return=>{ :type => "void",
1484
- :name => 'cmock_to_return',
1485
- :ptr? => false,
1486
- :const? => false,
1487
- :const_ptr? => false,
1488
- :str => "void cmock_to_return",
1489
- :void? => true
1490
- },
1491
- :name=>"FunkyFowl",
1492
- :modifier=>"",
1493
- :contains_ptr? => false,
1494
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"cmock_arg1", :ptr? => false, :const? => true, :const_ptr? => false}
1495
- ],
1496
- :args_string=>"cmock_module_func_ptr1 const cmock_arg1",
1497
- :args_call=>"cmock_arg1" }]
1498
- typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char);"]
1499
- result = @parser.parse("module", source)
1500
- assert_equal(expected, result[:functions])
1501
- assert_equal(typedefs, result[:typedefs])
1502
- end
1503
-
1504
- it "extract functions returning a function pointer" do
1505
- source = "unsigned short (*FunkyPidgeon( const char op_code ))( int, long int )"
1506
- expected = [{ :var_arg=>nil,
1507
- :return=>{ :type => "cmock_module_func_ptr1",
1508
- :name => 'cmock_to_return',
1509
- :ptr? => false,
1510
- :const? => false,
1511
- :const_ptr? => false,
1512
- :str => "cmock_module_func_ptr1 cmock_to_return",
1513
- :void? => false
1514
- },
1515
- :name=>"FunkyPidgeon",
1516
- :modifier=>"",
1517
- :contains_ptr? => false,
1518
- :args=>[ {:type=>"char", :name=>"op_code", :ptr? => false, :const? => true, :const_ptr? => false}
1519
- ],
1520
- :args_string=>"const char op_code",
1521
- :args_call=>"op_code" }]
1522
- typedefs = ["typedef unsigned short(*cmock_module_func_ptr1)( int, long int );"]
1523
- result = @parser.parse("module", source)
1524
- assert_equal(expected, result[:functions])
1525
- assert_equal(typedefs, result[:typedefs])
1526
- end
1527
-
1528
- it "extract functions returning a function pointer with implied void" do
1529
- source = "unsigned short (*FunkyTweetie())()"
1530
- expected = [{ :var_arg=>nil,
1531
- :return=>{ :type => "cmock_module_func_ptr1",
1532
- :name => 'cmock_to_return',
1533
- :ptr? => false,
1534
- :const? => false,
1535
- :const_ptr? => false,
1536
- :str => "cmock_module_func_ptr1 cmock_to_return",
1537
- :void? => false
1538
- },
1539
- :name=>"FunkyTweetie",
1540
- :modifier=>"",
1541
- :contains_ptr? => false,
1542
- :args=>[],
1543
- :args_string=>"void",
1544
- :args_call=>"" }]
1545
- typedefs = ["typedef unsigned short(*cmock_module_func_ptr1)();"]
1546
- result = @parser.parse("module", source)
1547
- assert_equal(expected, result[:functions])
1548
- assert_equal(typedefs, result[:typedefs])
1549
- end
1550
-
1551
- it "extract functions returning a function pointer where everything is a void" do
1552
- source = "void (* FunkySeaGull(void))(void)"
1553
- expected = [{ :var_arg=>nil,
1554
- :return=>{ :type => "cmock_module_func_ptr1",
1555
- :name => 'cmock_to_return',
1556
- :ptr? => false,
1557
- :const? => false,
1558
- :const_ptr? => false,
1559
- :str => "cmock_module_func_ptr1 cmock_to_return",
1560
- :void? => false
1561
- },
1562
- :name=>"FunkySeaGull",
1563
- :modifier=>"",
1564
- :contains_ptr? => false,
1565
- :args=>[],
1566
- :args_string=>"void",
1567
- :args_call=>"" }]
1568
- typedefs = ["typedef void(*cmock_module_func_ptr1)(void);"]
1569
- result = @parser.parse("module", source)
1570
- assert_equal(expected, result[:functions])
1571
- assert_equal(typedefs, result[:typedefs])
1572
- end
1573
-
1574
- it "extract functions returning a function pointer with some pointer nonsense" do
1575
- source = "unsigned int * (* FunkyMacaw(double* foo, THING *bar))(unsigned int)"
1576
- expected = [{ :var_arg=>nil,
1577
- :return=>{ :type => "cmock_module_func_ptr1",
1578
- :name => 'cmock_to_return',
1579
- :ptr? => false,
1580
- :const? => false,
1581
- :const_ptr? => false,
1582
- :str => "cmock_module_func_ptr1 cmock_to_return",
1583
- :void? => false
1584
- },
1585
- :name=>"FunkyMacaw",
1586
- :modifier=>"",
1587
- :contains_ptr? => true,
1588
- :args=>[ {:type=>"double*", :name=>"foo", :ptr? => true, :const? => false, :const_ptr? => false},
1589
- {:type=>"THING*", :name=>"bar", :ptr? => true, :const? => false, :const_ptr? => false}
1590
- ],
1591
- :args_string=>"double* foo, THING* bar",
1592
- :args_call=>"foo, bar" }]
1593
- typedefs = ["typedef unsigned int *(*cmock_module_func_ptr1)(unsigned int);"]
1594
- result = @parser.parse("module", source)
1595
- assert_equal(expected, result[:functions])
1596
- assert_equal(typedefs, result[:typedefs])
1597
- end
1598
-
1599
- it "extract this SQLite3 function with an anonymous function pointer arg (regression test)" do
1600
- source = "SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*))"
1601
- expected = [{ :var_arg=>nil,
1602
- :return=>{ :type => "int",
1603
- :name => "cmock_to_return",
1604
- :ptr? => false,
1605
- :const? => false,
1606
- :const_ptr? => false,
1607
- :str => "int cmock_to_return",
1608
- :void? => false
1609
- },
1610
- :name=>"sqlite3_bind_text",
1611
- :modifier=>"SQLITE_API",
1612
- :contains_ptr? => true,
1613
- :args=>[ {:type=>"sqlite3_stmt*", :name=>"cmock_arg2", :ptr? => true, :const? => false, :const_ptr? => false},
1614
- {:type=>"int", :name=>"cmock_arg3", :ptr? => false, :const? => false, :const_ptr? => false},
1615
- {:type=>"const char*", :name=>"cmock_arg4", :ptr? => false, :const? => true, :const_ptr? => false},
1616
- {:type=>"int", :name=>"n", :ptr? => false, :const? => false, :const_ptr? => false},
1617
- {:type=>"cmock_module_func_ptr1", :name=>"cmock_arg1", :ptr? => false, :const? => false, :const_ptr? => false}
1618
- ],
1619
- :args_string=>"sqlite3_stmt* cmock_arg2, int cmock_arg3, const char* cmock_arg4, int n, cmock_module_func_ptr1 cmock_arg1",
1620
- :args_call=>"cmock_arg2, cmock_arg3, cmock_arg4, n, cmock_arg1" }]
1621
- typedefs = ["typedef void(*cmock_module_func_ptr1)(void*);"]
1622
- result = @parser.parse("module", source)
1623
- assert_equal(expected, result[:functions])
1624
- assert_equal(typedefs, result[:typedefs])
1625
- end
1626
-
1627
- it "extract functions with varargs" do
1628
- source = "int XFiles(int Scully, int Mulder, ...);\n"
1629
- expected = [{ :var_arg=>"...",
1630
- :return=> { :type => "int",
1631
- :name => 'cmock_to_return',
1632
- :ptr? => false,
1633
- :const? => false,
1634
- :const_ptr? => false,
1635
- :str => "int cmock_to_return",
1636
- :void? => false
1637
- },
1638
- :name=>"XFiles",
1639
- :modifier=>"",
1640
- :contains_ptr? => false,
1641
- :args=>[ {:type=>"int", :name=>"Scully", :ptr? => false, :const? => false, :const_ptr? => false},
1642
- {:type=>"int", :name=>"Mulder", :ptr? => false, :const? => false, :const_ptr? => false}
1643
- ],
1644
- :args_string=>"int Scully, int Mulder",
1645
- :args_call=>"Scully, Mulder"
1646
- }]
1647
- assert_equal(expected, @parser.parse("module", source)[:functions])
1648
- end
1649
-
1650
- it "extract functions with void pointers" do
1651
- source = "void* MoreSillySongs(void* stuff);\n"
1652
- expected = [{ :var_arg=>nil,
1653
- :return=> { :type => "void*",
1654
- :name => 'cmock_to_return',
1655
- :ptr? => true,
1656
- :const? => false,
1657
- :const_ptr? => false,
1658
- :str => "void* cmock_to_return",
1659
- :void? => false
1660
- },
1661
- :name=>"MoreSillySongs",
1662
- :modifier=>"",
1663
- :contains_ptr? => true,
1664
- :args=>[ {:type=>"void*", :name=>"stuff", :ptr? => true, :const? => false, :const_ptr? => false}
1665
- ],
1666
- :args_string=>"void* stuff",
1667
- :args_call=>"stuff"
1668
- }]
1669
- assert_equal(expected, @parser.parse("module", source)[:functions])
1670
- end
1671
-
1672
- it "extract functions with strippable confusing junk like gcc attributes" do
1673
- source = "int LaverneAndShirley(int Lenny, int Squiggy) __attribute__((weak)) __attribute__ ((deprecated));\n"
1674
- expected = [{ :var_arg=>nil,
1675
- :return=> { :type => "int",
1676
- :name => 'cmock_to_return',
1677
- :ptr? => false,
1678
- :const? => false,
1679
- :const_ptr? => false,
1680
- :str => "int cmock_to_return",
1681
- :void? => false
1682
- },
1683
- :name=>"LaverneAndShirley",
1684
- :modifier=>"",
1685
- :contains_ptr? => false,
1686
- :args=>[ {:type=>"int", :name=>"Lenny", :ptr? => false, :const? => false, :const_ptr? => false},
1687
- {:type=>"int", :name=>"Squiggy", :ptr? => false, :const? => false, :const_ptr? => false}
1688
- ],
1689
- :args_string=>"int Lenny, int Squiggy",
1690
- :args_call=>"Lenny, Squiggy"
1691
- }]
1692
- assert_equal(expected, @parser.parse("module", source)[:functions])
1693
- end
1694
-
1695
- it "extract functions with strippable confusing junk like gcc attributes with parenthesis" do
1696
- source = "int TheCosbyShow(int Cliff, int Claire) __attribute__((weak, alias (\"__f\"));\n"
1697
- expected = [{ :var_arg=>nil,
1698
- :return=> { :type => "int",
1699
- :name => 'cmock_to_return',
1700
- :ptr? => false,
1701
- :const? => false,
1702
- :const_ptr? => false,
1703
- :str => "int cmock_to_return",
1704
- :void? => false
1705
- },
1706
- :name=>"TheCosbyShow",
1707
- :modifier=>"",
1708
- :contains_ptr? => false,
1709
- :args=>[ {:type=>"int", :name=>"Cliff", :ptr? => false, :const? => false, :const_ptr? => false},
1710
- {:type=>"int", :name=>"Claire", :ptr? => false, :const? => false, :const_ptr? => false}
1711
- ],
1712
- :args_string=>"int Cliff, int Claire",
1713
- :args_call=>"Cliff, Claire"
1714
- }]
1715
- assert_equal(expected, @parser.parse("module", source)[:functions])
1716
- end
1717
-
1718
- it "divines all permutations of ptr, const, and const_ptr correctly" do
1719
- truth_table = [
1720
- # argument ptr const const_ptr
1721
- [ "constNOTconst constNOTconst", false, false, false ],
1722
- [ "const constNOTconst constNOTconst", false, true, false ],
1723
- [ "constNOTconst const constNOTconst", false, true, false ],
1724
- [ "constNOTconst *constNOTconst", true, false, false ],
1725
- [ "const constNOTconst *constNOTconst", true, true, false ],
1726
- [ "constNOTconst const *constNOTconst", true, true, false ],
1727
- [ "constNOTconst *const constNOTconst", true, false, true ],
1728
- [ "const constNOTconst *const constNOTconst", true, true, true ],
1729
- [ "constNOTconst const *const constNOTconst", true, true, true ],
1730
- [ "constNOTconst **constNOTconst", true, false, false ],
1731
- [ "const constNOTconst **constNOTconst", true, false, false ],
1732
- [ "constNOTconst const **constNOTconst", true, false, false ],
1733
- [ "constNOTconst *const *constNOTconst", true, true, false ],
1734
- [ "const constNOTconst *const *constNOTconst", true, true, false ],
1735
- [ "constNOTconst const *const *constNOTconst", true, true, false ],
1736
- [ "constNOTconst **const constNOTconst", true, false, true ],
1737
- [ "const constNOTconst **const constNOTconst", true, false, true ],
1738
- [ "constNOTconst const **const constNOTconst", true, false, true ],
1739
- [ "constNOTconst *const *const constNOTconst", true, true, true ],
1740
- [ "const constNOTconst *const *const constNOTconst", true, true, true ],
1741
- [ "constNOTconst const *const *const constNOTconst", true, true, true ]
1742
- ]
1743
-
1744
- truth_table.each do |entry|
1745
- assert_equal(@parser.divine_ptr(entry[0]), entry[1])
1746
- assert_equal(@parser.divine_const(entry[0]), entry[2])
1747
- assert_equal(@parser.divine_ptr_and_const(entry[0]),
1748
- { ptr?: entry[1], const?: entry[2], const_ptr?: entry[3] })
1749
- end
1750
- end
1751
-
1752
- it "divines ptr correctly for string types" do
1753
- truth_table = [
1754
- # argument ptr
1755
- [ "char s", false ],
1756
- [ "const char s", false ],
1757
- [ "char const s", false ],
1758
- [ "char *s", false ],
1759
- [ "const char *s", false ],
1760
- [ "char const *s", false ],
1761
- [ "char *const s", false ],
1762
- [ "const char *const s", false ],
1763
- [ "char const *const s", false ],
1764
- [ "char **s", true ],
1765
- [ "const char **s", true ],
1766
- [ "char const **s", true ],
1767
- [ "char *const *s", true ],
1768
- [ "const char *const *s", true ],
1769
- [ "char const *const *s", true ],
1770
- [ "char **const s", true ],
1771
- [ "const char **const s", true ],
1772
- [ "char const **const s", true ],
1773
- [ "char *const *const s", true ],
1774
- [ "const char *const *const s", true ],
1775
- [ "char const *const *const s", true ]
1776
- ]
1777
-
1778
- truth_table.each do |entry|
1779
- assert_equal(@parser.divine_ptr(entry[0]), entry[1])
1780
- end
1781
- end
1782
-
1783
- it "Transform inline functions doesn't change a header with no inlines" do
1784
- source =
1785
- "#ifndef _NOINCLUDES\n" +
1786
- "#define _NOINCLUDES\n" +
1787
- "#include \"unity.h\"\n" +
1788
- "#include \"cmock.h\"\n" +
1789
- "#include \"YetAnotherHeader.h\"\n" +
1790
- "\n" +
1791
- "/* Ignore the following warnings since we are copying code */\n" +
1792
- "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n" +
1793
- "#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 6 || (__GNUC_MINOR__ == 6 && __GNUC_PATCHLEVEL__ > 0)))\n" +
1794
- "#pragma GCC diagnostic push\n" +
1795
- "#endif\n" +
1796
- "#if !defined(__clang__)\n" +
1797
- "#pragma GCC diagnostic ignored \"-Wpragmas\"\n" +
1798
- "#endif\n" +
1799
- "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n" +
1800
- "#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n" +
1801
- "#endif\n" +
1802
- "\n" +
1803
- "struct my_struct {\n" +
1804
- "int a;\n" +
1805
- "int b;\n" +
1806
- "int b;\n" +
1807
- "char c;\n" +
1808
- "};\n" +
1809
- "int my_function(int a);\n" +
1810
- "int my_better_function(struct my_struct *s);\n" +
1811
- "\n" +
1812
- "#endif _NOINCLUDES\n"
1813
-
1814
- assert_equal(source, @parser.transform_inline_functions(source))
1815
- end
1816
-
1817
- it "Transform inline functions changes inline functions to function declarations" do
1818
- source =
1819
- "#ifndef _NOINCLUDES\n" +
1820
- "#define _NOINCLUDES\n" +
1821
- "#include \"unity.h\"\n" +
1822
- "#include \"cmock.h\"\n" +
1823
- "#include \"YetAnotherHeader.h\"\n" +
1824
- "\n" +
1825
- "/* Ignore the following warnings since we are copying code */\n" +
1826
- "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n" +
1827
- "#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 6 || (__GNUC_MINOR__ == 6 && __GNUC_PATCHLEVEL__ > 0)))\n" +
1828
- "#pragma GCC diagnostic push\n" +
1829
- "#endif\n" +
1830
- "#if !defined(__clang__)\n" +
1831
- "#pragma GCC diagnostic ignored \"-Wpragmas\"\n" +
1832
- "#endif\n" +
1833
- "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n" +
1834
- "#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n" +
1835
- "#endif\n" +
1836
- "\n" +
1837
- "struct my_struct {\n" +
1838
- "int a;\n" +
1839
- "int b;\n" +
1840
- "int b;\n" +
1841
- "char c;\n" +
1842
- "};\n" +
1843
- "int my_function(int a);\n" +
1844
- "int my_better_function(struct my_struct *s);\n" +
1845
- "static inline int staticinlinebar(struct my_struct *s)\n" + # This is a function with a lot of indentation levels, we should be able to handle it
1846
- "{\n" +
1847
- "\t{\n" +
1848
- "\t\t{\n" +
1849
- "\t\t\treturn s->a;\n" +
1850
- "\t\t}\n" +
1851
- "\t}\n" +
1852
- "}\n" +
1853
- "static inline int staticinlinefunc(struct my_struct *s)\n" +
1854
- "{\n" +
1855
- " return s->a;\n" +
1856
- "}\n" +
1857
- "int bar(struct my_struct *s);\n" + # A normal function to screw with our parser
1858
- "inline static int inlinestaticfunc(int a) {\n" +
1859
- " return a + 42;\n" +
1860
- "}\n" +
1861
- "inline int StaticInlineFunc(struct my_struct *s)\n" +
1862
- "{\n" +
1863
- " return get_member_a(s) + 42;\n" +
1864
- "}\n" +
1865
- "int inline StaticInlineBar(struct my_struct *s)\n" +
1866
- "{\n" +
1867
- " return get_member_a(s) + 42;\n" +
1868
- "}\n" +
1869
- "struct staticinlinestruct {\n" + # Add a structure declaration between the inline functions, just to make sure we don't touch it!
1870
- "int a;\n" +
1871
- "};\n" +
1872
- "\n" +
1873
- "struct staticinlinestruct fubarstruct(struct my_struct *s);\n" + # Another normal function to screw with our parser
1874
- "static inline struct staticinlinestruct inlinefubarfunction(struct my_struct *s)\n" +
1875
- "{\n" +
1876
- " return (struct staticinlinestruct)*s;\n" +
1877
- "}\n" +
1878
- "int fubar(struct my_struct *s);\n" + # Another normal function to screw with our parser
1879
- "inline int stuff(int num)" +
1880
- "{" +
1881
- " int reg = 0x12;" +
1882
- " if (num > 0)" +
1883
- " {" +
1884
- " reg |= (0x0Eu);" +
1885
- " }" +
1886
- " else" +
1887
- " {" +
1888
- " reg |= (0x07u);" +
1889
- " }" +
1890
- " return reg;" +
1891
- "}" +
1892
- "\n" +
1893
- "int inline static dummy_func_2(int a, char b, float c) {" + # This is a sneaky one, inline static is placed AFTER the return value
1894
- " c += 3.14;" +
1895
- " b -= 32;" +
1896
- " return a + (int)(b) + (int)c;" +
1897
- "}" +
1898
- "#endif _NOINCLUDES\n"
1899
-
1900
- expected =
1901
- "#ifndef _NOINCLUDES\n" +
1902
- "#define _NOINCLUDES\n" +
1903
- "#include \"unity.h\"\n" +
1904
- "#include \"cmock.h\"\n" +
1905
- "#include \"YetAnotherHeader.h\"\n" +
1906
- "\n" +
1907
- "/* Ignore the following warnings since we are copying code */\n" +
1908
- "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n" +
1909
- "#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 6 || (__GNUC_MINOR__ == 6 && __GNUC_PATCHLEVEL__ > 0)))\n" +
1910
- "#pragma GCC diagnostic push\n" +
1911
- "#endif\n" +
1912
- "#if !defined(__clang__)\n" +
1913
- "#pragma GCC diagnostic ignored \"-Wpragmas\"\n" +
1914
- "#endif\n" +
1915
- "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n" +
1916
- "#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n" +
1917
- "#endif\n" +
1918
- "\n" +
1919
- "struct my_struct {\n" +
1920
- "int a;\n" +
1921
- "int b;\n" +
1922
- "int b;\n" +
1923
- "char c;\n" +
1924
- "};\n" +
1925
- "int my_function(int a);\n" +
1926
- "int my_better_function(struct my_struct *s);\n" +
1927
- "int staticinlinebar(struct my_struct *s);\n" +
1928
- "int staticinlinefunc(struct my_struct *s);\n" +
1929
- "int bar(struct my_struct *s);\n" +
1930
- "int inlinestaticfunc(int a);\n" +
1931
- "int StaticInlineFunc(struct my_struct *s);\n" +
1932
- "int StaticInlineBar(struct my_struct *s);\n" +
1933
- "struct staticinlinestruct {\n" +
1934
- "int a;\n" +
1935
- "};\n" +
1936
- "\n" +
1937
- "struct staticinlinestruct fubarstruct(struct my_struct *s);\n" +
1938
- "struct staticinlinestruct inlinefubarfunction(struct my_struct *s);\n" +
1939
- "int fubar(struct my_struct *s);\n" +
1940
- "int stuff(int num);\n" +
1941
- "int dummy_func_2(int a, char b, float c);" +
1942
- "#endif _NOINCLUDES\n"
1943
-
1944
- assert_equal(expected, @parser.transform_inline_functions(source))
1945
- end
1946
-
1947
- it "Count number of pairs of braces in function succesfully" do
1948
- source =
1949
- "int foo(struct my_struct *s)\n" +
1950
- "{\n" +
1951
- " return get_member_a(s) + 42;\n" +
1952
- "}\n"
1953
- complex_source =
1954
- "int bar(struct my_struct *s)\n" +
1955
- "{\n" +
1956
- "\tint a = 6;\n" +
1957
- "\tint res = foo(&(struct my_struct){.nr = a});\n" +
1958
- "\t{\n" +
1959
- "\t\tint a = 5;\n" +
1960
- "\t\tint res = foo(&(struct my_struct){.nr = a});\n" +
1961
- "\t\t{\n" +
1962
- "\t\t\tstruct my_struct a = {.nr = 1};\n" +
1963
- "\t\t}\n" +
1964
- "\t}\n" +
1965
- "\treturn 42;\n" +
1966
- "}\n"
1967
-
1968
- assert_equal(1, @parser.count_number_of_pairs_of_braces_in_function(source))
1969
- assert_equal(6, @parser.count_number_of_pairs_of_braces_in_function(complex_source))
1970
- end
1971
-
1972
- it "Count number of pairs of braces returns 0 if bad source is supplied" do
1973
- bad_source_0 =
1974
- "int foo(struct my_struct *s)\n" +
1975
- "{\n" +
1976
- " return get_member_a(s) + 42;\n" +
1977
- "\n" # Missing closing brace
1978
- bad_source_1 =
1979
- "int bar(struct my_struct *s)\n" +
1980
- "{\n" +
1981
- "\tint a = 6;\n" +
1982
- "\tint res = foo(&(struct my_struct){.nr = a});\n" +
1983
- "\t{\n" +
1984
- "\t\tint a = 5;\n" +
1985
- "\t\tint res = foo(&(struct my_struct){.nr = a});\n" +
1986
- "\t\t{\n" +
1987
- "\t\t\n" + # Missing closing brace
1988
- "\t}\n" +
1989
- "\treturn 42;\n" +
1990
- "}\n"
1991
- bad_source_2 =
1992
- "int foo(struct my_struct *s)\n" +
1993
- "\n" # No braces in source
1994
-
1995
- assert_equal(0, @parser.count_number_of_pairs_of_braces_in_function(bad_source_0))
1996
- assert_equal(0, @parser.count_number_of_pairs_of_braces_in_function(bad_source_1))
1997
- assert_equal(0, @parser.count_number_of_pairs_of_braces_in_function(bad_source_2))
1998
- end
1999
-
2000
- end
1
+ # ==========================================
2
+ # CMock Project - Automatic Mock Generation for C
3
+ # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
4
+ # [Released under MIT License. Please refer to license.txt for details]
5
+ # ==========================================
6
+
7
+ $ThisIsOnlyATest = true
8
+
9
+ require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
10
+ require File.expand_path(File.dirname(__FILE__)) + '/../../lib/cmock_header_parser'
11
+
12
+ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
13
+
14
+ before do
15
+ create_mocks :config
16
+ @test_name = 'test_file.h'
17
+ @config.expect :strippables, ["STRIPPABLE"]
18
+ @config.expect :attributes, ['__ramfunc', 'funky_attrib', 'SQLITE_API']
19
+ @config.expect :c_calling_conventions, ['__stdcall']
20
+ @config.expect :treat_as_void, ['MY_FUNKY_VOID']
21
+ @config.expect :treat_as, { "BANJOS" => "INT", "TUBAS" => "HEX16"}
22
+ @config.expect :treat_as_array, {"IntArray" => "int", "Book" => "Page"}
23
+ @config.expect :when_no_prototypes, :error
24
+ @config.expect :verbosity, 1
25
+ @config.expect :treat_externs, :exclude
26
+ @config.expect :treat_inlines, :exclude
27
+ @config.expect :inline_function_patterns, ['(static\s+inline|inline\s+static)\s*', '(\bstatic\b|\binline\b)\s*']
28
+ @config.expect :array_size_type, ['int', 'size_t']
29
+ @config.expect :array_size_name, 'size|len'
30
+
31
+ @parser = CMockHeaderParser.new(@config)
32
+ end
33
+
34
+ after do
35
+ end
36
+
37
+ it "create and initialize variables to defaults appropriately" do
38
+ assert_equal([], @parser.funcs)
39
+ assert_equal(['const', '__ramfunc', 'funky_attrib', 'SQLITE_API'], @parser.c_attributes)
40
+ assert_equal(['void','MY_FUNKY_VOID'], @parser.treat_as_void)
41
+ end
42
+
43
+ it "strip out line comments" do
44
+ source =
45
+ " abcd;\n" +
46
+ "// hello;\n" +
47
+ "who // is you\n"
48
+
49
+ expected =
50
+ [
51
+ "abcd",
52
+ "who"
53
+ ]
54
+
55
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
56
+ end
57
+
58
+ it "remove block comments" do
59
+ source =
60
+ " no_comments;\n" +
61
+ "// basic_line_comment;\n" +
62
+ "/* basic_block_comment;*/\n" +
63
+ "pre_block; /* start_of_block_comment;\n" +
64
+ "// embedded_line_comment_in_block_comment; */\n" +
65
+ "// /* commented_out_block_comment_line\n" +
66
+ "shown_because_block_comment_invalid_from_line_comment;\n" +
67
+ "// */\n" +
68
+ "//* shorter_commented_out_block_comment_line; \n" +
69
+ "shown_because_block_comment_invalid_from_shorter_line_comment;\n" +
70
+ "/*/\n" +
71
+ "not_shown_because_line_above_started_comment;\n" +
72
+ "//*/\n" +
73
+ "/* \n" +
74
+ "not_shown_because_block_comment_started_this_time;\n" +
75
+ "/*/\n" +
76
+ "shown_because_line_above_ended_comment_this_time;\n" +
77
+ "//*/\n"
78
+
79
+ expected =
80
+ [
81
+ "no_comments",
82
+ "pre_block",
83
+ "shown_because_block_comment_invalid_from_line_comment",
84
+ "shown_because_block_comment_invalid_from_shorter_line_comment",
85
+ "shown_because_line_above_ended_comment_this_time"
86
+ ]
87
+
88
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
89
+ end
90
+
91
+ it "remove strippables from the beginning or end of function declarations" do
92
+ source =
93
+ "void* my_calloc(size_t, size_t) STRIPPABLE;\n" +
94
+ "void\n" +
95
+ " my_realloc(void*, size_t) STRIPPABLE;\n" +
96
+ "extern int\n" +
97
+ " my_printf (void *my_object, const char *my_format, ...)\n" +
98
+ " STRIPPABLE;\n" +
99
+ " void STRIPPABLE universal_handler ();\n"
100
+
101
+ expected =
102
+ [
103
+ "void* my_calloc(size_t, size_t)",
104
+ "void my_realloc(void*, size_t)",
105
+ "void universal_handler()"
106
+ ]
107
+
108
+ assert_equal(expected, @parser.import_source(source))
109
+ end
110
+
111
+ it "remove gcc's function __attribute__'s" do
112
+ source =
113
+ "void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)));\n" +
114
+ "void\n" +
115
+ " my_realloc(void*, size_t) __attribute__((alloc_size(2)));\n" +
116
+ "extern int\n" +
117
+ " my_printf (void *my_object, const char *my_format, ...)\n" +
118
+ " __attribute__ ((format (printf, 2, 3)));\n" +
119
+ " void __attribute__ ((interrupt)) universal_handler ();\n"
120
+
121
+ expected =
122
+ [
123
+ "void* my_calloc(size_t, size_t)",
124
+ "void my_realloc(void*, size_t)",
125
+ "void universal_handler()"
126
+ ]
127
+
128
+ assert_equal(expected, @parser.import_source(source))
129
+ end
130
+
131
+ it "remove preprocessor directives" do
132
+ source =
133
+ "#when stuff_happens\n" +
134
+ "#ifdef _TEST\n" +
135
+ "#pragma stack_switch"
136
+
137
+ expected = []
138
+
139
+ assert_equal(expected, @parser.import_source(source))
140
+ end
141
+
142
+
143
+ it "remove assembler pragma sections" do
144
+ source =
145
+ " #pragma\tasm\n" +
146
+ " .foo\n" +
147
+ " lda %m\n" +
148
+ " nop\n" +
149
+ "# pragma endasm \n" +
150
+ "foo"
151
+
152
+ expected = ["foo"]
153
+
154
+ assert_equal(expected, @parser.import_source(source))
155
+ end
156
+
157
+
158
+ it "smush lines together that contain continuation characters" do
159
+ source =
160
+ "hoo hah \\\n" +
161
+ "when \\ \n"
162
+
163
+ expected =
164
+ [
165
+ "hoo hah when"
166
+ ]
167
+
168
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
169
+ end
170
+
171
+
172
+ it "remove C macro definitions" do
173
+ source =
174
+ "#define this is the first line\\\n" +
175
+ "and the second\\\n" +
176
+ "and the third that should be removed\n" +
177
+ "but I'm here\n"
178
+
179
+ expected = ["but I'm here"]
180
+
181
+ assert_equal(expected, @parser.import_source(source))
182
+ end
183
+
184
+
185
+ it "remove typedef statements" do
186
+ source =
187
+ "typedef uint32 (unsigned int);\n" +
188
+ "const typedef int INT;\n" +
189
+ "int notatypedef;\n" +
190
+ "int typedef_isnt_me;\n" +
191
+ " typedef who cares what really comes here \n" + # exercise multiline typedef
192
+ " continuation;\n" +
193
+ "this should remain!;\n" +
194
+ "typedef blah bleh;\n" +
195
+ "typedef struct shell_command_struct {\n" +
196
+ " char_ptr COMMAND;\n" +
197
+ " int_32 (*SHELL_FUNC)(int_32 argc);\n" +
198
+ "} SHELL_COMMAND_STRUCT, * SHELL_COMMAND_PTR;\n" +
199
+ "typedef struct shell_command_struct {\n" +
200
+ " char_ptr COMMAND;\n" +
201
+ " int_32 (*SHELL_FUNC)(int_32 argc, char_ptr argv[]);\n" +
202
+ "} SHELL_COMMAND_STRUCT, * SHELL_COMMAND_PTR;\n" +
203
+ "typedef struct shell_command_struct {\n" +
204
+ " char_ptr COMMAND;\n" +
205
+ " int_32 (*SHELL_FUNC)(int_32 argc);\n" +
206
+ "};\n"
207
+
208
+ expected =
209
+ [
210
+ "int notatypedef",
211
+ "int typedef_isnt_me",
212
+ "this should remain!"
213
+ ]
214
+
215
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
216
+ end
217
+
218
+
219
+ it "remove enum statements" do
220
+ source =
221
+ "enum _NamedEnum {\n" +
222
+ " THING1 = (0x0001),\n" +
223
+ " THING2 = (0x0001 << 5),\n" +
224
+ "}ListOValues;\n\n" +
225
+ "don't delete me!!\n" +
226
+ " modifier_str enum _NamedEnum {THING1 = (0x0001), THING2 = (0x0001 << 5)} ListOValues;\n\n" +
227
+ "typedef enum {\n" +
228
+ " THING1,\n" +
229
+ " THING2,\n" +
230
+ "} Thinger;\n" +
231
+ "or me!!\n"
232
+
233
+ assert_equal(["don't delete me!! or me!!"], @parser.import_source(source).map!{|s|s.strip})
234
+ end
235
+
236
+
237
+ it "remove union statements" do
238
+ source =
239
+ "union _NamedDoohicky {\n" +
240
+ " unsigned int a;\n" +
241
+ " char b;\n" +
242
+ "} Doohicky;\n\n" +
243
+ "I want to live!!\n" +
244
+ "some_modifier union { unsigned int a; char b;} Whatever;\n" +
245
+ "typedef union {\n" +
246
+ " unsigned int a;\n" +
247
+ " char b;\n" +
248
+ "} Whatever;\n" +
249
+ "me too!!\n"
250
+
251
+ assert_equal(["I want to live!! me too!!"], @parser.import_source(source).map!{|s|s.strip})
252
+ end
253
+
254
+
255
+ it "remove struct statements" do
256
+ source =
257
+ "struct _NamedStruct1 {\n" +
258
+ " unsigned int a;\n" +
259
+ " signed long int b;\n" +
260
+ "} Thing ;\n\n" +
261
+ "extern struct ForwardDeclared_t TestDataType1;\n" +
262
+ "void foo(void);\n" +
263
+ "struct\n"+
264
+ " MultilineForwardDeclared_t\n" +
265
+ " TestDataType2;\n" +
266
+ "struct THINGER foo(void);\n" +
267
+ "typedef struct {\n" +
268
+ " unsigned int a;\n" +
269
+ " signed char b;\n" +
270
+ "}Thinger;\n" +
271
+ "I want to live!!\n"
272
+
273
+ assert_equal(["void foo(void)", "struct THINGER foo(void)", "I want to live!!"],
274
+ @parser.import_source(source).map!{|s|s.strip})
275
+ end
276
+
277
+ it "remove externed and inline functions" do
278
+ source =
279
+ " extern uint32 foobar(unsigned int);\n" +
280
+ "uint32 extern_name_func(unsigned int);\n" +
281
+ "uint32 funcinline(unsigned int);\n" +
282
+ "extern void bar(unsigned int);\n" +
283
+ "inline void bar(unsigned int);\n" +
284
+ "extern\n" +
285
+ "void kinda_ugly_on_the_next_line(unsigned int);\n"
286
+
287
+ expected =
288
+ [
289
+ "uint32 extern_name_func(unsigned int)",
290
+ "uint32 funcinline(unsigned int)"
291
+ ]
292
+
293
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
294
+ end
295
+
296
+ it "remove function definitions but keep function declarations" do
297
+ source =
298
+ "uint32 func_with_decl_a(unsigned int);\n" +
299
+ "uint32 func_with_decl_a(unsigned int a) { return a; }\n" +
300
+ "uint32 func_with_decl_b(unsigned int);\n" +
301
+ "uint32 func_with_decl_b(unsigned int a)\n" +
302
+ "{\n" +
303
+ " bar((unsigned int) a);\n" +
304
+ " stripme(a);\n" +
305
+ "}\n"
306
+
307
+ expected =
308
+ [
309
+ "uint32 func_with_decl_a(unsigned int)",
310
+ "uint32 func_with_decl_a", #okay. it's not going to be interpretted as another function
311
+ "uint32 func_with_decl_b(unsigned int)",
312
+ "uint32 func_with_decl_b", #okay. it's not going to be interpretted as another function
313
+ ]
314
+
315
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
316
+ end
317
+
318
+ it "remove function definitions with nested braces but keep function declarations" do
319
+ source =
320
+ "uint32 func_with_decl_a(unsigned int);\n" +
321
+ "uint32 func_with_decl_a(unsigned int a) {\n" +
322
+ " while (stuff) {\n" +
323
+ " not_a_definition1(void);\n" +
324
+ " }\n" +
325
+ " not_a_definition2(blah, bleh);\n" +
326
+ " return a;\n" +
327
+ "}\n" +
328
+ "uint32 func_with_decl_b(unsigned int);\n" +
329
+ "uint32 func_with_decl_b(unsigned int a)\n" +
330
+ "{\n" +
331
+ " bar((unsigned int) a);\n" +
332
+ " stripme(a);\n" +
333
+ "}\n" +
334
+ "uint32 func_with_decl_c(unsigned int);\n" +
335
+ "uint32 func_with_decl_c(unsigned int a)\n" +
336
+ "{\n" +
337
+ " if(a > 0)\n" +
338
+ " {\n" +
339
+ " return 1;\n" +
340
+ " }\n" +
341
+ " else\n"+
342
+ " {\n" +
343
+ " return 2;\n" +
344
+ " }\n" +
345
+ "}\n"
346
+
347
+ expected =
348
+ [
349
+ "uint32 func_with_decl_a(unsigned int)",
350
+ "uint32 func_with_decl_a", #okay. it's not going to be interpretted as another function
351
+ "uint32 func_with_decl_b(unsigned int)",
352
+ "uint32 func_with_decl_b", #okay. it's not going to be interpretted as another function
353
+ "uint32 func_with_decl_c(unsigned int)",
354
+ "uint32 func_with_decl_c", #okay. it's not going to be interpretted as another function
355
+ ]
356
+
357
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
358
+ end
359
+
360
+ it "remove a fully defined inline function" do
361
+ source =
362
+ "inline void foo(unsigned int a) { oranges = a; }\n" +
363
+ "inline void bar(unsigned int a) { apples = a; };\n" +
364
+ "inline void bar(unsigned int a)\n" +
365
+ "{" +
366
+ " bananas = a;\n" +
367
+ "}"
368
+
369
+ # ensure it's expected type of exception
370
+ assert_raises RuntimeError do
371
+ @parser.parse("module", source)
372
+ end
373
+
374
+ assert_equal([], @parser.funcs)
375
+
376
+ # verify exception message
377
+ begin
378
+ @parser.parse("module", source)
379
+ rescue RuntimeError => e
380
+ assert_equal("ERROR: No function prototypes found!", e.message)
381
+ end
382
+ end
383
+
384
+ it "remove a fully defined inline function that is multiple lines" do
385
+ source =
386
+ "inline void bar(unsigned int a)\n" +
387
+ "{" +
388
+ " bananas = a;\n" +
389
+ " grapes = a;\n" +
390
+ " apples(bananas, grapes);\n" +
391
+ "}"
392
+
393
+ # ensure it's expected type of exception
394
+ assert_raises RuntimeError do
395
+ @parser.parse("module", source)
396
+ end
397
+
398
+ assert_equal([], @parser.funcs)
399
+
400
+ # verify exception message
401
+ begin
402
+ @parser.parse("module", source)
403
+ rescue RuntimeError => e
404
+ assert_equal("ERROR: No function prototypes found!", e.message)
405
+ end
406
+ end
407
+
408
+ it "remove a fully defined inline function that contains nested braces" do
409
+ source =
410
+ "inline void bar(unsigned int a)\n" +
411
+ "{" +
412
+ " apples(bananas, grapes);\n" +
413
+ " if (bananas == a)\n" +
414
+ " {\n" +
415
+ " oranges(a);\n" +
416
+ " grapes = a;\n" +
417
+ " }\n" +
418
+ " grapefruit(bananas, grapes);\n" +
419
+ "}"
420
+
421
+ # ensure it's expected type of exception
422
+ assert_raises RuntimeError do
423
+ @parser.parse("module", source)
424
+ end
425
+
426
+ assert_equal([], @parser.funcs)
427
+
428
+ # verify exception message
429
+ begin
430
+ @parser.parse("module", source)
431
+ rescue RuntimeError => e
432
+ assert_equal("ERROR: No function prototypes found!", e.message)
433
+ end
434
+ end
435
+
436
+ it "remove just inline functions if externs to be included" do
437
+ source =
438
+ " extern uint32 foobar(unsigned int);\n" +
439
+ "uint32 extern_name_func(unsigned int);\n" +
440
+ "uint32 funcinline(unsigned int);\n" +
441
+ "extern void bar(unsigned int);\n" +
442
+ "inline void bar(unsigned int);\n" +
443
+ "extern\n" +
444
+ "void kinda_ugly_on_the_next_line(unsigned int);\n"
445
+
446
+ expected =
447
+ [ "extern uint32 foobar(unsigned int)",
448
+ "uint32 extern_name_func(unsigned int)",
449
+ "uint32 funcinline(unsigned int)",
450
+ "extern void bar(unsigned int)",
451
+ "extern void kinda_ugly_on_the_next_line(unsigned int)"
452
+ ]
453
+
454
+ @parser.treat_externs = :include
455
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
456
+ end
457
+
458
+ it "leave inline functions if inline to be included" do
459
+ source =
460
+ "extern uint32 foobar(unsigned int);\n" +
461
+ "uint32 extern_name_func(unsigned int);\n" +
462
+ "uint32 funcinline(unsigned int);\n" +
463
+ "inline void inlineBar(unsigned int);\n" +
464
+ "extern int extern_bar(void);\n" +
465
+ "static inline void staticinlineBar(unsigned int);\n" +
466
+ "static inline void bar(unsigned int);\n" +
467
+ "static inline void bar(unsigned int)\n" +
468
+ "{\n" +
469
+ " // NOP\n" +
470
+ "}\n"
471
+
472
+ expected =
473
+ [ "uint32 extern_name_func(unsigned int)",
474
+ "uint32 funcinline(unsigned int)",
475
+ "void inlineBar(unsigned int)",
476
+ "void staticinlineBar(unsigned int)",
477
+ "void bar(unsigned int)"
478
+ ]
479
+
480
+ @parser.treat_inlines = :include
481
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
482
+ end
483
+
484
+ it "leave inline and extern functions if inline and extern to be included" do
485
+ source =
486
+ "extern uint32 foobar(unsigned int);\n" +
487
+ "uint32 extern_name_func(unsigned int);\n" +
488
+ "uint32 funcinline(unsigned int);\n" +
489
+ "inline void inlineBar(unsigned int);\n" +
490
+ "extern int extern_bar(void);\n" +
491
+ "static inline void staticinlineBar(unsigned int);\n" +
492
+ "static inline void bar(unsigned int);\n" +
493
+ "static inline void bar(unsigned int)\n" +
494
+ "{\n" +
495
+ " // NOP\n" +
496
+ "}\n"
497
+
498
+ expected =
499
+ [ "extern uint32 foobar(unsigned int)",
500
+ "uint32 extern_name_func(unsigned int)",
501
+ "uint32 funcinline(unsigned int)",
502
+ "void inlineBar(unsigned int)",
503
+ "extern int extern_bar(void)",
504
+ "void staticinlineBar(unsigned int)",
505
+ "void bar(unsigned int)"
506
+ ]
507
+
508
+ @parser.treat_externs = :include
509
+ @parser.treat_inlines = :include
510
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
511
+ end
512
+
513
+ it "Include inline functions that contain user defined inline function formats" do
514
+ source =
515
+ "uint32 foo(unsigned int);\n" +
516
+ "uint32 bar(unsigned int);\n" +
517
+ "inline void inlineBar(void)\n" +
518
+ "{\n" +
519
+ " return 43;\n" +
520
+ "}\n" +
521
+ "static __inline__ __attribute__ ((always_inline)) int alwaysinlinefunc(int a)\n" +
522
+ "{\n" +
523
+ " return a + inlineBar();\n" +
524
+ "}\n" +
525
+ "static __inline__ void inlinebar(unsigned int)\n" +
526
+ "{\n" +
527
+ " int a = alwaysinlinefunc()\n" +
528
+ "}\n"
529
+
530
+ expected =
531
+ [
532
+ "uint32 foo(unsigned int)",
533
+ "uint32 bar(unsigned int)",
534
+ "void inlineBar(void)",
535
+ "int alwaysinlinefunc(int a)",
536
+ "void inlinebar(unsigned int)"
537
+ ]
538
+
539
+ @parser.treat_inlines = :include
540
+ @parser.inline_function_patterns = ['static __inline__ __attribute__ \(\(always_inline\)\)', 'static __inline__', '\binline\b']
541
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
542
+ end
543
+
544
+ it "remove defines" do
545
+ source =
546
+ "#define whatever you feel like defining\n" +
547
+ "void hello(void);\n" +
548
+ "#DEFINE I JUST DON'T CARE\n" +
549
+ "#deFINE\n" +
550
+ "#define get_foo() \\\n ((Thing)foo.bar)" # exercise multiline define
551
+
552
+ expected =
553
+ [
554
+ "void hello(void)",
555
+ ]
556
+
557
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
558
+ end
559
+
560
+
561
+ it "remove keywords that would keep things from going smoothly in the future" do
562
+ source =
563
+ "const int TheMatrix(register int Trinity, unsigned int *restrict Neo)"
564
+
565
+ expected =
566
+ [
567
+ "const int TheMatrix(int Trinity, unsigned int * Neo)",
568
+ ]
569
+
570
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
571
+ end
572
+
573
+
574
+ # some code actually typedef's void even though it's not ANSI C and is, frankly, weird
575
+ # since cmock treats void specially, we can't let void be obfuscated
576
+ it "handle odd case of typedef'd void returned" do
577
+ source = "MY_FUNKY_VOID FunkyVoidReturned(int a)"
578
+ expected = { :var_arg=>nil,
579
+ :name=>"FunkyVoidReturned",
580
+ :unscoped_name=>"FunkyVoidReturned",
581
+ :namespace=>[],
582
+ :class=>nil,
583
+ :return=>{ :type => "void",
584
+ :name => 'cmock_to_return',
585
+ :ptr? => false,
586
+ :const? => false,
587
+ :const_ptr? => false,
588
+ :str => "void cmock_to_return",
589
+ :void? => true
590
+ },
591
+ :modifier=>"",
592
+ :contains_ptr? => false,
593
+ :args=>[{:type=>"int", :name=>"a", :ptr? => false, :const? => false, :const_ptr? => false}],
594
+ :args_string=>"int a",
595
+ :args_call=>"a"}
596
+ assert_equal(expected, @parser.parse_declaration(source))
597
+ end
598
+
599
+ it "handle odd case of typedef'd void as arg" do
600
+ source = "int FunkyVoidAsArg(MY_FUNKY_VOID)"
601
+ expected = { :var_arg=>nil,
602
+ :name=>"FunkyVoidAsArg",
603
+ :unscoped_name=>"FunkyVoidAsArg",
604
+ :namespace=>[],
605
+ :class=>nil,
606
+ :return=>{ :type => "int",
607
+ :name => 'cmock_to_return',
608
+ :ptr? => false,
609
+ :const? => false,
610
+ :const_ptr? => false,
611
+ :str => "int cmock_to_return",
612
+ :void? => false
613
+ },
614
+ :modifier=>"",
615
+ :contains_ptr? => false,
616
+ :args=>[],
617
+ :args_string=>"void",
618
+ :args_call=>"" }
619
+ assert_equal(expected, @parser.parse_declaration(source))
620
+ end
621
+
622
+ it "handle odd case of typedef'd void as arg pointer" do
623
+ source = "char FunkyVoidPointer(MY_FUNKY_VOID* bluh)"
624
+ expected = { :var_arg=>nil,
625
+ :name=>"FunkyVoidPointer",
626
+ :unscoped_name=>"FunkyVoidPointer",
627
+ :namespace=>[],
628
+ :class=>nil,
629
+ :return=>{ :type => "char",
630
+ :name => 'cmock_to_return',
631
+ :ptr? => false,
632
+ :const? => false,
633
+ :const_ptr? => false,
634
+ :str => "char cmock_to_return",
635
+ :void? => false
636
+ },
637
+ :modifier=>"",
638
+ :contains_ptr? => true,
639
+ :args=>[{:type=>"MY_FUNKY_VOID*", :name=>"bluh", :ptr? => true, :const? => false, :const_ptr? => false}],
640
+ :args_string=>"MY_FUNKY_VOID* bluh",
641
+ :args_call=>"bluh" }
642
+ assert_equal(expected, @parser.parse_declaration(source))
643
+ end
644
+
645
+
646
+ it "strip default values from function parameter lists" do
647
+ source =
648
+ "void Foo(int a = 57, float b=37.52, char c= 'd', char* e=\"junk\");\n"
649
+
650
+ expected =
651
+ [
652
+ "void Foo(int a, float b, char c, char* e)"
653
+ ]
654
+
655
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
656
+ end
657
+
658
+
659
+ it "raise upon empty file" do
660
+ source = ''
661
+
662
+ # ensure it's expected type of exception
663
+ assert_raises RuntimeError do
664
+ @parser.parse("module", source)
665
+ end
666
+
667
+ assert_equal([], @parser.funcs)
668
+
669
+ # verify exception message
670
+ begin
671
+ @parser.parse("module", source)
672
+ rescue RuntimeError => e
673
+ assert_equal("ERROR: No function prototypes found!", e.message)
674
+ end
675
+ end
676
+
677
+ it "clean up module names that contain spaces, dashes, and such" do
678
+ source = 'void meh(int (*func)(int));'
679
+
680
+ retval = @parser.parse("C:\Ugly Module-Name", source)
681
+ assert (retval[:typedefs][0] =~ /CUglyModuleName/)
682
+ end
683
+
684
+ it "raise upon no function prototypes found in file" do
685
+ source =
686
+ "typedef void SILLY_VOID_TYPE1;\n" +
687
+ "typedef (void) SILLY_VOID_TYPE2 ;\n" +
688
+ "typedef ( void ) (*FUNCPTR)(void);\n\n" +
689
+ "#define get_foo() \\\n ((Thing)foo.bar)"
690
+
691
+ # ensure it's expected type of exception
692
+ assert_raises(RuntimeError) do
693
+ @parser.parse("module", source)
694
+ end
695
+
696
+ assert_equal([], @parser.funcs)
697
+
698
+ # verify exception message
699
+ begin
700
+ @parser.parse("module", source)
701
+ rescue RuntimeError => e
702
+ assert_equal("ERROR: No function prototypes found!", e.message)
703
+ end
704
+ end
705
+
706
+
707
+ it "raise upon prototype parsing failure" do
708
+ source = "void (int, )"
709
+
710
+ # ensure it's expected type of exception
711
+ assert_raises(RuntimeError) do
712
+ @parser.parse("module", source)
713
+ end
714
+
715
+ # verify exception message
716
+ begin
717
+ @parser.parse("module", source)
718
+ rescue RuntimeError => e
719
+ assert(e.message.include?("Failed Parsing Declaration Prototype!"))
720
+ end
721
+ end
722
+
723
+ it "extract and return function declarations with retval and args" do
724
+
725
+ source = "int Foo(int a, unsigned int b)"
726
+ expected = { :var_arg=>nil,
727
+ :name=>"Foo",
728
+ :unscoped_name=>"Foo",
729
+ :namespace=>[],
730
+ :class=>nil,
731
+ :return=>{ :type => "int",
732
+ :name => 'cmock_to_return',
733
+ :ptr? => false,
734
+ :const? => false,
735
+ :const_ptr? => false,
736
+ :str => "int cmock_to_return",
737
+ :void? => false
738
+ },
739
+ :modifier=>"",
740
+ :contains_ptr? => false,
741
+ :args=>[ {:type=>"int", :name=>"a", :ptr? => false, :const? => false, :const_ptr? => false},
742
+ {:type=>"unsigned int", :name=>"b", :ptr? => false, :const? => false, :const_ptr? => false}
743
+ ],
744
+ :args_string=>"int a, unsigned int b",
745
+ :args_call=>"a, b" }
746
+ assert_equal(expected, @parser.parse_declaration(source))
747
+ end
748
+
749
+ it "extract and return function declarations with no retval" do
750
+
751
+ source = "void FunkyChicken( uint la, int de, bool da)"
752
+ expected = { :var_arg=>nil,
753
+ :return=>{ :type => "void",
754
+ :name => 'cmock_to_return',
755
+ :ptr? => false,
756
+ :const? => false,
757
+ :const_ptr? => false,
758
+ :str => "void cmock_to_return",
759
+ :void? => true
760
+ },
761
+ :name=>"FunkyChicken",
762
+ :unscoped_name=>"FunkyChicken",
763
+ :namespace=>[],
764
+ :class=>nil,
765
+ :modifier=>"",
766
+ :contains_ptr? => false,
767
+ :args=>[ {:type=>"uint", :name=>"la", :ptr? => false, :const? => false, :const_ptr? => false},
768
+ {:type=>"int", :name=>"de", :ptr? => false, :const? => false, :const_ptr? => false},
769
+ {:type=>"bool", :name=>"da", :ptr? => false, :const? => false, :const_ptr? => false}
770
+ ],
771
+ :args_string=>"uint la, int de, bool da",
772
+ :args_call=>"la, de, da" }
773
+ assert_equal(expected, @parser.parse_declaration(source))
774
+ end
775
+
776
+ it "extract and return function declarations with implied voids" do
777
+
778
+ source = "void tat()"
779
+ expected = { :var_arg=>nil,
780
+ :return=>{ :type => "void",
781
+ :name => 'cmock_to_return',
782
+ :ptr? => false,
783
+ :const? => false,
784
+ :const_ptr? => false,
785
+ :str => "void cmock_to_return",
786
+ :void? => true
787
+ },
788
+ :name=>"tat",
789
+ :unscoped_name=>"tat",
790
+ :namespace=>[],
791
+ :class=>nil,
792
+ :modifier=>"",
793
+ :contains_ptr? => false,
794
+ :args=>[ ],
795
+ :args_string=>"void",
796
+ :args_call=>"" }
797
+ assert_equal(expected, @parser.parse_declaration(source))
798
+ end
799
+
800
+ it "extract modifiers properly" do
801
+
802
+ source = "const int TheMatrix(int Trinity, unsigned int * Neo)"
803
+ expected = { :var_arg=>nil,
804
+ :return=>{ :type => "int",
805
+ :name => 'cmock_to_return',
806
+ :ptr? => false,
807
+ :const? => true,
808
+ :const_ptr? => false,
809
+ :str => "int cmock_to_return",
810
+ :void? => false
811
+ },
812
+ :name=>"TheMatrix",
813
+ :unscoped_name=>"TheMatrix",
814
+ :namespace=>[],
815
+ :class=>nil,
816
+ :modifier=>"const",
817
+ :contains_ptr? => true,
818
+ :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
819
+ {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
820
+ ],
821
+ :args_string=>"int Trinity, unsigned int* Neo",
822
+ :args_call=>"Trinity, Neo" }
823
+ assert_equal(expected, @parser.parse_declaration(source))
824
+ end
825
+
826
+ it "extract c calling conventions properly" do
827
+
828
+ source = "const int __stdcall TheMatrix(int Trinity, unsigned int * Neo)"
829
+ expected = { :var_arg=>nil,
830
+ :return=>{ :type => "int",
831
+ :name => 'cmock_to_return',
832
+ :ptr? => false,
833
+ :const? => true,
834
+ :const_ptr? => false,
835
+ :str => "int cmock_to_return",
836
+ :void? => false
837
+ },
838
+ :name=>"TheMatrix",
839
+ :unscoped_name=>"TheMatrix",
840
+ :namespace=>[],
841
+ :class=>nil,
842
+ :modifier=>"const",
843
+ :c_calling_convention=>"__stdcall",
844
+ :contains_ptr? => true,
845
+ :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
846
+ {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
847
+ ],
848
+ :args_string=>"int Trinity, unsigned int* Neo",
849
+ :args_call=>"Trinity, Neo" }
850
+ assert_equal(expected, @parser.parse_declaration(source))
851
+ end
852
+
853
+ it "extract and return function declarations inside namespace and class" do
854
+ source = "int Foo(int a, unsigned int b)"
855
+ expected = { :var_arg=>nil,
856
+ :name=>"ns1_ns2_Bar_Foo",
857
+ :unscoped_name=>"Foo",
858
+ :class=>"Bar",
859
+ :namespace=>["ns1", "ns2"],
860
+ :return=>{ :type => "int",
861
+ :name => 'cmock_to_return',
862
+ :ptr? => false,
863
+ :const? => false,
864
+ :const_ptr? => false,
865
+ :str => "int cmock_to_return",
866
+ :void? => false
867
+ },
868
+ :modifier=>"",
869
+ :contains_ptr? => false,
870
+ :args=>[ {:type=>"int", :name=>"a", :ptr? => false, :const? => false, :const_ptr? => false},
871
+ {:type=>"unsigned int", :name=>"b", :ptr? => false, :const? => false, :const_ptr? => false}
872
+ ],
873
+ :args_string=>"int a, unsigned int b",
874
+ :args_call=>"a, b" }
875
+ assert_equal(expected, @parser.parse_declaration(source, ["ns1", "ns2"], "Bar"))
876
+ end
877
+
878
+ it "fully parse multiple prototypes" do
879
+
880
+ source = "const int TheMatrix(int Trinity, unsigned int * Neo);\n" +
881
+ "int Morpheus(int, unsigned int*);\n"
882
+
883
+ expected = [{ :var_arg=>nil,
884
+ :return=> { :type => "int",
885
+ :name => 'cmock_to_return',
886
+ :ptr? => false,
887
+ :const? => true,
888
+ :const_ptr? => false,
889
+ :str => "int cmock_to_return",
890
+ :void? => false
891
+ },
892
+ :name=>"TheMatrix",
893
+ :unscoped_name=>"TheMatrix",
894
+ :namespace=>[],
895
+ :class=>nil,
896
+ :modifier=>"const",
897
+ :contains_ptr? => true,
898
+ :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
899
+ {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
900
+ ],
901
+ :args_string=>"int Trinity, unsigned int* Neo",
902
+ :args_call=>"Trinity, Neo" },
903
+ { :var_arg=>nil,
904
+ :return=> { :type => "int",
905
+ :name => 'cmock_to_return',
906
+ :ptr? => false,
907
+ :const? => false,
908
+ :const_ptr? => false,
909
+ :str => "int cmock_to_return",
910
+ :void? => false
911
+ },
912
+ :name=>"Morpheus",
913
+ :unscoped_name=>"Morpheus",
914
+ :namespace=>[],
915
+ :class=>nil,
916
+ :modifier=>"",
917
+ :contains_ptr? => true,
918
+ :args=>[ {:type=>"int", :name=>"cmock_arg1", :ptr? => false, :const? => false, :const_ptr? => false},
919
+ {:type=>"unsigned int*", :name=>"cmock_arg2", :ptr? => true, :const? => false, :const_ptr? => false}
920
+ ],
921
+ :args_string=>"int cmock_arg1, unsigned int* cmock_arg2",
922
+ :args_call=>"cmock_arg1, cmock_arg2"
923
+ }]
924
+ assert_equal(expected, @parser.parse("module", source)[:functions])
925
+ end
926
+
927
+ it "not extract for mocking multiply defined prototypes" do
928
+
929
+ source = "const int TheMatrix(int Trinity, unsigned int * Neo);\n" +
930
+ "const int TheMatrix(int, unsigned int*);\n"
931
+
932
+ expected = [{ :var_arg=>nil,
933
+ :name=>"TheMatrix",
934
+ :unscoped_name=>"TheMatrix",
935
+ :namespace=>[],
936
+ :class=>nil,
937
+ :return=> { :type => "int",
938
+ :name => 'cmock_to_return',
939
+ :ptr? => false,
940
+ :const? => true,
941
+ :const_ptr? => false,
942
+ :str => "int cmock_to_return",
943
+ :void? => false
944
+ },
945
+ :modifier=>"const",
946
+ :contains_ptr? => true,
947
+ :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
948
+ {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
949
+ ],
950
+ :args_string=>"int Trinity, unsigned int* Neo",
951
+ :args_call=>"Trinity, Neo"
952
+ }]
953
+ assert_equal(expected, @parser.parse("module", source)[:functions])
954
+ end
955
+
956
+ it "should properly handle const before return type" do
957
+ sources = [
958
+ "const int * PorkRoast(void);\n",
959
+ "const int* PorkRoast(void);\n",
960
+ "const int *PorkRoast(void);\n"
961
+ ]
962
+
963
+ expected = [{ :var_arg => nil,
964
+ :name => "PorkRoast",
965
+ :unscoped_name => "PorkRoast",
966
+ :namespace=>[],
967
+ :class=>nil,
968
+ :return => { :type => "const int*",
969
+ :name => 'cmock_to_return',
970
+ :ptr? => true,
971
+ :const? => true,
972
+ :const_ptr? => false,
973
+ :str => "const int* cmock_to_return",
974
+ :void? => false
975
+ },
976
+ :modifier => "",
977
+ :contains_ptr? => false,
978
+ :args => [],
979
+ :args_string => "void",
980
+ :args_call => ""
981
+ }]
982
+
983
+ sources.each do |source|
984
+ assert_equal(expected, @parser.parse("module", source)[:functions])
985
+ end
986
+ end
987
+
988
+ it "should properly handle const before return type" do
989
+ sources = [
990
+ "int const * PorkRoast(void);\n",
991
+ "int const* PorkRoast(void);\n",
992
+ "int const *PorkRoast(void);\n"
993
+ ]
994
+
995
+ expected = [{ :var_arg => nil,
996
+ :name => "PorkRoast",
997
+ :unscoped_name => "PorkRoast",
998
+ :namespace=>[],
999
+ :class=>nil,
1000
+ :return => { :type => "int const*",
1001
+ :name => 'cmock_to_return',
1002
+ :ptr? => true,
1003
+ :const? => true,
1004
+ :const_ptr? => false,
1005
+ :str => "int const* cmock_to_return",
1006
+ :void? => false
1007
+ },
1008
+ :modifier => "",
1009
+ :contains_ptr? => false,
1010
+ :args => [],
1011
+ :args_string => "void",
1012
+ :args_call => ""
1013
+ }]
1014
+
1015
+ sources.each do |source|
1016
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1017
+ end
1018
+ end
1019
+
1020
+ it "should properly handle const applied after asterisk in return type (not legal C, but sometimes used)" do
1021
+
1022
+ source = "int * const PorkRoast(void);\n"
1023
+
1024
+ expected = [{ :var_arg=>nil,
1025
+ :name=>"PorkRoast",
1026
+ :unscoped_name=>"PorkRoast",
1027
+ :namespace=>[],
1028
+ :class=>nil,
1029
+ :return=> { :type => "int*",
1030
+ :name => 'cmock_to_return',
1031
+ :ptr? => true,
1032
+ :const? => false,
1033
+ :const_ptr? => true,
1034
+ :str => "int* cmock_to_return",
1035
+ :void? => false
1036
+ },
1037
+ :modifier=>"const",
1038
+ :contains_ptr? => false,
1039
+ :args=>[],
1040
+ :args_string=>"void",
1041
+ :args_call=>""
1042
+ }]
1043
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1044
+ end
1045
+
1046
+ it "properly parse const and pointer argument types with no arg names" do
1047
+
1048
+ source = "void foo(int const*, int*const, const int*, const int*const, int const*const, int*, int, const int);\n"
1049
+
1050
+ expected = [{ :name => "foo",
1051
+ :unscoped_name => "foo",
1052
+ :namespace=>[],
1053
+ :class=>nil,
1054
+ :modifier => "",
1055
+ :return => { :type => "void",
1056
+ :name => "cmock_to_return",
1057
+ :str => "void cmock_to_return",
1058
+ :void? => true,
1059
+ :ptr? => false,
1060
+ :const? => false,
1061
+ :const_ptr? => false
1062
+ },
1063
+ :var_arg => nil,
1064
+ :args_string => "int const* cmock_arg1, int* const cmock_arg2, const int* cmock_arg3, const int* const cmock_arg4, " +
1065
+ "int const* const cmock_arg5, int* cmock_arg6, int cmock_arg7, const int cmock_arg8",
1066
+ :args => [{ :type=>"int const*", :name => "cmock_arg1", :ptr? => true, :const? => true, :const_ptr? => false },
1067
+ { :type=>"int*", :name => "cmock_arg2", :ptr? => true, :const? => false, :const_ptr? => true },
1068
+ { :type=>"const int*", :name => "cmock_arg3", :ptr? => true, :const? => true, :const_ptr? => false },
1069
+ { :type=>"const int*", :name => "cmock_arg4", :ptr? => true, :const? => true, :const_ptr? => true },
1070
+ { :type=>"int const*", :name => "cmock_arg5", :ptr? => true, :const? => true, :const_ptr? => true },
1071
+ { :type=>"int*", :name => "cmock_arg6", :ptr? => true, :const? => false, :const_ptr? => false },
1072
+ { :type=>"int", :name => "cmock_arg7", :ptr? => false, :const? => false, :const_ptr? => false },
1073
+ { :type=>"int", :name => "cmock_arg8", :ptr? => false, :const? => true, :const_ptr? => false }],
1074
+ :args_call => "cmock_arg1, cmock_arg2, cmock_arg3, cmock_arg4, cmock_arg5, cmock_arg6, cmock_arg7, cmock_arg8",
1075
+ :contains_ptr? => true
1076
+ }]
1077
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1078
+ end
1079
+
1080
+ it "properly parse const and pointer argument types with arg names" do
1081
+
1082
+ source = "void bar(int const* param1, int*const param2, const int* param3, const int*const param4,\n" +
1083
+ " int const*const param5, int*param6, int param7, const int param8);\n"
1084
+
1085
+ expected = [{ :name => "bar",
1086
+ :unscoped_name => "bar",
1087
+ :namespace=>[],
1088
+ :class=>nil,
1089
+ :modifier => "",
1090
+ :return => { :type => "void",
1091
+ :name => "cmock_to_return",
1092
+ :str => "void cmock_to_return",
1093
+ :void? => true,
1094
+ :ptr? => false,
1095
+ :const? => false,
1096
+ :const_ptr? => false
1097
+ },
1098
+ :var_arg => nil,
1099
+ :args_string => "int const* param1, int* const param2, const int* param3, const int* const param4, " +
1100
+ "int const* const param5, int* param6, int param7, const int param8",
1101
+ :args => [{ :type=>"int const*", :name => "param1", :ptr? => true, :const? => true, :const_ptr? => false },
1102
+ { :type=>"int*", :name => "param2", :ptr? => true, :const? => false, :const_ptr? => true },
1103
+ { :type=>"const int*", :name => "param3", :ptr? => true, :const? => true, :const_ptr? => false },
1104
+ { :type=>"const int*", :name => "param4", :ptr? => true, :const? => true, :const_ptr? => true },
1105
+ { :type=>"int const*", :name => "param5", :ptr? => true, :const? => true, :const_ptr? => true },
1106
+ { :type=>"int*", :name => "param6", :ptr? => true, :const? => false, :const_ptr? => false },
1107
+ { :type=>"int", :name => "param7", :ptr? => false, :const? => false, :const_ptr? => false },
1108
+ { :type=>"int", :name => "param8", :ptr? => false, :const? => true, :const_ptr? => false }],
1109
+ :args_call => "param1, param2, param3, param4, param5, param6, param7, param8",
1110
+ :contains_ptr? => true
1111
+ }].freeze
1112
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1113
+ end
1114
+
1115
+ it "converts typedef'd array arguments to pointers" do
1116
+
1117
+ source = "Book AddToBook(Book book, const IntArray values);\n"
1118
+
1119
+ expected = [{ :name => "AddToBook",
1120
+ :unscoped_name => "AddToBook",
1121
+ :namespace=>[],
1122
+ :class=>nil,
1123
+ :modifier=>"",
1124
+ :return => { :type => "Book",
1125
+ :name => "cmock_to_return",
1126
+ :str => "Book cmock_to_return",
1127
+ :void? => false,
1128
+ :ptr? => false,
1129
+ :const? => false,
1130
+ :const_ptr? => false
1131
+ },
1132
+ :var_arg => nil,
1133
+ :args => [{ :type => "Page*", :name => "book", :ptr? => true, :const? => false, :const_ptr? => false },
1134
+ { :type => "const int*", :name => "values", :ptr? => true, :const? => true, :const_ptr? => false }],
1135
+ :args_string => "Book book, const IntArray values",
1136
+ :args_call => "book, values",
1137
+ :contains_ptr? => true
1138
+ }]
1139
+
1140
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1141
+
1142
+ end
1143
+
1144
+ it "properly detect typedef'd variants of void and use those" do
1145
+
1146
+ source = "typedef (void) FUNKY_VOID_T;\n" +
1147
+ "typedef void CHUNKY_VOID_T;\n" +
1148
+ "FUNKY_VOID_T DrHorrible(int SingAlong);\n" +
1149
+ "int CaptainHammer(CHUNKY_VOID_T);\n"
1150
+
1151
+ expected = [{ :var_arg=>nil,
1152
+ :name=>"DrHorrible",
1153
+ :unscoped_name=>"DrHorrible",
1154
+ :namespace=>[],
1155
+ :class=>nil,
1156
+ :return => { :type => "void",
1157
+ :name => 'cmock_to_return',
1158
+ :ptr? => false,
1159
+ :const? => false,
1160
+ :const_ptr? => false,
1161
+ :str => "void cmock_to_return",
1162
+ :void? => true
1163
+ },
1164
+ :modifier=>"",
1165
+ :contains_ptr? => false,
1166
+ :args=>[ {:type=>"int", :name=>"SingAlong", :ptr? => false, :const? => false, :const_ptr? => false} ],
1167
+ :args_string=>"int SingAlong",
1168
+ :args_call=>"SingAlong"
1169
+ },
1170
+ { :var_arg=>nil,
1171
+ :return=> { :type => "int",
1172
+ :name => 'cmock_to_return',
1173
+ :ptr? => false,
1174
+ :const? => false,
1175
+ :const_ptr? => false,
1176
+ :str => "int cmock_to_return",
1177
+ :void? => false
1178
+ },
1179
+ :name=>"CaptainHammer",
1180
+ :unscoped_name=>"CaptainHammer",
1181
+ :namespace=>[],
1182
+ :class=>nil,
1183
+ :modifier=>"",
1184
+ :contains_ptr? => false,
1185
+ :args=>[ ],
1186
+ :args_string=>"void",
1187
+ :args_call=>""
1188
+ }]
1189
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1190
+ end
1191
+
1192
+ it "be ok with structs inside of function declarations" do
1193
+
1194
+ source = "int DrHorrible(struct SingAlong Blog);\n" +
1195
+ "void Penny(struct const _KeepYourHeadUp_ * const BillyBuddy);\n" +
1196
+ "struct TheseArentTheHammer CaptainHammer(void);\n"
1197
+
1198
+ expected = [{ :var_arg=>nil,
1199
+ :return =>{ :type => "int",
1200
+ :name => 'cmock_to_return',
1201
+ :ptr? => false,
1202
+ :const? => false,
1203
+ :const_ptr? => false,
1204
+ :str => "int cmock_to_return",
1205
+ :void? => false
1206
+ },
1207
+ :name=>"DrHorrible",
1208
+ :unscoped_name=>"DrHorrible",
1209
+ :namespace=>[],
1210
+ :class=>nil,
1211
+ :modifier=>"",
1212
+ :contains_ptr? => false,
1213
+ :args=>[ {:type=>"struct SingAlong", :name=>"Blog", :ptr? => false, :const? => false, :const_ptr? => false} ],
1214
+ :args_string=>"struct SingAlong Blog",
1215
+ :args_call=>"Blog"
1216
+ },
1217
+ { :var_arg=>nil,
1218
+ :return=> { :type => "void",
1219
+ :name => 'cmock_to_return',
1220
+ :ptr? => false,
1221
+ :const? => false,
1222
+ :const_ptr? => false,
1223
+ :str => "void cmock_to_return",
1224
+ :void? => true
1225
+ },
1226
+ :name=>"Penny",
1227
+ :unscoped_name=>"Penny",
1228
+ :namespace=>[],
1229
+ :class=>nil,
1230
+ :modifier=>"",
1231
+ :contains_ptr? => true,
1232
+ :args=>[ {:type=>"struct const _KeepYourHeadUp_*", :name=>"BillyBuddy", :ptr? => true, :const? => true, :const_ptr? => true} ],
1233
+ :args_string=>"struct const _KeepYourHeadUp_* const BillyBuddy",
1234
+ :args_call=>"BillyBuddy"
1235
+ },
1236
+ { :var_arg=>nil,
1237
+ :return=> { :type => "struct TheseArentTheHammer",
1238
+ :name => 'cmock_to_return',
1239
+ :ptr? => false,
1240
+ :const? => false,
1241
+ :const_ptr? => false,
1242
+ :str => "struct TheseArentTheHammer cmock_to_return",
1243
+ :void? => false
1244
+ },
1245
+ :name=>"CaptainHammer",
1246
+ :unscoped_name=>"CaptainHammer",
1247
+ :namespace=>[],
1248
+ :class=>nil,
1249
+ :modifier=>"",
1250
+ :contains_ptr? => false,
1251
+ :args=>[ ],
1252
+ :args_string=>"void",
1253
+ :args_call=>""
1254
+ }]
1255
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1256
+ end
1257
+
1258
+ it "extract functions containing unions with union specifier" do
1259
+ source = "void OrangePeel(union STARS_AND_STRIPES * a, union AFL_CIO b)"
1260
+ expected = [{ :var_arg=>nil,
1261
+ :return=>{ :type => "void",
1262
+ :name => 'cmock_to_return',
1263
+ :ptr? => false,
1264
+ :const? => false,
1265
+ :const_ptr? => false,
1266
+ :str => "void cmock_to_return",
1267
+ :void? => true
1268
+ },
1269
+ :name=>"OrangePeel",
1270
+ :unscoped_name=>"OrangePeel",
1271
+ :namespace=>[],
1272
+ :class=>nil,
1273
+ :modifier=>"",
1274
+ :contains_ptr? => true,
1275
+ :args=>[ {:type=>"union STARS_AND_STRIPES*", :name=>"a", :ptr? => true, :const? => false, :const_ptr? => false},
1276
+ {:type=>"union AFL_CIO", :name=>"b", :ptr? => false, :const? => false, :const_ptr? => false}
1277
+ ],
1278
+ :args_string=>"union STARS_AND_STRIPES* a, union AFL_CIO b",
1279
+ :args_call=>"a, b" }]
1280
+ result = @parser.parse("module", source)
1281
+ assert_equal(expected, result[:functions])
1282
+ end
1283
+
1284
+ it "not be thwarted by variables named with primitive types as part of the name" do
1285
+ source = "void ApplePeel(const unsigned int const_param, int int_param, int integer, char character, int* const constant)"
1286
+ expected = [{ :var_arg=>nil,
1287
+ :return=>{ :type => "void",
1288
+ :name => 'cmock_to_return',
1289
+ :ptr? => false,
1290
+ :const? => false,
1291
+ :const_ptr? => false,
1292
+ :str => "void cmock_to_return",
1293
+ :void? => true
1294
+ },
1295
+ :name=>"ApplePeel",
1296
+ :unscoped_name=>"ApplePeel",
1297
+ :namespace=>[],
1298
+ :class=>nil,
1299
+ :modifier=>"",
1300
+ :contains_ptr? => true,
1301
+ :args=>[ {:type=> "unsigned int", :name=>"const_param", :ptr? => false, :const? => true, :const_ptr? => false},
1302
+ {:type=>"int", :name=>"int_param", :ptr? => false, :const? => false, :const_ptr? => false},
1303
+ {:type=>"int", :name=>"integer", :ptr? => false, :const? => false, :const_ptr? => false},
1304
+ {:type=>"char", :name=>"character", :ptr? => false, :const? => false, :const_ptr? => false},
1305
+ {:type=>"int*", :name=>"constant", :ptr? => true, :const? => false, :const_ptr? => true}
1306
+ ],
1307
+ :args_string=>"const unsigned int const_param, int int_param, int integer, char character, int* const constant",
1308
+ :args_call=>"const_param, int_param, integer, character, constant" }]
1309
+ result = @parser.parse("module", source)
1310
+ assert_equal(expected, result[:functions])
1311
+ end
1312
+
1313
+ it "not be thwarted by custom types named similarly to primitive types" do
1314
+ source = "void LemonPeel(integer param, character thing, longint * junk, constant value, int32_t const number)"
1315
+ expected = [{:var_arg=>nil,
1316
+ :return=>{ :type => "void",
1317
+ :name => 'cmock_to_return',
1318
+ :ptr? => false,
1319
+ :const? => false,
1320
+ :const_ptr? => false,
1321
+ :str => "void cmock_to_return",
1322
+ :void? => true
1323
+ },
1324
+ :name=>"LemonPeel",
1325
+ :unscoped_name=>"LemonPeel",
1326
+ :namespace=>[],
1327
+ :class=>nil,
1328
+ :modifier=>"",
1329
+ :contains_ptr? => true,
1330
+ :args=>[ {:type=>"integer", :name=>"param", :ptr? => false, :const? => false, :const_ptr? => false},
1331
+ {:type=>"character", :name=>"thing", :ptr? => false, :const? => false, :const_ptr? => false},
1332
+ {:type=>"longint*", :name=>"junk", :ptr? => true, :const? => false, :const_ptr? => false},
1333
+ {:type=>"constant", :name=>"value", :ptr? => false, :const? => false, :const_ptr? => false},
1334
+ {:type=>"int32_t", :name=>"number", :ptr? => false, :const? => true, :const_ptr? => false}
1335
+ ],
1336
+ :args_string=>"integer param, character thing, longint* junk, constant value, int32_t const number",
1337
+ :args_call=>"param, thing, junk, value, number" }]
1338
+ result = @parser.parse("module", source)
1339
+ assert_equal(expected, result[:functions])
1340
+ end
1341
+
1342
+ it "handle some of those chains of C name specifiers naturally" do
1343
+ source = "void CoinOperated(signed char abc, const unsigned long int xyz_123, unsigned int const abc_123, long long arm_of_the_law)"
1344
+ expected = [{:var_arg=>nil,
1345
+ :return=>{ :type => "void",
1346
+ :name => 'cmock_to_return',
1347
+ :ptr? => false,
1348
+ :const? => false,
1349
+ :const_ptr? => false,
1350
+ :str => "void cmock_to_return",
1351
+ :void? => true
1352
+ },
1353
+ :name=>"CoinOperated",
1354
+ :unscoped_name=>"CoinOperated",
1355
+ :namespace=>[],
1356
+ :class=>nil,
1357
+ :modifier=>"",
1358
+ :contains_ptr? => false,
1359
+ :args=>[ {:type=>"signed char", :name=>"abc", :ptr? => false, :const? => false, :const_ptr? => false},
1360
+ {:type=>"unsigned long int", :name=>"xyz_123", :ptr? => false, :const? => true, :const_ptr? => false},
1361
+ {:type=>"unsigned int", :name=>"abc_123", :ptr? => false, :const? => true, :const_ptr? => false},
1362
+ {:type=>"long long", :name=>"arm_of_the_law", :ptr? => false, :const? => false, :const_ptr? => false}
1363
+ ],
1364
+ :args_string=>"signed char abc, const unsigned long int xyz_123, unsigned int const abc_123, long long arm_of_the_law",
1365
+ :args_call=>"abc, xyz_123, abc_123, arm_of_the_law" }]
1366
+ result = @parser.parse("module", source)
1367
+ assert_equal(expected, result[:functions])
1368
+ end
1369
+
1370
+ it "handle custom types of various formats" do
1371
+ source = "void CardOperated(CUSTOM_TYPE abc, CUSTOM_TYPE* xyz_123, CUSTOM_TYPE const abcxyz, struct CUSTOM_TYPE const * const abc123)"
1372
+ expected = [{:var_arg=>nil,
1373
+ :return=>{ :type => "void",
1374
+ :name => 'cmock_to_return',
1375
+ :ptr? => false,
1376
+ :const? => false,
1377
+ :const_ptr? => false,
1378
+ :str => "void cmock_to_return",
1379
+ :void? => true
1380
+ },
1381
+ :name=>"CardOperated",
1382
+ :unscoped_name=>"CardOperated",
1383
+ :namespace=>[],
1384
+ :class=>nil,
1385
+ :modifier=>"",
1386
+ :contains_ptr? => true,
1387
+ :args=>[ {:type=>"CUSTOM_TYPE", :name=>"abc", :ptr? => false, :const? => false, :const_ptr? => false},
1388
+ {:type=>"CUSTOM_TYPE*", :name=>"xyz_123", :ptr? => true, :const? => false, :const_ptr? => false},
1389
+ {:type=>"CUSTOM_TYPE", :name=>"abcxyz", :ptr? => false, :const? => true, :const_ptr? => false},
1390
+ {:type=>"struct CUSTOM_TYPE const*", :name=>"abc123", :ptr? => true, :const? => true, :const_ptr? => true}
1391
+ ],
1392
+ :args_string=>"CUSTOM_TYPE abc, CUSTOM_TYPE* xyz_123, CUSTOM_TYPE const abcxyz, struct CUSTOM_TYPE const* const abc123",
1393
+ :args_call=>"abc, xyz_123, abcxyz, abc123" }]
1394
+ result = @parser.parse("module", source)
1395
+ assert_equal(expected, result[:functions])
1396
+ end
1397
+
1398
+ it "handle arrays and treat them as pointers or strings" do
1399
+ source = 'void KeyOperated(CUSTOM_TYPE thing1[], int thing2 [ ], ' \
1400
+ 'char thing3 [][2 ][ 3], int* thing4[4], u8 thing5[((u8)((5 + 5*2)/3))])'
1401
+ expected_args = [
1402
+ { type: 'CUSTOM_TYPE*', name: 'thing1', ptr?: true, const?: false, const_ptr?: false },
1403
+ { type: 'int*', name: 'thing2', ptr?: true, const?: false, const_ptr?: false },
1404
+ # this one will likely change in the future when we improve multidimensional array support
1405
+ { type: 'char*', name: 'thing3', ptr?: false, const?: false, const_ptr?: false },
1406
+ # this one will likely change in the future when we improve multidimensional array support
1407
+ { type: 'int**', name: 'thing4', ptr?: true, const?: false, const_ptr?: false },
1408
+ { type: 'u8*', name: 'thing5', ptr?: true, const?: false, const_ptr?: false }
1409
+ ]
1410
+ expected = [{:var_arg=>nil,
1411
+ :return=>{ :type => "void",
1412
+ :name => 'cmock_to_return',
1413
+ :ptr? => false,
1414
+ :const? => false,
1415
+ :const_ptr? => false,
1416
+ :str => "void cmock_to_return",
1417
+ :void? => true
1418
+ },
1419
+ :name=>"KeyOperated",
1420
+ :unscoped_name=>"KeyOperated",
1421
+ :namespace=>[],
1422
+ :class=>nil,
1423
+ :modifier=>"",
1424
+ :contains_ptr? => true,
1425
+ :args => expected_args,
1426
+ :args_string => 'CUSTOM_TYPE* thing1, int* thing2, ' \
1427
+ 'char* thing3, int** thing4, u8* thing5',
1428
+ :args_call => 'thing1, thing2, thing3, thing4, thing5' }]
1429
+ result = @parser.parse("module", source)
1430
+ assert_equal(expected, result[:functions])
1431
+ end
1432
+
1433
+ it "give a reasonable guess when dealing with weird combinations of custom types and modifiers" do
1434
+ source = "void Cheese(unsigned CUSTOM_TYPE abc, unsigned xyz, CUSTOM_TYPE1 CUSTOM_TYPE2 pdq)"
1435
+ expected = [{:var_arg=>nil,
1436
+ :return=>{ :type => "void",
1437
+ :name => 'cmock_to_return',
1438
+ :ptr? => false,
1439
+ :const? => false,
1440
+ :const_ptr? => false,
1441
+ :str => "void cmock_to_return",
1442
+ :void? => true
1443
+ },
1444
+ :name=>"Cheese",
1445
+ :unscoped_name=>"Cheese",
1446
+ :namespace=>[],
1447
+ :class=>nil,
1448
+ :modifier=>"",
1449
+ :contains_ptr? => false,
1450
+ :args=>[ {:type=>"unsigned CUSTOM_TYPE", :name=>"abc", :ptr? => false, :const? => false, :const_ptr? => false},
1451
+ {:type=>"unsigned", :name=>"xyz", :ptr? => false, :const? => false, :const_ptr? => false},
1452
+ {:type=>"CUSTOM_TYPE1 CUSTOM_TYPE2", :name=>"pdq", :ptr? => false, :const? => false, :const_ptr? => false}
1453
+ ],
1454
+ :args_string=>"unsigned CUSTOM_TYPE abc, unsigned xyz, CUSTOM_TYPE1 CUSTOM_TYPE2 pdq",
1455
+ :args_call=>"abc, xyz, pdq" }]
1456
+ result = @parser.parse("module", source)
1457
+ assert_equal(expected, result[:functions])
1458
+ end
1459
+
1460
+ it "extract functions containing a function pointer" do
1461
+ source = "void FunkyTurkey(unsigned int (*func_ptr)(int, char))"
1462
+ expected = [{ :var_arg=>nil,
1463
+ :return=>{ :type => "void",
1464
+ :name => 'cmock_to_return',
1465
+ :ptr? => false,
1466
+ :const? => false,
1467
+ :const_ptr? => false,
1468
+ :str => "void cmock_to_return",
1469
+ :void? => true
1470
+ },
1471
+ :name=>"FunkyTurkey",
1472
+ :unscoped_name=>"FunkyTurkey",
1473
+ :namespace=>[],
1474
+ :class=>nil,
1475
+ :modifier=>"",
1476
+ :contains_ptr? => false,
1477
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1478
+ ],
1479
+ :args_string=>"cmock_module_func_ptr1 func_ptr",
1480
+ :args_call=>"func_ptr" }]
1481
+ typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char);"]
1482
+ result = @parser.parse("module", source)
1483
+ assert_equal(expected, result[:functions])
1484
+ assert_equal(typedefs, result[:typedefs])
1485
+ end
1486
+
1487
+ it "extract functions using a function pointer with shorthand notation" do
1488
+ source = "void FunkyTurkey(unsigned int func_ptr(int, char))"
1489
+ expected = [{ :var_arg=>nil,
1490
+ :return=>{ :type => "void",
1491
+ :name => 'cmock_to_return',
1492
+ :ptr? => false,
1493
+ :const? => false,
1494
+ :const_ptr? => false,
1495
+ :str => "void cmock_to_return",
1496
+ :void? => true
1497
+ },
1498
+ :name=>"FunkyTurkey",
1499
+ :unscoped_name=>"FunkyTurkey",
1500
+ :namespace=>[],
1501
+ :class=>nil,
1502
+ :modifier=>"",
1503
+ :contains_ptr? => false,
1504
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1505
+ ],
1506
+ :args_string=>"cmock_module_func_ptr1 func_ptr",
1507
+ :args_call=>"func_ptr" }]
1508
+ typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char);"]
1509
+ result = @parser.parse("module", source)
1510
+ assert_equal(expected, result[:functions])
1511
+ assert_equal(typedefs, result[:typedefs])
1512
+ end
1513
+
1514
+ it "extract functions containing a function pointer with a void" do
1515
+ source = "void FunkyTurkey(void (*func_ptr)(void))"
1516
+ expected = [{ :var_arg=>nil,
1517
+ :return=>{ :type => "void",
1518
+ :name => 'cmock_to_return',
1519
+ :ptr? => false,
1520
+ :const? => false,
1521
+ :const_ptr? => false,
1522
+ :str => "void cmock_to_return",
1523
+ :void? => true
1524
+ },
1525
+ :name=>"FunkyTurkey",
1526
+ :unscoped_name=>"FunkyTurkey",
1527
+ :namespace=>[],
1528
+ :class=>nil,
1529
+ :modifier=>"",
1530
+ :contains_ptr? => false,
1531
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1532
+ ],
1533
+ :args_string=>"cmock_module_func_ptr1 func_ptr",
1534
+ :args_call=>"func_ptr" }]
1535
+ typedefs = ["typedef void(*cmock_module_func_ptr1)(void);"]
1536
+ result = @parser.parse("module", source)
1537
+ assert_equal(expected, result[:functions])
1538
+ assert_equal(typedefs, result[:typedefs])
1539
+ end
1540
+
1541
+ it "extract functions containing a function pointer with an implied void" do
1542
+ source = "void FunkyTurkey(unsigned int (*func_ptr)())"
1543
+ expected = [{ :var_arg=>nil,
1544
+ :return=>{ :type => "void",
1545
+ :name => 'cmock_to_return',
1546
+ :ptr? => false,
1547
+ :const? => false,
1548
+ :const_ptr? => false,
1549
+ :str => "void cmock_to_return",
1550
+ :void? => true
1551
+ },
1552
+ :name=>"FunkyTurkey",
1553
+ :unscoped_name=>"FunkyTurkey",
1554
+ :namespace=>[],
1555
+ :class=>nil,
1556
+ :modifier=>"",
1557
+ :contains_ptr? => false,
1558
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1559
+ ],
1560
+ :args_string=>"cmock_module_func_ptr1 func_ptr",
1561
+ :args_call=>"func_ptr" }]
1562
+ typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)();"]
1563
+ result = @parser.parse("module", source)
1564
+ assert_equal(expected, result[:functions])
1565
+ assert_equal(typedefs, result[:typedefs])
1566
+ end
1567
+
1568
+ it "extract functions containing a constant function pointer and a pointer in the nested arg list" do
1569
+ source = "void FunkyChicken(unsigned int (* const func_ptr)(unsigned long int * , char))"
1570
+ expected = [{ :var_arg=>nil,
1571
+ :return=>{ :type => "void",
1572
+ :name => 'cmock_to_return',
1573
+ :ptr? => false,
1574
+ :const? => false,
1575
+ :const_ptr? => false,
1576
+ :str => "void cmock_to_return",
1577
+ :void? => true
1578
+ },
1579
+ :name=>"FunkyChicken",
1580
+ :unscoped_name=>"FunkyChicken",
1581
+ :namespace=>[],
1582
+ :class=>nil,
1583
+ :modifier=>"",
1584
+ :contains_ptr? => false,
1585
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => true, :const_ptr? => false}
1586
+ ],
1587
+ :args_string=>"cmock_module_func_ptr1 const func_ptr",
1588
+ :args_call=>"func_ptr" }]
1589
+ typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(unsigned long int* , char);"]
1590
+ result = @parser.parse("module", source)
1591
+ assert_equal(expected, result[:functions])
1592
+ assert_equal(typedefs, result[:typedefs])
1593
+ end
1594
+
1595
+ # it "extract functions containing a function pointer taking a vararg" do
1596
+ # source = "void FunkyParrot(unsigned int (*func_ptr)(int, char, ...))"
1597
+ # expected = [{ :var_arg=>nil,
1598
+ # :return=>{ :type => "void",
1599
+ # :name => 'cmock_to_return',
1600
+ # :ptr? => false,
1601
+ # :const? => false,
1602
+ # :const_ptr? => false,
1603
+ # :str => "void cmock_to_return",
1604
+ # :void? => true
1605
+ # },
1606
+ # :name=>"FunkyParrot",
1607
+ # :unscoped_name=>"FunkyParrot",
1608
+ # :namespace=>[],
1609
+ # :class=>nil,
1610
+ # :modifier=>"",
1611
+ # :contains_ptr? => false,
1612
+ # :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1613
+ # ],
1614
+ # :args_string=>"cmock_module_func_ptr1 func_ptr",
1615
+ # :args_call=>"func_ptr" }]
1616
+ # typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char, ...);"]
1617
+ # result = @parser.parse("module", source)
1618
+ # assert_equal(expected, result[:functions])
1619
+ # assert_equal(typedefs, result[:typedefs])
1620
+ # end
1621
+
1622
+ it "extract functions containing a function pointer with extra parenthesis and two sets" do
1623
+ source = "void FunkyBudgie(int (((* func_ptr1)(int, char))), void (*func_ptr2)(void))"
1624
+ expected = [{ :var_arg=>nil,
1625
+ :return=>{ :type => "void",
1626
+ :name => 'cmock_to_return',
1627
+ :ptr? => false,
1628
+ :const? => false,
1629
+ :const_ptr? => false,
1630
+ :str => "void cmock_to_return",
1631
+ :void? => true
1632
+ },
1633
+ :name=>"FunkyBudgie",
1634
+ :unscoped_name=>"FunkyBudgie",
1635
+ :namespace=>[],
1636
+ :class=>nil,
1637
+ :modifier=>"",
1638
+ :contains_ptr? => false,
1639
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr1", :ptr? => false, :const? => false, :const_ptr? => false},
1640
+ {:type=>"cmock_module_func_ptr2", :name=>"func_ptr2", :ptr? => false, :const? => false, :const_ptr? => false}
1641
+ ],
1642
+ :args_string=>"cmock_module_func_ptr1 func_ptr1, cmock_module_func_ptr2 func_ptr2",
1643
+ :args_call=>"func_ptr1, func_ptr2" }]
1644
+ typedefs = ["typedef int(*cmock_module_func_ptr1)(int, char);", "typedef void(*cmock_module_func_ptr2)(void);"]
1645
+ result = @parser.parse("module", source)
1646
+ assert_equal(expected, result[:functions])
1647
+ assert_equal(typedefs, result[:typedefs])
1648
+ end
1649
+
1650
+ it "extract functions containing a function pointers, structs and other things" do
1651
+ source = "struct mytype *FunkyRobin(uint16_t num1, uint16_t num2, void (*func_ptr1)(uint16_t num3, struct mytype2 *s));"
1652
+ expected = [{ :var_arg=>nil,
1653
+ :return=>{ :type => "struct mytype*",
1654
+ :name => 'cmock_to_return',
1655
+ :ptr? => true,
1656
+ :const? => false,
1657
+ :const_ptr? => false,
1658
+ :str => "struct mytype* cmock_to_return",
1659
+ :void? => false
1660
+ },
1661
+ :name=>"FunkyRobin",
1662
+ :unscoped_name=>"FunkyRobin",
1663
+ :namespace=>[],
1664
+ :class=>nil,
1665
+ :modifier=>"",
1666
+ :contains_ptr? => false,
1667
+ :args=>[ {:type=>"uint16_t", :name=>"num1", :ptr? => false, :const? => false, :const_ptr? => false},
1668
+ {:type=>"uint16_t", :name=>"num2", :ptr? => false, :const? => false, :const_ptr? => false},
1669
+ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr1", :ptr? => false, :const? => false, :const_ptr? => false}
1670
+ ],
1671
+ :args_string=>"uint16_t num1, uint16_t num2, cmock_module_func_ptr1 func_ptr1",
1672
+ :args_call=>"num1, num2, func_ptr1" }]
1673
+ typedefs = ["typedef void(*cmock_module_func_ptr1)(uint16_t num3, struct mytype2* s);"]
1674
+ result = @parser.parse("module", source)
1675
+ assert_equal(expected, result[:functions])
1676
+ assert_equal(typedefs, result[:typedefs])
1677
+ end
1678
+
1679
+ it "extract functions containing an anonymous function pointer" do
1680
+ source = "void FunkyFowl(unsigned int (* const)(int, char))"
1681
+ expected = [{ :var_arg=>nil,
1682
+ :return=>{ :type => "void",
1683
+ :name => 'cmock_to_return',
1684
+ :ptr? => false,
1685
+ :const? => false,
1686
+ :const_ptr? => false,
1687
+ :str => "void cmock_to_return",
1688
+ :void? => true
1689
+ },
1690
+ :name=>"FunkyFowl",
1691
+ :unscoped_name=>"FunkyFowl",
1692
+ :namespace=>[],
1693
+ :class=>nil,
1694
+ :modifier=>"",
1695
+ :contains_ptr? => false,
1696
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"cmock_arg1", :ptr? => false, :const? => true, :const_ptr? => false}
1697
+ ],
1698
+ :args_string=>"cmock_module_func_ptr1 const cmock_arg1",
1699
+ :args_call=>"cmock_arg1" }]
1700
+ typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char);"]
1701
+ result = @parser.parse("module", source)
1702
+ assert_equal(expected, result[:functions])
1703
+ assert_equal(typedefs, result[:typedefs])
1704
+ end
1705
+
1706
+ it "extract functions returning a function pointer" do
1707
+ source = "unsigned short (*FunkyPidgeon( const char op_code ))( int, long int )"
1708
+ expected = [{ :var_arg=>nil,
1709
+ :return=>{ :type => "cmock_module_func_ptr1",
1710
+ :name => 'cmock_to_return',
1711
+ :ptr? => false,
1712
+ :const? => false,
1713
+ :const_ptr? => false,
1714
+ :str => "cmock_module_func_ptr1 cmock_to_return",
1715
+ :void? => false
1716
+ },
1717
+ :name=>"FunkyPidgeon",
1718
+ :unscoped_name=>"FunkyPidgeon",
1719
+ :namespace=>[],
1720
+ :class=>nil,
1721
+ :modifier=>"",
1722
+ :contains_ptr? => false,
1723
+ :args=>[ {:type=>"char", :name=>"op_code", :ptr? => false, :const? => true, :const_ptr? => false}
1724
+ ],
1725
+ :args_string=>"const char op_code",
1726
+ :args_call=>"op_code" }]
1727
+ typedefs = ["typedef unsigned short(*cmock_module_func_ptr1)( int, long int );"]
1728
+ result = @parser.parse("module", source)
1729
+ assert_equal(expected, result[:functions])
1730
+ assert_equal(typedefs, result[:typedefs])
1731
+ end
1732
+
1733
+ it "extract functions returning a function pointer with implied void" do
1734
+ source = "unsigned short (*FunkyTweetie())()"
1735
+ expected = [{ :var_arg=>nil,
1736
+ :return=>{ :type => "cmock_module_func_ptr1",
1737
+ :name => 'cmock_to_return',
1738
+ :ptr? => false,
1739
+ :const? => false,
1740
+ :const_ptr? => false,
1741
+ :str => "cmock_module_func_ptr1 cmock_to_return",
1742
+ :void? => false
1743
+ },
1744
+ :name=>"FunkyTweetie",
1745
+ :unscoped_name=>"FunkyTweetie",
1746
+ :namespace=>[],
1747
+ :class=>nil,
1748
+ :modifier=>"",
1749
+ :contains_ptr? => false,
1750
+ :args=>[],
1751
+ :args_string=>"void",
1752
+ :args_call=>"" }]
1753
+ typedefs = ["typedef unsigned short(*cmock_module_func_ptr1)();"]
1754
+ result = @parser.parse("module", source)
1755
+ assert_equal(expected, result[:functions])
1756
+ assert_equal(typedefs, result[:typedefs])
1757
+ end
1758
+
1759
+ it "extract functions returning a function pointer where everything is a void" do
1760
+ source = "void (* FunkySeaGull(void))(void)"
1761
+ expected = [{ :var_arg=>nil,
1762
+ :return=>{ :type => "cmock_module_func_ptr1",
1763
+ :name => 'cmock_to_return',
1764
+ :ptr? => false,
1765
+ :const? => false,
1766
+ :const_ptr? => false,
1767
+ :str => "cmock_module_func_ptr1 cmock_to_return",
1768
+ :void? => false
1769
+ },
1770
+ :name=>"FunkySeaGull",
1771
+ :unscoped_name=>"FunkySeaGull",
1772
+ :namespace=>[],
1773
+ :class=>nil,
1774
+ :modifier=>"",
1775
+ :contains_ptr? => false,
1776
+ :args=>[],
1777
+ :args_string=>"void",
1778
+ :args_call=>"" }]
1779
+ typedefs = ["typedef void(*cmock_module_func_ptr1)(void);"]
1780
+ result = @parser.parse("module", source)
1781
+ assert_equal(expected, result[:functions])
1782
+ assert_equal(typedefs, result[:typedefs])
1783
+ end
1784
+
1785
+ it "extract functions returning a function pointer with some pointer nonsense" do
1786
+ source = "unsigned int * (* FunkyMacaw(double* foo, THING *bar))(unsigned int)"
1787
+ expected = [{ :var_arg=>nil,
1788
+ :return=>{ :type => "cmock_module_func_ptr1",
1789
+ :name => 'cmock_to_return',
1790
+ :ptr? => false,
1791
+ :const? => false,
1792
+ :const_ptr? => false,
1793
+ :str => "cmock_module_func_ptr1 cmock_to_return",
1794
+ :void? => false
1795
+ },
1796
+ :name=>"FunkyMacaw",
1797
+ :unscoped_name=>"FunkyMacaw",
1798
+ :namespace=>[],
1799
+ :class=>nil,
1800
+ :modifier=>"",
1801
+ :contains_ptr? => true,
1802
+ :args=>[ {:type=>"double*", :name=>"foo", :ptr? => true, :const? => false, :const_ptr? => false},
1803
+ {:type=>"THING*", :name=>"bar", :ptr? => true, :const? => false, :const_ptr? => false}
1804
+ ],
1805
+ :args_string=>"double* foo, THING* bar",
1806
+ :args_call=>"foo, bar" }]
1807
+ typedefs = ["typedef unsigned int *(*cmock_module_func_ptr1)(unsigned int);"]
1808
+ result = @parser.parse("module", source)
1809
+ assert_equal(expected, result[:functions])
1810
+ assert_equal(typedefs, result[:typedefs])
1811
+ end
1812
+
1813
+ it "extract this SQLite3 function with an anonymous function pointer arg (regression test)" do
1814
+ source = "SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*))"
1815
+ expected = [{ :var_arg=>nil,
1816
+ :return=>{ :type => "int",
1817
+ :name => "cmock_to_return",
1818
+ :ptr? => false,
1819
+ :const? => false,
1820
+ :const_ptr? => false,
1821
+ :str => "int cmock_to_return",
1822
+ :void? => false
1823
+ },
1824
+ :name=>"sqlite3_bind_text",
1825
+ :unscoped_name=>"sqlite3_bind_text",
1826
+ :namespace=>[],
1827
+ :class=>nil,
1828
+ :modifier=>"SQLITE_API",
1829
+ :contains_ptr? => true,
1830
+ :args=>[ {:type=>"sqlite3_stmt*", :name=>"cmock_arg2", :ptr? => true, :const? => false, :const_ptr? => false},
1831
+ {:type=>"int", :name=>"cmock_arg3", :ptr? => false, :const? => false, :const_ptr? => false},
1832
+ {:type=>"const char*", :name=>"cmock_arg4", :ptr? => false, :const? => true, :const_ptr? => false},
1833
+ {:type=>"int", :name=>"n", :ptr? => false, :const? => false, :const_ptr? => false},
1834
+ {:type=>"cmock_module_func_ptr1", :name=>"cmock_arg1", :ptr? => false, :const? => false, :const_ptr? => false}
1835
+ ],
1836
+ :args_string=>"sqlite3_stmt* cmock_arg2, int cmock_arg3, const char* cmock_arg4, int n, cmock_module_func_ptr1 cmock_arg1",
1837
+ :args_call=>"cmock_arg2, cmock_arg3, cmock_arg4, n, cmock_arg1" }]
1838
+ typedefs = ["typedef void(*cmock_module_func_ptr1)(void*);"]
1839
+ result = @parser.parse("module", source)
1840
+ assert_equal(expected, result[:functions])
1841
+ assert_equal(typedefs, result[:typedefs])
1842
+ end
1843
+
1844
+ it "extract functions with varargs" do
1845
+ source = "int XFiles(int Scully, int Mulder, ...);\n"
1846
+ expected = [{ :var_arg=>"...",
1847
+ :return=> { :type => "int",
1848
+ :name => 'cmock_to_return',
1849
+ :ptr? => false,
1850
+ :const? => false,
1851
+ :const_ptr? => false,
1852
+ :str => "int cmock_to_return",
1853
+ :void? => false
1854
+ },
1855
+ :name=>"XFiles",
1856
+ :unscoped_name=>"XFiles",
1857
+ :namespace=>[],
1858
+ :class=>nil,
1859
+ :modifier=>"",
1860
+ :contains_ptr? => false,
1861
+ :args=>[ {:type=>"int", :name=>"Scully", :ptr? => false, :const? => false, :const_ptr? => false},
1862
+ {:type=>"int", :name=>"Mulder", :ptr? => false, :const? => false, :const_ptr? => false}
1863
+ ],
1864
+ :args_string=>"int Scully, int Mulder",
1865
+ :args_call=>"Scully, Mulder"
1866
+ }]
1867
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1868
+ end
1869
+
1870
+ it "extract functions with void pointers" do
1871
+ source = "void* MoreSillySongs(void* stuff);\n"
1872
+ expected = [{ :var_arg=>nil,
1873
+ :return=> { :type => "void*",
1874
+ :name => 'cmock_to_return',
1875
+ :ptr? => true,
1876
+ :const? => false,
1877
+ :const_ptr? => false,
1878
+ :str => "void* cmock_to_return",
1879
+ :void? => false
1880
+ },
1881
+ :name=>"MoreSillySongs",
1882
+ :unscoped_name=>"MoreSillySongs",
1883
+ :namespace=>[],
1884
+ :class=>nil,
1885
+ :modifier=>"",
1886
+ :contains_ptr? => true,
1887
+ :args=>[ {:type=>"void*", :name=>"stuff", :ptr? => true, :const? => false, :const_ptr? => false}
1888
+ ],
1889
+ :args_string=>"void* stuff",
1890
+ :args_call=>"stuff"
1891
+ }]
1892
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1893
+ end
1894
+
1895
+ it "extract functions with strippable confusing junk like gcc attributes" do
1896
+ source = "int LaverneAndShirley(int Lenny, int Squiggy) __attribute__((weak)) __attribute__ ((deprecated));\n"
1897
+ expected = [{ :var_arg=>nil,
1898
+ :return=> { :type => "int",
1899
+ :name => 'cmock_to_return',
1900
+ :ptr? => false,
1901
+ :const? => false,
1902
+ :const_ptr? => false,
1903
+ :str => "int cmock_to_return",
1904
+ :void? => false
1905
+ },
1906
+ :name=>"LaverneAndShirley",
1907
+ :unscoped_name=>"LaverneAndShirley",
1908
+ :namespace=>[],
1909
+ :class=>nil,
1910
+ :modifier=>"",
1911
+ :contains_ptr? => false,
1912
+ :args=>[ {:type=>"int", :name=>"Lenny", :ptr? => false, :const? => false, :const_ptr? => false},
1913
+ {:type=>"int", :name=>"Squiggy", :ptr? => false, :const? => false, :const_ptr? => false}
1914
+ ],
1915
+ :args_string=>"int Lenny, int Squiggy",
1916
+ :args_call=>"Lenny, Squiggy"
1917
+ }]
1918
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1919
+ end
1920
+
1921
+ it "extract functions with strippable confusing junk like gcc attributes with parenthesis" do
1922
+ source = "int TheCosbyShow(int Cliff, int Claire) __attribute__((weak, alias (\"__f\"));\n"
1923
+ expected = [{ :var_arg=>nil,
1924
+ :return=> { :type => "int",
1925
+ :name => 'cmock_to_return',
1926
+ :ptr? => false,
1927
+ :const? => false,
1928
+ :const_ptr? => false,
1929
+ :str => "int cmock_to_return",
1930
+ :void? => false
1931
+ },
1932
+ :name=>"TheCosbyShow",
1933
+ :unscoped_name=>"TheCosbyShow",
1934
+ :namespace=>[],
1935
+ :class=>nil,
1936
+ :modifier=>"",
1937
+ :contains_ptr? => false,
1938
+ :args=>[ {:type=>"int", :name=>"Cliff", :ptr? => false, :const? => false, :const_ptr? => false},
1939
+ {:type=>"int", :name=>"Claire", :ptr? => false, :const? => false, :const_ptr? => false}
1940
+ ],
1941
+ :args_string=>"int Cliff, int Claire",
1942
+ :args_call=>"Cliff, Claire"
1943
+ }]
1944
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1945
+ end
1946
+
1947
+ it "divines all permutations of ptr, const, and const_ptr correctly" do
1948
+ truth_table = [
1949
+ # argument ptr const const_ptr
1950
+ [ "constNOTconst constNOTconst", false, false, false ],
1951
+ [ "const constNOTconst constNOTconst", false, true, false ],
1952
+ [ "constNOTconst const constNOTconst", false, true, false ],
1953
+ [ "constNOTconst *constNOTconst", true, false, false ],
1954
+ [ "const constNOTconst *constNOTconst", true, true, false ],
1955
+ [ "constNOTconst const *constNOTconst", true, true, false ],
1956
+ [ "constNOTconst *const constNOTconst", true, false, true ],
1957
+ [ "const constNOTconst *const constNOTconst", true, true, true ],
1958
+ [ "constNOTconst const *const constNOTconst", true, true, true ],
1959
+ [ "constNOTconst **constNOTconst", true, false, false ],
1960
+ [ "const constNOTconst **constNOTconst", true, false, false ],
1961
+ [ "constNOTconst const **constNOTconst", true, false, false ],
1962
+ [ "constNOTconst *const *constNOTconst", true, true, false ],
1963
+ [ "const constNOTconst *const *constNOTconst", true, true, false ],
1964
+ [ "constNOTconst const *const *constNOTconst", true, true, false ],
1965
+ [ "constNOTconst **const constNOTconst", true, false, true ],
1966
+ [ "const constNOTconst **const constNOTconst", true, false, true ],
1967
+ [ "constNOTconst const **const constNOTconst", true, false, true ],
1968
+ [ "constNOTconst *const *const constNOTconst", true, true, true ],
1969
+ [ "const constNOTconst *const *const constNOTconst", true, true, true ],
1970
+ [ "constNOTconst const *const *const constNOTconst", true, true, true ]
1971
+ ]
1972
+
1973
+ truth_table.each do |entry|
1974
+ assert_equal(@parser.divine_ptr(entry[0]), entry[1])
1975
+ assert_equal(@parser.divine_const(entry[0]), entry[2])
1976
+ assert_equal(@parser.divine_ptr_and_const(entry[0]),
1977
+ { ptr?: entry[1], const?: entry[2], const_ptr?: entry[3] })
1978
+ end
1979
+ end
1980
+
1981
+ it "divines ptr correctly for string types" do
1982
+ truth_table = [
1983
+ # argument ptr
1984
+ [ "char s", false ],
1985
+ [ "const char s", false ],
1986
+ [ "char const s", false ],
1987
+ [ "char *s", false ],
1988
+ [ "const char *s", false ],
1989
+ [ "char const *s", false ],
1990
+ [ "char *const s", false ],
1991
+ [ "const char *const s", false ],
1992
+ [ "char const *const s", false ],
1993
+ [ "char **s", true ],
1994
+ [ "const char **s", true ],
1995
+ [ "char const **s", true ],
1996
+ [ "char *const *s", true ],
1997
+ [ "const char *const *s", true ],
1998
+ [ "char const *const *s", true ],
1999
+ [ "char **const s", true ],
2000
+ [ "const char **const s", true ],
2001
+ [ "char const **const s", true ],
2002
+ [ "char *const *const s", true ],
2003
+ [ "const char *const *const s", true ],
2004
+ [ "char const *const *const s", true ]
2005
+ ]
2006
+
2007
+ truth_table.each do |entry|
2008
+ assert_equal(@parser.divine_ptr(entry[0]), entry[1])
2009
+ end
2010
+ end
2011
+
2012
+ it "Transform inline functions doesn't change a header with no inlines" do
2013
+ source =
2014
+ "#ifndef _NOINCLUDES\n" +
2015
+ "#define _NOINCLUDES\n" +
2016
+ "#include \"unity.h\"\n" +
2017
+ "#include \"cmock.h\"\n" +
2018
+ "#include \"YetAnotherHeader.h\"\n" +
2019
+ "\n" +
2020
+ "/* Ignore the following warnings since we are copying code */\n" +
2021
+ "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n" +
2022
+ "#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 6 || (__GNUC_MINOR__ == 6 && __GNUC_PATCHLEVEL__ > 0)))\n" +
2023
+ "#pragma GCC diagnostic push\n" +
2024
+ "#endif\n" +
2025
+ "#if !defined(__clang__)\n" +
2026
+ "#pragma GCC diagnostic ignored \"-Wpragmas\"\n" +
2027
+ "#endif\n" +
2028
+ "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n" +
2029
+ "#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n" +
2030
+ "#endif\n" +
2031
+ "\n" +
2032
+ "struct my_struct {\n" +
2033
+ "int a;\n" +
2034
+ "int b;\n" +
2035
+ "int b;\n" +
2036
+ "char c;\n" +
2037
+ "};\n" +
2038
+ "int my_function(int a);\n" +
2039
+ "int my_better_function(struct my_struct *s);\n" +
2040
+ "\n" +
2041
+ "#endif _NOINCLUDES\n"
2042
+
2043
+ assert_equal(source, @parser.transform_inline_functions(source))
2044
+ end
2045
+
2046
+ it "Transform inline functions changes inline functions to function declarations" do
2047
+ source =
2048
+ "#ifndef _NOINCLUDES\n" +
2049
+ "#define _NOINCLUDES\n" +
2050
+ "#include \"unity.h\"\n" +
2051
+ "#include \"cmock.h\"\n" +
2052
+ "#include \"YetAnotherHeader.h\"\n" +
2053
+ "\n" +
2054
+ "/* Ignore the following warnings since we are copying code */\n" +
2055
+ "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n" +
2056
+ "#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 6 || (__GNUC_MINOR__ == 6 && __GNUC_PATCHLEVEL__ > 0)))\n" +
2057
+ "#pragma GCC diagnostic push\n" +
2058
+ "#endif\n" +
2059
+ "#if !defined(__clang__)\n" +
2060
+ "#pragma GCC diagnostic ignored \"-Wpragmas\"\n" +
2061
+ "#endif\n" +
2062
+ "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n" +
2063
+ "#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n" +
2064
+ "#endif\n" +
2065
+ "\n" +
2066
+ "struct my_struct {\n" +
2067
+ "int a;\n" +
2068
+ "int b;\n" +
2069
+ "int b;\n" +
2070
+ "char c;\n" +
2071
+ "};\n" +
2072
+ "int my_function(int a);\n" +
2073
+ "int my_better_function(struct my_struct *s);\n" +
2074
+ "static inline int staticinlinebar(struct my_struct *s)\n" + # This is a function with a lot of indentation levels, we should be able to handle it
2075
+ "{\n" +
2076
+ "\t{\n" +
2077
+ "\t\t{\n" +
2078
+ "\t\t\treturn s->a;\n" +
2079
+ "\t\t}\n" +
2080
+ "\t}\n" +
2081
+ "}\n" +
2082
+ "static inline int staticinlinefunc(struct my_struct *s)\n" +
2083
+ "{\n" +
2084
+ " return s->a;\n" +
2085
+ "}\n" +
2086
+ "int bar(struct my_struct *s);\n" + # A normal function to screw with our parser
2087
+ "inline static int inlinestaticfunc(int a) {\n" +
2088
+ " return a + 42;\n" +
2089
+ "}\n" +
2090
+ "inline int StaticInlineFunc(struct my_struct *s)\n" +
2091
+ "{\n" +
2092
+ " return get_member_a(s) + 42;\n" +
2093
+ "}\n" +
2094
+ "int inline StaticInlineBar(struct my_struct *s)\n" +
2095
+ "{\n" +
2096
+ " return get_member_a(s) + 42;\n" +
2097
+ "}\n" +
2098
+ "struct staticinlinestruct {\n" + # Add a structure declaration between the inline functions, just to make sure we don't touch it!
2099
+ "int a;\n" +
2100
+ "};\n" +
2101
+ "\n" +
2102
+ "struct staticinlinestruct fubarstruct(struct my_struct *s);\n" + # Another normal function to screw with our parser
2103
+ "static inline struct staticinlinestruct inlinefubarfunction(struct my_struct *s)\n" +
2104
+ "{\n" +
2105
+ " return (struct staticinlinestruct)*s;\n" +
2106
+ "}\n" +
2107
+ "int fubar(struct my_struct *s);\n" + # Another normal function to screw with our parser
2108
+ "inline int stuff(int num)" +
2109
+ "{" +
2110
+ " int reg = 0x12;" +
2111
+ " if (num > 0)" +
2112
+ " {" +
2113
+ " reg |= (0x0Eu);" +
2114
+ " }" +
2115
+ " else" +
2116
+ " {" +
2117
+ " reg |= (0x07u);" +
2118
+ " }" +
2119
+ " return reg;" +
2120
+ "}" +
2121
+ "\n" +
2122
+ "int inline static dummy_func_2(int a, char b, float c) {" + # This is a sneaky one, inline static is placed AFTER the return value
2123
+ " c += 3.14;" +
2124
+ " b -= 32;" +
2125
+ " return a + (int)(b) + (int)c;" +
2126
+ "}" +
2127
+ "#endif _NOINCLUDES\n"
2128
+
2129
+ expected =
2130
+ "#ifndef _NOINCLUDES\n" +
2131
+ "#define _NOINCLUDES\n" +
2132
+ "#include \"unity.h\"\n" +
2133
+ "#include \"cmock.h\"\n" +
2134
+ "#include \"YetAnotherHeader.h\"\n" +
2135
+ "\n" +
2136
+ "/* Ignore the following warnings since we are copying code */\n" +
2137
+ "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n" +
2138
+ "#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 6 || (__GNUC_MINOR__ == 6 && __GNUC_PATCHLEVEL__ > 0)))\n" +
2139
+ "#pragma GCC diagnostic push\n" +
2140
+ "#endif\n" +
2141
+ "#if !defined(__clang__)\n" +
2142
+ "#pragma GCC diagnostic ignored \"-Wpragmas\"\n" +
2143
+ "#endif\n" +
2144
+ "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n" +
2145
+ "#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n" +
2146
+ "#endif\n" +
2147
+ "\n" +
2148
+ "struct my_struct {\n" +
2149
+ "int a;\n" +
2150
+ "int b;\n" +
2151
+ "int b;\n" +
2152
+ "char c;\n" +
2153
+ "};\n" +
2154
+ "int my_function(int a);\n" +
2155
+ "int my_better_function(struct my_struct *s);\n" +
2156
+ "int staticinlinebar(struct my_struct *s);\n" +
2157
+ "int staticinlinefunc(struct my_struct *s);\n" +
2158
+ "int bar(struct my_struct *s);\n" +
2159
+ "int inlinestaticfunc(int a);\n" +
2160
+ "int StaticInlineFunc(struct my_struct *s);\n" +
2161
+ "int StaticInlineBar(struct my_struct *s);\n" +
2162
+ "struct staticinlinestruct {\n" +
2163
+ "int a;\n" +
2164
+ "};\n" +
2165
+ "\n" +
2166
+ "struct staticinlinestruct fubarstruct(struct my_struct *s);\n" +
2167
+ "struct staticinlinestruct inlinefubarfunction(struct my_struct *s);\n" +
2168
+ "int fubar(struct my_struct *s);\n" +
2169
+ "int stuff(int num);\n" +
2170
+ "int dummy_func_2(int a, char b, float c);" +
2171
+ "#endif _NOINCLUDES\n"
2172
+
2173
+ assert_equal(expected, @parser.transform_inline_functions(source))
2174
+ end
2175
+
2176
+ it "Count number of pairs of braces in function succesfully" do
2177
+ source =
2178
+ "int foo(struct my_struct *s)\n" +
2179
+ "{\n" +
2180
+ " return get_member_a(s) + 42;\n" +
2181
+ "}\n"
2182
+ complex_source =
2183
+ "int bar(struct my_struct *s)\n" +
2184
+ "{\n" +
2185
+ "\tint a = 6;\n" +
2186
+ "\tint res = foo(&(struct my_struct){.nr = a});\n" +
2187
+ "\t{\n" +
2188
+ "\t\tint a = 5;\n" +
2189
+ "\t\tint res = foo(&(struct my_struct){.nr = a});\n" +
2190
+ "\t\t{\n" +
2191
+ "\t\t\tstruct my_struct a = {.nr = 1};\n" +
2192
+ "\t\t}\n" +
2193
+ "\t}\n" +
2194
+ "\treturn 42;\n" +
2195
+ "}\n"
2196
+
2197
+ assert_equal(1, @parser.count_number_of_pairs_of_braces_in_function(source))
2198
+ assert_equal(6, @parser.count_number_of_pairs_of_braces_in_function(complex_source))
2199
+ end
2200
+
2201
+ it "Count number of pairs of braces returns 0 if bad source is supplied" do
2202
+ bad_source_0 =
2203
+ "int foo(struct my_struct *s)\n" +
2204
+ "{\n" +
2205
+ " return get_member_a(s) + 42;\n" +
2206
+ "\n" # Missing closing brace
2207
+ bad_source_1 =
2208
+ "int bar(struct my_struct *s)\n" +
2209
+ "{\n" +
2210
+ "\tint a = 6;\n" +
2211
+ "\tint res = foo(&(struct my_struct){.nr = a});\n" +
2212
+ "\t{\n" +
2213
+ "\t\tint a = 5;\n" +
2214
+ "\t\tint res = foo(&(struct my_struct){.nr = a});\n" +
2215
+ "\t\t{\n" +
2216
+ "\t\t\n" + # Missing closing brace
2217
+ "\t}\n" +
2218
+ "\treturn 42;\n" +
2219
+ "}\n"
2220
+ bad_source_2 =
2221
+ "int foo(struct my_struct *s)\n" +
2222
+ "\n" # No braces in source
2223
+
2224
+ assert_equal(0, @parser.count_number_of_pairs_of_braces_in_function(bad_source_0))
2225
+ assert_equal(0, @parser.count_number_of_pairs_of_braces_in_function(bad_source_1))
2226
+ assert_equal(0, @parser.count_number_of_pairs_of_braces_in_function(bad_source_2))
2227
+ end
2228
+
2229
+ it "handles parsing multiline functions" do
2230
+ source = "int\nLaverneAndShirley(int Lenny,\n int Squiggy);\n"
2231
+ expected = [{ :var_arg=>nil,
2232
+ :return=> { :type => "int",
2233
+ :name => 'cmock_to_return',
2234
+ :ptr? => false,
2235
+ :const? => false,
2236
+ :const_ptr? => false,
2237
+ :str => "int cmock_to_return",
2238
+ :void? => false
2239
+ },
2240
+ :name=>"LaverneAndShirley",
2241
+ :unscoped_name=>"LaverneAndShirley",
2242
+ :namespace=>[],
2243
+ :class=>nil,
2244
+ :modifier=>"",
2245
+ :contains_ptr? => false,
2246
+ :args=>[ {:type=>"int", :name=>"Lenny", :ptr? => false, :const? => false, :const_ptr? => false},
2247
+ {:type=>"int", :name=>"Squiggy", :ptr? => false, :const? => false, :const_ptr? => false}
2248
+ ],
2249
+ :args_string=>"int Lenny, int Squiggy",
2250
+ :args_call=>"Lenny, Squiggy"
2251
+ }]
2252
+ assert_equal(expected, @parser.parse("module", source)[:functions])
2253
+ end
2254
+
2255
+ it "imports C++ differently when asked" do
2256
+ source =
2257
+ [
2258
+ "namespace ns1 {\n",
2259
+ " namespace ns2 {\n",
2260
+ "\n",
2261
+ " class cls1 {\n",
2262
+ " public:\n",
2263
+ " int f_header_impl(int a, int b){\n",
2264
+ " return a + b;\n",
2265
+ " }\n",
2266
+ "\n",
2267
+ " static void f_void();\n",
2268
+ " static int f_ret_simple();\n",
2269
+ "\n",
2270
+ " protected:\n",
2271
+ " static void protected_f_void();\n",
2272
+ "\n",
2273
+ " public:\n",
2274
+ " private:\n",
2275
+ " static void private_f_void();\n",
2276
+ " }; // cls1\n",
2277
+ " } // ns2\n",
2278
+ "} // ns1\n"
2279
+ ].join
2280
+
2281
+ expected =
2282
+ [
2283
+ "namespace ns1 { namespace ns2 { class cls1 { public: int f_header_impl",
2284
+ "static void f_void()",
2285
+ "static int f_ret_simple()",
2286
+ "protected: static void protected_f_void()",
2287
+ "public: private: static void private_f_void()",
2288
+ "}",
2289
+ "} }"
2290
+ ]
2291
+
2292
+ assert_equal(expected, @parser.import_source(source, cpp=true))
2293
+ refute_equal(expected, @parser.import_source(source))
2294
+ end
2295
+
2296
+ # only so parse_functions does not raise an error
2297
+ def dummy_source
2298
+ "void dummy(void);"
2299
+ end
2300
+
2301
+ # Expected result of above
2302
+ def dummy_func
2303
+ { :name => "dummy",
2304
+ :unscoped_name => "dummy",
2305
+ :class => nil,
2306
+ :namespace => [],
2307
+ :var_arg => nil,
2308
+ :args_string => "void",
2309
+ :args => [],
2310
+ :args_call => "",
2311
+ :contains_ptr? => false,
2312
+ :modifier => "",
2313
+ :return => {
2314
+ :type => "void",
2315
+ :name => "cmock_to_return",
2316
+ :str => "void cmock_to_return",
2317
+ :void? => true,
2318
+ :ptr? => false,
2319
+ :const? => false,
2320
+ :const_ptr? => false}}
2321
+ end
2322
+
2323
+ # Commonly used example function
2324
+ def voidvoid_func(namespace=[], name="Classic_functional")
2325
+ { :name => name,
2326
+ :unscoped_name => "functional",
2327
+ :class => "Classic",
2328
+ :namespace => namespace,
2329
+ :var_arg => nil,
2330
+ :args_string => "void",
2331
+ :args => [],
2332
+ :args_call => "",
2333
+ :contains_ptr? => false,
2334
+ :modifier => "",
2335
+ :return => {
2336
+ :type=>"void",
2337
+ :name=>"cmock_to_return",
2338
+ :str=>"void cmock_to_return",
2339
+ :void? => true,
2340
+ :ptr? => false,
2341
+ :const? => false,
2342
+ :const_ptr? => false}}
2343
+ end
2344
+
2345
+ it "parses public C++ functions" do
2346
+ source = dummy_source + <<~SOURCE
2347
+ class Classic {
2348
+ public:
2349
+ static void functional(void);
2350
+ };
2351
+ SOURCE
2352
+
2353
+ expected = [dummy_func, voidvoid_func]
2354
+
2355
+ assert_equal(expected, @parser.parse("module", source)[:functions])
2356
+ end
2357
+
2358
+ it "handles a namespace" do
2359
+ source = dummy_source + <<~SOURCE
2360
+ namespace ns1 {
2361
+ class Classic {
2362
+ public:
2363
+ static void functional(void);
2364
+ };
2365
+ } // ns1
2366
+ SOURCE
2367
+
2368
+ expected = [dummy_func,
2369
+ voidvoid_func(namespace=["ns1"], name="ns1_Classic_functional")]
2370
+
2371
+ assert_equal(expected, @parser.parse("module", source)[:functions])
2372
+ end
2373
+
2374
+ it "handles nested namespaces" do
2375
+ source = dummy_source + <<~SOURCE
2376
+ namespace ns1 {
2377
+ namespace ns2 {
2378
+ class Classic {
2379
+ public:
2380
+ static void functional(void);
2381
+ };
2382
+ } // ns1
2383
+ } // ns1
2384
+ SOURCE
2385
+
2386
+ expected = [dummy_func,
2387
+ voidvoid_func(namespace=["ns1", "ns2"], name="ns1_ns2_Classic_functional")]
2388
+
2389
+ assert_equal(expected, @parser.parse("module", source)[:functions])
2390
+ end
2391
+
2392
+ it "ignores non-static C++ functions" do
2393
+ source = dummy_source + <<~SOURCE
2394
+ class Classic {
2395
+ public:
2396
+ void functional(void);
2397
+ };
2398
+ SOURCE
2399
+
2400
+ expected = [dummy_func]
2401
+
2402
+ assert_equal(expected, @parser.parse("module", source)[:functions])
2403
+ end
2404
+
2405
+ it "ignores private functions" do
2406
+ source = dummy_source + <<~SOURCE
2407
+ class Classic {
2408
+ private:
2409
+ static void functional(void);
2410
+ };
2411
+ SOURCE
2412
+
2413
+ expected = [dummy_func]
2414
+
2415
+ assert_equal(expected, @parser.parse("module", source)[:functions])
2416
+ end
2417
+
2418
+ it "parses public C++ functions after private functions" do
2419
+ source = dummy_source + <<~SOURCE
2420
+ class Classic {
2421
+ private:
2422
+ static void ignoreme(void);
2423
+ public:
2424
+ static void functional(void);
2425
+ };
2426
+ SOURCE
2427
+
2428
+ expected = [dummy_func, voidvoid_func]
2429
+
2430
+ assert_equal(expected, @parser.parse("module", source)[:functions])
2431
+ end
2432
+
2433
+ it "ignores protected functions" do
2434
+ source = dummy_source + <<~SOURCE
2435
+ class Classic {
2436
+ protected:
2437
+ static void functional(void);
2438
+ };
2439
+ SOURCE
2440
+
2441
+ expected = [dummy_func]
2442
+
2443
+ assert_equal(expected, @parser.parse("module", source)[:functions])
2444
+ end
2445
+
2446
+ it "parses public C++ functions after protected functions" do
2447
+ source = dummy_source + <<~SOURCE
2448
+ class Classic {
2449
+ protected:
2450
+ static void ignoreme(void);
2451
+ public:
2452
+ static void functional(void);
2453
+ };
2454
+ SOURCE
2455
+
2456
+ expected = [dummy_func, voidvoid_func]
2457
+
2458
+ assert_equal(expected, @parser.parse("module", source)[:functions])
2459
+ end
2460
+
2461
+ it "parses multiple classes in same file with uniquely named functions" do
2462
+ source = dummy_source + <<~SOURCE
2463
+ namespace ns1 {
2464
+ class Classic {
2465
+ public:
2466
+ static void functional(void);
2467
+ };
2468
+
2469
+ class Classical {
2470
+ public:
2471
+ static int functionality(int a);
2472
+ };
2473
+ } // ns1
2474
+
2475
+ class Classy {
2476
+ public:
2477
+ static int* func(int* a);
2478
+ };
2479
+ SOURCE
2480
+
2481
+ expected = [dummy_func,
2482
+ voidvoid_func(["ns1"], name="ns1_Classic_functional"),
2483
+ { :name => "ns1_Classical_functionality",
2484
+ :unscoped_name => "functionality",
2485
+ :class => "Classical",
2486
+ :namespace => ["ns1"],
2487
+ :var_arg => nil,
2488
+ :args_string => "int a",
2489
+ :args => [
2490
+ { :ptr? => false,
2491
+ :const? => false,
2492
+ :const_ptr? => false,
2493
+ :name => "a",
2494
+ :type => "int"}],
2495
+ :args_call => "a",
2496
+ :contains_ptr? => false,
2497
+ :modifier => "",
2498
+ :return => {
2499
+ :type=>"int",
2500
+ :name=>"cmock_to_return",
2501
+ :str=>"int cmock_to_return",
2502
+ :void? => false,
2503
+ :ptr? => false,
2504
+ :const? => false,
2505
+ :const_ptr? => false}},
2506
+ { :name => "Classy_func",
2507
+ :unscoped_name => "func",
2508
+ :class => "Classy",
2509
+ :namespace => [],
2510
+ :var_arg => nil,
2511
+ :args_string => "int* a",
2512
+ :args => [
2513
+ { :ptr? => true,
2514
+ :const? => false,
2515
+ :const_ptr? => false,
2516
+ :name => "a",
2517
+ :type => "int*"}],
2518
+ :args_call => "a",
2519
+ :contains_ptr? => true,
2520
+ :modifier => "",
2521
+ :return => {
2522
+ :type=>"int*",
2523
+ :name=>"cmock_to_return",
2524
+ :str=>"int* cmock_to_return",
2525
+ :void? => false,
2526
+ :ptr? => true,
2527
+ :const? => false,
2528
+ :const_ptr? => false}}]
2529
+
2530
+ assert_equal(expected, @parser.parse("module", source)[:functions])
2531
+ end
2532
+
2533
+ it "handles multiple classes in same file with identically named functions" do
2534
+ source = dummy_source + <<~SOURCE
2535
+ namespace ns1 {
2536
+ class Classic {
2537
+ public:
2538
+ static void functional(void);
2539
+ };
2540
+
2541
+ class Classical {
2542
+ public:
2543
+ static int functional(int a);
2544
+ };
2545
+ } // ns1
2546
+
2547
+ class Classy {
2548
+ public:
2549
+ static int* functional(int* a);
2550
+ };
2551
+ SOURCE
2552
+
2553
+ expected = [dummy_func,
2554
+ voidvoid_func(["ns1"], name="ns1_Classic_functional"),
2555
+ { :name => "ns1_Classical_functional",
2556
+ :unscoped_name => "functional",
2557
+ :class => "Classical",
2558
+ :namespace => ["ns1"],
2559
+ :var_arg => nil,
2560
+ :args_string => "int a",
2561
+ :args => [
2562
+ { :ptr? => false,
2563
+ :const? => false,
2564
+ :const_ptr? => false,
2565
+ :name => "a",
2566
+ :type => "int"}],
2567
+ :args_call => "a",
2568
+ :contains_ptr? => false,
2569
+ :modifier => "",
2570
+ :return => {
2571
+ :type=>"int",
2572
+ :name=>"cmock_to_return",
2573
+ :str=>"int cmock_to_return",
2574
+ :void? => false,
2575
+ :ptr? => false,
2576
+ :const? => false,
2577
+ :const_ptr? => false}},
2578
+ { :name => "Classy_functional",
2579
+ :unscoped_name => "functional",
2580
+ :class => "Classy",
2581
+ :namespace => [],
2582
+ :var_arg => nil,
2583
+ :args_string => "int* a",
2584
+ :args => [
2585
+ { :ptr? => true,
2586
+ :const? => false,
2587
+ :const_ptr? => false,
2588
+ :name => "a",
2589
+ :type => "int*"}],
2590
+ :args_call => "a",
2591
+ :contains_ptr? => true,
2592
+ :modifier => "",
2593
+ :return => {
2594
+ :type=>"int*",
2595
+ :name=>"cmock_to_return",
2596
+ :str=>"int* cmock_to_return",
2597
+ :void? => false,
2598
+ :ptr? => true,
2599
+ :const? => false,
2600
+ :const_ptr? => false}}]
2601
+
2602
+ assert_equal(expected, @parser.parse("module", source)[:functions])
2603
+ end
2604
+
2605
+ it "Transform inline functions can handle inline function declarations" do
2606
+ source =
2607
+ "static inline int dummy_func_decl(int a, char b, float c);\n" + # First declaration
2608
+ "static inline int dummy_func_decl2(int a, char b, float c)\n\n\n\n\n\n;\n" + # Second declaration with a lot of newlines before the semicolon to mess with the parser
2609
+ "static inline int staticinlinefunc(struct my_struct *s)\n" + # 'normal' inline pattern
2610
+ "{\n" +
2611
+ " return dummy_func_decl(1, 1, 1);\n" +
2612
+ "}\n" +
2613
+ "struct my_struct_with_inline_in_it\n" + # struct definition in between to mess with the parser
2614
+ "{\n" +
2615
+ " int a;\n" +
2616
+ " char b;\n" +
2617
+ " float inlineb;\n" +
2618
+ "};\n" +
2619
+ "static inline int dummy_func_decl(int a, char b, float c) {\n" + # Second user pattern
2620
+ " return 42;\n" +
2621
+ "}\n" +
2622
+ "\n"
2623
+
2624
+ expected =
2625
+ "int dummy_func_decl(int a, char b, float c);\n" +
2626
+ "int dummy_func_decl2(int a, char b, float c)\n\n\n\n\n\n;\n" + # Second declaration with a lot of newlines until the semicolon to mess with the parser
2627
+ "int staticinlinefunc(struct my_struct *s);\n" +
2628
+ "struct my_struct_with_inline_in_it\n" +
2629
+ "{\n" +
2630
+ " int a;\n" +
2631
+ " char b;\n" +
2632
+ " float inlineb;\n" +
2633
+ "};\n" +
2634
+ "int dummy_func_decl(int a, char b, float c);\n" +
2635
+ "\n"
2636
+
2637
+ @parser.treat_inlines = :include
2638
+ assert_equal(expected, @parser.transform_inline_functions(source))
2639
+ end
2640
+
2641
+ it "Transform inline functions can handle header with only inline function declarations" do
2642
+ source =
2643
+ "static inline int dummy_func_decl(int a, char b, float c);\n" +
2644
+ "\n"
2645
+
2646
+ expected =
2647
+ "int dummy_func_decl(int a, char b, float c);\n" +
2648
+ "\n"
2649
+
2650
+ @parser.treat_inlines = :include
2651
+ assert_equal(expected, @parser.transform_inline_functions(source))
2652
+ end
2653
+
2654
+ it "Transform inline functions takes user provided patterns into account" do
2655
+ source =
2656
+ "static __inline__ __attribute__ ((always_inline)) uint16_t _somefunc (uint32_t a)\n" +
2657
+ "{\n" +
2658
+ " return _someotherfunc (a);\n" +
2659
+ "}\n" +
2660
+ "static __inline__ uint16_t _somefunc_0 (uint32_t a)\n" +
2661
+ "{\n" +
2662
+ " return (uint16_t) a;\n" +
2663
+ "}\n" +
2664
+ "\n"
2665
+
2666
+ expected =
2667
+ "uint16_t _somefunc (uint32_t a);\n" +
2668
+ "uint16_t _somefunc_0 (uint32_t a);\n" +
2669
+ "\n"
2670
+
2671
+ @parser.treat_inlines = :include
2672
+ @parser.inline_function_patterns = ['static __inline__ __attribute__ \(\(always_inline\)\)', 'static __inline__']
2673
+ assert_equal(expected, @parser.transform_inline_functions(source))
2674
+ end
2675
+
2676
+ it "Transform inline functions limits deleting user macro to actual line/word" do
2677
+ source =
2678
+ "#if defined (FORCE_INLINE)\n" +
2679
+ "#define MY_LIBRARY_INLINE static __inline__ __attribute__ ((always_inline))\n" +
2680
+ "#else\n" +
2681
+ "#define MY_LIBRARY_INLINE\n" +
2682
+ "#endif\n" +
2683
+ "#define INLINE static __inline__ __attribute__ ((always_inline))\n" +
2684
+ "#define INLINE_TWO \\\nstatic\\\ninline\n" +
2685
+ "INLINE uint16_t _somefunc (uint32_t a)\n" +
2686
+ "{\n" +
2687
+ " return _someotherfunc (a);\n" +
2688
+ "}\n" +
2689
+ "static __inline__ uint16_t _somefunc_0 (uint32_t a)\n" +
2690
+ "{\n" +
2691
+ " return (uint16_t) a;\n" +
2692
+ "}\n" +
2693
+ "static __inline__ __attribute__ \(\(always_inline\)\) uint16_t _somefunc_1 (uint32_t a)\n" +
2694
+ "{\n" +
2695
+ " return (uint16_t) a;\n" +
2696
+ "}\n" +
2697
+ "INLINE_TWO uint16_t _somefunc_2(uint32_t a)\n" +
2698
+ "{\n" +
2699
+ " return (uint16_t) a;\n" +
2700
+ "}\n" +
2701
+ "#define INLINE_THREE \\\nstatic\\\ninline"
2702
+
2703
+ expected =
2704
+ "#if defined (FORCE_INLINE)\n" +
2705
+ "#else\n" +
2706
+ "#endif\n" +
2707
+ "uint16_t _somefunc (uint32_t a);\n" +
2708
+ "uint16_t _somefunc_0 (uint32_t a);\n" +
2709
+ "uint16_t _somefunc_1 (uint32_t a);\n" +
2710
+ "uint16_t _somefunc_2(uint32_t a);\n"
2711
+
2712
+ @parser.treat_inlines = :include
2713
+ @parser.inline_function_patterns = ['MY_LIBRARY_INLINE', 'INLINE_THREE', 'INLINE_TWO', 'INLINE', 'static __inline__ __attribute__ \(\(always_inline\)\)', 'static __inline__']
2714
+ assert_equal(expected, @parser.transform_inline_functions(source))
2715
+ end
2716
+
2717
+ end