ceedling 0.28.3 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1101) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +16 -16
  3. data/Gemfile.lock +17 -16
  4. data/README.md +107 -66
  5. data/Rakefile +11 -11
  6. data/assets/ceedling +3 -3
  7. data/assets/ceedling.cmd +1 -1
  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 +100 -90
  12. data/assets/project_with_guts.yml +101 -91
  13. data/assets/project_with_guts_gcov.yml +101 -91
  14. data/assets/test_example_file.c +13 -13
  15. data/assets/test_example_file_boom.c +13 -13
  16. data/assets/test_example_file_success.c +14 -14
  17. data/assets/test_example_file_verbose.c +12 -12
  18. data/bin/ceedling +337 -316
  19. data/ceedling.gemspec +36 -39
  20. data/ceedling.sublime-project +25 -0
  21. data/ceedling.sublime-workspace +1276 -0
  22. data/config/test_environment.rb +11 -11
  23. data/docs/CeedlingPacket.md +2119 -2060
  24. data/docs/ThrowTheSwitchCodingStandard.md +207 -207
  25. data/examples/blinky/project.yml +99 -98
  26. data/examples/blinky/rakefile.rb +31 -31
  27. data/examples/blinky/src/BlinkTask.c +21 -21
  28. data/examples/blinky/src/BlinkTask.h +6 -6
  29. data/examples/blinky/src/Configure.c +36 -36
  30. data/examples/blinky/src/Configure.h +6 -6
  31. data/examples/blinky/src/main.c +51 -51
  32. data/examples/blinky/src/main.h +9 -9
  33. data/examples/blinky/test/support/stub_interrupt.h +347 -347
  34. data/examples/blinky/test/support/stub_io.h +421 -421
  35. data/examples/blinky/test/support/stub_iom328p.h +883 -883
  36. data/examples/blinky/test/support/stub_sfr_defs.h +269 -269
  37. data/examples/blinky/test/test_BlinkTask.c +42 -42
  38. data/examples/blinky/test/test_Configure.c +29 -29
  39. data/examples/blinky/test/test_main.c +60 -60
  40. data/examples/temp_sensor/project.yml +76 -76
  41. data/examples/temp_sensor/rakefile.rb +6 -6
  42. data/examples/temp_sensor/src/AdcConductor.c +42 -42
  43. data/examples/temp_sensor/src/AdcConductor.h +13 -13
  44. data/examples/temp_sensor/src/AdcHardware.c +27 -27
  45. data/examples/temp_sensor/src/AdcHardware.h +11 -11
  46. data/examples/temp_sensor/src/AdcHardwareConfigurator.c +18 -18
  47. data/examples/temp_sensor/src/AdcHardwareConfigurator.h +10 -10
  48. data/examples/temp_sensor/src/AdcModel.c +33 -33
  49. data/examples/temp_sensor/src/AdcModel.h +13 -13
  50. data/examples/temp_sensor/src/AdcTemperatureSensor.c +51 -51
  51. data/examples/temp_sensor/src/AdcTemperatureSensor.h +10 -10
  52. data/examples/temp_sensor/src/Executor.c +25 -25
  53. data/examples/temp_sensor/src/Executor.h +9 -9
  54. data/examples/temp_sensor/src/IntrinsicsWrapper.c +18 -18
  55. data/examples/temp_sensor/src/IntrinsicsWrapper.h +7 -7
  56. data/examples/temp_sensor/src/Main.c +46 -46
  57. data/examples/temp_sensor/src/Main.h +7 -7
  58. data/examples/temp_sensor/src/Model.c +10 -10
  59. data/examples/temp_sensor/src/Model.h +8 -8
  60. data/examples/temp_sensor/src/ModelConfig.h +7 -7
  61. data/examples/temp_sensor/src/TaskScheduler.c +72 -72
  62. data/examples/temp_sensor/src/TaskScheduler.h +11 -11
  63. data/examples/temp_sensor/src/TemperatureCalculator.c +27 -27
  64. data/examples/temp_sensor/src/TemperatureCalculator.h +8 -8
  65. data/examples/temp_sensor/src/TemperatureFilter.c +38 -38
  66. data/examples/temp_sensor/src/TemperatureFilter.h +10 -10
  67. data/examples/temp_sensor/src/TimerConductor.c +15 -15
  68. data/examples/temp_sensor/src/TimerConductor.h +9 -9
  69. data/examples/temp_sensor/src/TimerConfigurator.c +51 -51
  70. data/examples/temp_sensor/src/TimerConfigurator.h +15 -15
  71. data/examples/temp_sensor/src/TimerHardware.c +15 -15
  72. data/examples/temp_sensor/src/TimerHardware.h +8 -8
  73. data/examples/temp_sensor/src/TimerInterruptConfigurator.c +55 -55
  74. data/examples/temp_sensor/src/TimerInterruptConfigurator.h +13 -13
  75. data/examples/temp_sensor/src/TimerInterruptHandler.c +25 -25
  76. data/examples/temp_sensor/src/TimerInterruptHandler.h +10 -10
  77. data/examples/temp_sensor/src/TimerModel.c +9 -9
  78. data/examples/temp_sensor/src/TimerModel.h +8 -8
  79. data/examples/temp_sensor/src/Types.h +90 -90
  80. data/examples/temp_sensor/src/UsartBaudRateRegisterCalculator.c +18 -18
  81. data/examples/temp_sensor/src/UsartBaudRateRegisterCalculator.h +8 -8
  82. data/examples/temp_sensor/src/UsartConductor.c +21 -21
  83. data/examples/temp_sensor/src/UsartConductor.h +7 -7
  84. data/examples/temp_sensor/src/UsartConfigurator.c +39 -39
  85. data/examples/temp_sensor/src/UsartConfigurator.h +13 -13
  86. data/examples/temp_sensor/src/UsartHardware.c +22 -22
  87. data/examples/temp_sensor/src/UsartHardware.h +9 -9
  88. data/examples/temp_sensor/src/UsartModel.c +34 -34
  89. data/examples/temp_sensor/src/UsartModel.h +10 -10
  90. data/examples/temp_sensor/src/UsartPutChar.c +16 -16
  91. data/examples/temp_sensor/src/UsartPutChar.h +8 -8
  92. data/examples/temp_sensor/src/UsartTransmitBufferStatus.c +7 -7
  93. data/examples/temp_sensor/src/UsartTransmitBufferStatus.h +8 -8
  94. data/examples/temp_sensor/test/TestAdcConductor.c +121 -121
  95. data/examples/temp_sensor/test/TestAdcHardware.c +44 -44
  96. data/examples/temp_sensor/test/TestAdcModel.c +33 -33
  97. data/examples/temp_sensor/test/TestExecutor.c +36 -36
  98. data/examples/temp_sensor/test/TestMain.c +24 -24
  99. data/examples/temp_sensor/test/TestModel.c +20 -20
  100. data/examples/temp_sensor/test/TestTaskScheduler.c +104 -104
  101. data/examples/temp_sensor/test/TestTemperatureCalculator.c +36 -36
  102. data/examples/temp_sensor/test/TestTemperatureFilter.c +79 -79
  103. data/examples/temp_sensor/test/TestTimerConductor.c +32 -32
  104. data/examples/temp_sensor/test/TestTimerHardware.c +26 -26
  105. data/examples/temp_sensor/test/TestTimerModel.c +18 -18
  106. data/examples/temp_sensor/test/TestUsartBaudRateRegisterCalculator.c +21 -21
  107. data/examples/temp_sensor/test/TestUsartConductor.c +40 -40
  108. data/examples/temp_sensor/test/TestUsartHardware.c +36 -36
  109. data/examples/temp_sensor/test/TestUsartModel.c +40 -40
  110. data/examples/temp_sensor/test/support/UnityHelper.c +12 -12
  111. data/examples/temp_sensor/test/support/UnityHelper.h +12 -12
  112. data/lib/ceedling.rb +99 -99
  113. data/lib/ceedling/build_invoker_utils.rb +39 -39
  114. data/lib/ceedling/cacheinator.rb +47 -42
  115. data/lib/ceedling/cacheinator_helper.rb +31 -12
  116. data/lib/ceedling/cmock_builder.rb +15 -15
  117. data/lib/ceedling/configurator.rb +363 -356
  118. data/lib/ceedling/configurator_builder.rb +458 -451
  119. data/lib/ceedling/configurator_plugins.rb +111 -111
  120. data/lib/ceedling/configurator_setup.rb +127 -127
  121. data/lib/ceedling/configurator_validator.rb +193 -193
  122. data/lib/ceedling/constants.rb +97 -97
  123. data/lib/ceedling/defaults.rb +418 -418
  124. data/lib/ceedling/dependinator.rb +98 -91
  125. data/lib/ceedling/erb_wrapper.rb +8 -8
  126. data/lib/ceedling/file_finder.rb +149 -149
  127. data/lib/ceedling/file_finder_helper.rb +54 -54
  128. data/lib/ceedling/file_path_utils.rb +200 -200
  129. data/lib/ceedling/file_system_utils.rb +69 -69
  130. data/lib/ceedling/file_system_wrapper.rb +9 -9
  131. data/lib/ceedling/file_wrapper.rb +83 -83
  132. data/lib/ceedling/flaginator.rb +74 -74
  133. data/lib/ceedling/generator.rb +183 -176
  134. data/lib/ceedling/generator_helper.rb +40 -40
  135. data/lib/ceedling/generator_test_results.rb +89 -89
  136. data/lib/ceedling/generator_test_results_sanity_checker.rb +65 -65
  137. data/lib/ceedling/generator_test_runner.rb +56 -52
  138. data/lib/ceedling/loginator.rb +31 -31
  139. data/lib/ceedling/makefile.rb +46 -46
  140. data/lib/ceedling/objects.yml +310 -307
  141. data/lib/ceedling/par_map.rb +19 -19
  142. data/lib/ceedling/plugin.rb +80 -80
  143. data/lib/ceedling/plugin_builder.rb +52 -52
  144. data/lib/ceedling/plugin_manager.rb +107 -107
  145. data/lib/ceedling/plugin_manager_helper.rb +19 -19
  146. data/lib/ceedling/plugin_reportinator.rb +76 -76
  147. data/lib/ceedling/plugin_reportinator_helper.rb +51 -51
  148. data/lib/ceedling/preprocessinator.rb +42 -43
  149. data/lib/ceedling/preprocessinator_extractor.rb +30 -30
  150. data/lib/ceedling/preprocessinator_file_handler.rb +21 -21
  151. data/lib/ceedling/preprocessinator_helper.rb +46 -46
  152. data/lib/ceedling/preprocessinator_includes_handler.rb +181 -96
  153. data/lib/ceedling/project_config_manager.rb +46 -37
  154. data/lib/ceedling/project_file_loader.rb +99 -99
  155. data/lib/ceedling/rake_utils.rb +17 -17
  156. data/lib/ceedling/rake_wrapper.rb +33 -33
  157. data/lib/ceedling/rakefile.rb +86 -86
  158. data/lib/ceedling/release_invoker.rb +73 -73
  159. data/lib/ceedling/release_invoker_helper.rb +19 -19
  160. data/lib/ceedling/reportinator.rb +26 -26
  161. data/lib/ceedling/rules_cmock.rake +9 -9
  162. data/lib/ceedling/rules_preprocess.rake +26 -26
  163. data/lib/ceedling/rules_release.rake +86 -86
  164. data/lib/ceedling/rules_release_deep_dependencies.rake +15 -15
  165. data/lib/ceedling/rules_tests.rake +74 -74
  166. data/lib/ceedling/rules_tests_deep_dependencies.rake +15 -15
  167. data/lib/ceedling/setupinator.rb +53 -53
  168. data/lib/ceedling/stream_wrapper.rb +28 -20
  169. data/lib/ceedling/streaminator.rb +40 -40
  170. data/lib/ceedling/streaminator_helper.rb +15 -15
  171. data/lib/ceedling/system_utils.rb +37 -37
  172. data/lib/ceedling/system_wrapper.rb +80 -80
  173. data/lib/ceedling/target_loader.rb +38 -38
  174. data/lib/ceedling/task_invoker.rb +117 -101
  175. data/lib/ceedling/tasks_base.rake +111 -112
  176. data/lib/ceedling/tasks_filesystem.rake +103 -100
  177. data/lib/ceedling/tasks_release.rake +30 -30
  178. data/lib/ceedling/tasks_release_deep_dependencies.rake +9 -9
  179. data/lib/ceedling/tasks_tests.rake +60 -55
  180. data/lib/ceedling/tasks_tests_deep_dependencies.rake +9 -9
  181. data/lib/ceedling/tasks_vendor.rake +35 -35
  182. data/lib/ceedling/test_includes_extractor.rb +85 -85
  183. data/lib/ceedling/test_invoker.rb +188 -164
  184. data/lib/ceedling/test_invoker_helper.rb +32 -32
  185. data/lib/ceedling/tool_executor.rb +229 -223
  186. data/lib/ceedling/tool_executor_helper.rb +164 -164
  187. data/lib/ceedling/verbosinator.rb +10 -10
  188. data/lib/ceedling/version.rb +36 -15
  189. data/lib/ceedling/yaml_wrapper.rb +17 -17
  190. data/license.txt +31 -31
  191. data/out.fail +22 -21
  192. data/plugins/beep/README.md +22 -22
  193. data/plugins/beep/lib/beep.rb +40 -40
  194. data/plugins/bullseye/assets/template.erb +15 -15
  195. data/plugins/bullseye/bullseye.rake +169 -169
  196. data/plugins/bullseye/config/defaults.yml +57 -57
  197. data/plugins/bullseye/lib/bullseye.rb +194 -194
  198. data/plugins/colour_report/lib/colour_report.rb +16 -0
  199. data/plugins/command_hooks/README.md +53 -52
  200. data/plugins/command_hooks/lib/command_hooks.rb +92 -75
  201. data/plugins/fake_function_framework/README.md +250 -250
  202. data/plugins/fake_function_framework/Rakefile +18 -18
  203. data/plugins/fake_function_framework/examples/fff_example/project.yml +71 -71
  204. data/plugins/fake_function_framework/examples/fff_example/rakefile.rb +7 -7
  205. data/plugins/fake_function_framework/examples/fff_example/src/bar.c +1 -1
  206. data/plugins/fake_function_framework/examples/fff_example/src/bar.h +14 -14
  207. data/plugins/fake_function_framework/examples/fff_example/src/custom_types.h +6 -6
  208. data/plugins/fake_function_framework/examples/fff_example/src/display.c +6 -6
  209. data/plugins/fake_function_framework/examples/fff_example/src/display.h +16 -16
  210. data/plugins/fake_function_framework/examples/fff_example/src/event_processor.c +93 -93
  211. data/plugins/fake_function_framework/examples/fff_example/src/event_processor.h +11 -11
  212. data/plugins/fake_function_framework/examples/fff_example/src/foo.c +16 -16
  213. data/plugins/fake_function_framework/examples/fff_example/src/foo.h +8 -8
  214. data/plugins/fake_function_framework/examples/fff_example/src/subfolder/zzz.c +1 -1
  215. data/plugins/fake_function_framework/examples/fff_example/src/subfolder/zzz.h +6 -6
  216. data/plugins/fake_function_framework/examples/fff_example/test/test_event_processor.c +155 -155
  217. data/plugins/fake_function_framework/examples/fff_example/test/test_foo.c +47 -47
  218. data/plugins/fake_function_framework/lib/fake_function_framework.rb +87 -87
  219. data/plugins/fake_function_framework/lib/fff_mock_generator.rb +163 -163
  220. data/plugins/fake_function_framework/spec/fff_mock_header_generator_spec.rb +304 -304
  221. data/plugins/fake_function_framework/spec/fff_mock_source_generator_spec.rb +148 -148
  222. data/plugins/fake_function_framework/spec/header_generator.rb +50 -50
  223. data/plugins/fake_function_framework/spec/spec_helper.rb +96 -96
  224. data/plugins/fake_function_framework/src/fff_unity_helper.h +32 -32
  225. data/plugins/gcov/README.md +101 -42
  226. data/plugins/gcov/assets/template.erb +15 -15
  227. data/plugins/gcov/config/defaults.yml +73 -66
  228. data/plugins/gcov/gcov.rake +220 -180
  229. data/plugins/gcov/lib/gcov.rb +113 -106
  230. data/plugins/gcov/lib/gcov_constants.rb +19 -18
  231. data/plugins/junit_tests_report/README.md +36 -0
  232. data/plugins/junit_tests_report/lib/junit_tests_report.rb +129 -118
  233. data/plugins/module_generator/config/module_generator.yml +3 -3
  234. data/plugins/module_generator/lib/module_generator.rb +70 -51
  235. data/plugins/module_generator/module_generator.rake +47 -43
  236. data/plugins/raw_output_report/lib/raw_output_report.rb +41 -41
  237. data/plugins/stdout_gtestlike_tests_report/assets/template.erb +84 -84
  238. data/plugins/stdout_gtestlike_tests_report/assets/template.erb copy +59 -59
  239. data/plugins/stdout_gtestlike_tests_report/config/stdout_gtestlike_tests_report.yml +4 -4
  240. data/plugins/stdout_gtestlike_tests_report/lib/stdout_gtestlike_tests_report.rb +43 -43
  241. data/plugins/stdout_ide_tests_report/config/stdout_ide_tests_report.yml +4 -4
  242. data/plugins/stdout_ide_tests_report/lib/stdout_ide_tests_report.rb +44 -44
  243. data/plugins/stdout_pretty_tests_report/assets/template.erb +59 -59
  244. data/plugins/stdout_pretty_tests_report/config/stdout_pretty_tests_report.yml +4 -4
  245. data/plugins/stdout_pretty_tests_report/lib/stdout_pretty_tests_report.rb +47 -47
  246. data/plugins/subprojects/README.md +63 -63
  247. data/plugins/subprojects/config/defaults.yml +33 -33
  248. data/plugins/subprojects/lib/subprojects.rb +92 -92
  249. data/plugins/subprojects/subprojects.rake +78 -78
  250. data/plugins/teamcity_tests_report/config/teamcity_tests_report.yml +4 -4
  251. data/plugins/teamcity_tests_report/lib/teamcity_tests_report.rb +57 -57
  252. data/plugins/warnings_report/lib/warnings_report.rb +69 -69
  253. data/plugins/xml_tests_report/README.md +36 -0
  254. data/plugins/xml_tests_report/lib/xml_tests_report.rb +110 -108
  255. data/spec/build_invoker_utils_spec.rb +54 -54
  256. data/spec/ceedling_spec.rb +154 -154
  257. data/spec/configurator_builder_spec.rb +6 -6
  258. data/spec/configurator_helper_spec.rb +4 -4
  259. data/spec/configurator_spec.rb +9 -9
  260. data/spec/file_finder_helper_spec.rb +53 -53
  261. data/spec/gcov/gcov_deployment_spec.rb +70 -70
  262. data/spec/gcov/gcov_test_cases_spec.rb +91 -91
  263. data/spec/generator_test_results_sanity_checker_spec.rb +88 -88
  264. data/spec/generator_test_results_spec.rb +107 -107
  265. data/spec/par_map_spec.rb +57 -57
  266. data/spec/preprocessinator_extractor_spec.rb +45 -45
  267. data/spec/preprocessinator_includes_handler_spec.rb +202 -186
  268. data/spec/reportinator_spec.rb +19 -19
  269. data/spec/spec_helper.rb +27 -27
  270. data/spec/spec_system_helper.rb +575 -481
  271. data/spec/support/test_example.fail +22 -22
  272. data/spec/support/test_example.pass +22 -22
  273. data/spec/support/test_example_empty.pass +14 -14
  274. data/spec/support/test_example_ignore.pass +22 -22
  275. data/spec/support/test_example_mangled.pass +20 -20
  276. data/spec/support/test_example_with_time.pass +22 -22
  277. data/spec/system/deployment_spec.rb +219 -197
  278. data/spec/system_utils_spec.rb +56 -56
  279. data/spec/target_loader_spec.rb +30 -30
  280. data/spec/tool_executor_helper_spec.rb +310 -310
  281. data/spec/uncatagorized_specs_spec.rb +8 -8
  282. data/vendor/behaviors/Manifest.txt +9 -9
  283. data/vendor/behaviors/Rakefile +19 -19
  284. data/vendor/behaviors/lib/behaviors.rb +76 -76
  285. data/vendor/behaviors/lib/behaviors/reporttask.rb +158 -158
  286. data/vendor/behaviors/test/behaviors_tasks_test.rb +73 -73
  287. data/vendor/behaviors/test/behaviors_test.rb +50 -50
  288. data/vendor/behaviors/test/tasks_test/Rakefile +19 -19
  289. data/vendor/behaviors/test/tasks_test/lib/user.rb +2 -2
  290. data/vendor/behaviors/test/tasks_test/test/user_test.rb +17 -17
  291. data/vendor/c_exception/Gemfile +4 -4
  292. data/vendor/c_exception/Gemfile.lock +12 -12
  293. data/vendor/c_exception/LICENSE.txt +30 -30
  294. data/vendor/c_exception/README.md +162 -162
  295. data/vendor/c_exception/Rakefile +42 -42
  296. data/vendor/c_exception/docs/CException.md +292 -292
  297. data/vendor/c_exception/docs/ThrowTheSwitchCodingStandard.md +207 -207
  298. data/vendor/c_exception/lib/CException.c +46 -46
  299. data/vendor/c_exception/lib/CException.h +115 -110
  300. data/vendor/c_exception/makefile +23 -23
  301. data/vendor/c_exception/test/CExceptionConfig.h +46 -46
  302. data/vendor/c_exception/test/TestException.c +391 -391
  303. data/vendor/c_exception/test/TestException_Runner.c +67 -67
  304. data/vendor/c_exception/vendor/unity/README.md +220 -0
  305. data/vendor/c_exception/vendor/unity/auto/colour_prompt.rb +118 -0
  306. data/vendor/c_exception/vendor/unity/auto/colour_reporter.rb +39 -0
  307. data/vendor/c_exception/vendor/unity/auto/generate_config.yml +36 -0
  308. data/vendor/c_exception/vendor/unity/auto/generate_module.rb +308 -0
  309. data/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +437 -0
  310. data/vendor/c_exception/vendor/unity/auto/parse_output.rb +220 -0
  311. data/vendor/c_exception/vendor/unity/auto/stylize_as_junit.rb +252 -0
  312. data/vendor/c_exception/vendor/unity/auto/test_file_filter.rb +25 -0
  313. data/vendor/c_exception/vendor/unity/auto/type_sanitizer.rb +6 -0
  314. data/vendor/c_exception/vendor/unity/auto/unity_test_summary.py +139 -0
  315. data/vendor/c_exception/vendor/unity/auto/unity_test_summary.rb +136 -0
  316. data/vendor/c_exception/vendor/unity/auto/unity_to_junit.py +146 -0
  317. data/vendor/c_exception/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +207 -0
  318. data/vendor/c_exception/vendor/unity/docs/UnityAssertionsCheatSheetSuitableforPrintingandPossiblyFraming.pdf +0 -0
  319. data/vendor/c_exception/vendor/unity/docs/UnityAssertionsReference.md +716 -0
  320. data/vendor/c_exception/vendor/unity/docs/UnityConfigurationGuide.md +398 -0
  321. data/vendor/c_exception/vendor/unity/docs/UnityGettingStartedGuide.md +191 -0
  322. data/vendor/c_exception/vendor/unity/docs/UnityHelperScriptsGuide.md +242 -0
  323. data/vendor/{cmock → c_exception}/vendor/unity/docs/license.txt +21 -21
  324. data/vendor/c_exception/vendor/unity/examples/example_1/makefile +71 -0
  325. data/vendor/c_exception/vendor/unity/examples/example_1/readme.txt +5 -0
  326. data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode.c +24 -0
  327. data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode.h +3 -0
  328. data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.c +11 -0
  329. data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.h +2 -0
  330. data/vendor/c_exception/vendor/unity/examples/example_1/test/TestProductionCode.c +62 -0
  331. data/vendor/c_exception/vendor/unity/examples/example_1/test/TestProductionCode2.c +31 -0
  332. data/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -0
  333. data/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -0
  334. data/vendor/c_exception/vendor/unity/examples/example_2/makefile +70 -0
  335. data/vendor/c_exception/vendor/unity/examples/example_2/readme.txt +5 -0
  336. data/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode.c +24 -0
  337. data/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode.h +3 -0
  338. data/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode2.c +11 -0
  339. data/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode2.h +2 -0
  340. data/vendor/c_exception/vendor/unity/examples/example_2/test/TestProductionCode.c +64 -0
  341. data/vendor/c_exception/vendor/unity/examples/example_2/test/TestProductionCode2.c +33 -0
  342. data/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +9 -0
  343. data/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +11 -0
  344. data/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/all_tests.c +12 -0
  345. data/vendor/c_exception/vendor/unity/examples/example_3/helper/UnityHelper.c +10 -0
  346. data/vendor/c_exception/vendor/unity/examples/example_3/helper/UnityHelper.h +12 -0
  347. data/vendor/c_exception/vendor/unity/examples/example_3/rakefile.rb +43 -0
  348. data/vendor/c_exception/vendor/unity/examples/example_3/rakefile_helper.rb +249 -0
  349. data/vendor/c_exception/vendor/unity/examples/example_3/readme.txt +13 -0
  350. data/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode.c +24 -0
  351. data/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode.h +3 -0
  352. data/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode2.c +11 -0
  353. data/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode2.h +2 -0
  354. data/vendor/c_exception/vendor/unity/examples/example_3/target_gcc_32.yml +46 -0
  355. data/vendor/c_exception/vendor/unity/examples/example_3/test/TestProductionCode.c +62 -0
  356. data/vendor/c_exception/vendor/unity/examples/example_3/test/TestProductionCode2.c +31 -0
  357. data/vendor/c_exception/vendor/unity/examples/unity_config.h +237 -0
  358. data/vendor/c_exception/vendor/unity/extras/eclipse/error_parsers.txt +26 -0
  359. data/vendor/c_exception/vendor/unity/extras/fixture/rakefile.rb +48 -0
  360. data/vendor/c_exception/vendor/unity/extras/fixture/rakefile_helper.rb +178 -0
  361. data/vendor/{cmock → c_exception}/vendor/unity/extras/fixture/readme.txt +8 -8
  362. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +432 -0
  363. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +83 -0
  364. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +51 -0
  365. data/vendor/{unity → c_exception/vendor/unity}/extras/fixture/src/unity_fixture_malloc_overrides.h +47 -47
  366. data/vendor/c_exception/vendor/unity/extras/fixture/test/Makefile +74 -0
  367. data/vendor/c_exception/vendor/unity/extras/fixture/test/main/AllTests.c +22 -0
  368. data/vendor/c_exception/vendor/unity/extras/fixture/test/template_fixture_tests.c +39 -0
  369. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +543 -0
  370. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +57 -0
  371. data/vendor/{cmock → c_exception}/vendor/unity/extras/fixture/test/unity_output_Spy.c +57 -57
  372. data/vendor/{cmock → c_exception}/vendor/unity/extras/fixture/test/unity_output_Spy.h +17 -17
  373. data/vendor/c_exception/vendor/unity/release/build.info +2 -0
  374. data/vendor/c_exception/vendor/unity/release/version.info +2 -0
  375. data/vendor/c_exception/vendor/unity/src/unity.c +1517 -0
  376. data/vendor/c_exception/vendor/unity/src/unity.h +339 -0
  377. data/vendor/c_exception/vendor/unity/src/unity_internals.h +784 -0
  378. data/vendor/c_exception/vendor/unity/test/Makefile +63 -0
  379. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_cmd.c +61 -0
  380. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_def.c +57 -0
  381. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.c +55 -0
  382. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.h +15 -0
  383. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_cmd.c +80 -0
  384. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_def.c +76 -0
  385. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.c +75 -0
  386. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.h +13 -0
  387. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new1.c +89 -0
  388. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new2.c +89 -0
  389. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_param.c +77 -0
  390. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run1.c +89 -0
  391. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run2.c +89 -0
  392. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_yaml.c +90 -0
  393. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_new1.c +67 -0
  394. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_new2.c +70 -0
  395. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_param.c +58 -0
  396. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_run1.c +67 -0
  397. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_run2.c +70 -0
  398. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_yaml.c +71 -0
  399. data/vendor/c_exception/vendor/unity/test/rakefile +125 -0
  400. data/vendor/c_exception/vendor/unity/test/rakefile_helper.rb +260 -0
  401. data/vendor/c_exception/vendor/unity/test/spec/generate_module_existing_file_spec.rb +158 -0
  402. data/vendor/c_exception/vendor/unity/test/targets/clang_file.yml +78 -0
  403. data/vendor/c_exception/vendor/unity/test/targets/clang_strict.yml +78 -0
  404. data/vendor/c_exception/vendor/unity/test/targets/gcc_32.yml +49 -0
  405. data/vendor/c_exception/vendor/unity/test/targets/gcc_64.yml +50 -0
  406. data/vendor/c_exception/vendor/unity/test/targets/gcc_auto_limits.yml +47 -0
  407. data/vendor/c_exception/vendor/unity/test/targets/gcc_auto_stdint.yml +59 -0
  408. data/vendor/c_exception/vendor/unity/test/targets/gcc_manual_math.yml +47 -0
  409. data/vendor/c_exception/vendor/unity/test/targets/hitech_picc18.yml +101 -0
  410. data/vendor/c_exception/vendor/unity/test/targets/iar_arm_v4.yml +90 -0
  411. data/vendor/c_exception/vendor/unity/test/targets/iar_arm_v5.yml +80 -0
  412. data/vendor/c_exception/vendor/unity/test/targets/iar_arm_v5_3.yml +80 -0
  413. data/vendor/c_exception/vendor/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +94 -0
  414. data/vendor/c_exception/vendor/unity/test/targets/iar_cortexm3_v5.yml +84 -0
  415. data/vendor/c_exception/vendor/unity/test/targets/iar_msp430.yml +95 -0
  416. data/vendor/c_exception/vendor/unity/test/targets/iar_sh2a_v6.yml +86 -0
  417. data/vendor/c_exception/vendor/unity/test/testdata/CException.h +11 -0
  418. data/vendor/c_exception/vendor/unity/test/testdata/Defs.h +8 -0
  419. data/vendor/c_exception/vendor/unity/test/testdata/cmock.h +14 -0
  420. data/vendor/c_exception/vendor/unity/test/testdata/mockMock.h +13 -0
  421. data/vendor/c_exception/vendor/unity/test/testdata/testRunnerGenerator.c +183 -0
  422. data/vendor/c_exception/vendor/unity/test/testdata/testRunnerGeneratorSmall.c +67 -0
  423. data/vendor/c_exception/vendor/unity/test/testdata/testRunnerGeneratorWithMocks.c +192 -0
  424. data/vendor/c_exception/vendor/unity/test/tests/test_generate_test_runner.rb +1252 -0
  425. data/vendor/c_exception/vendor/unity/test/tests/testparameterized.c +110 -0
  426. data/vendor/c_exception/vendor/unity/test/tests/testunity.c +4993 -0
  427. data/vendor/cmock/Gemfile +9 -9
  428. data/vendor/cmock/{docs/license.txt → LICENSE.txt} +18 -18
  429. data/vendor/cmock/README.md +34 -34
  430. data/vendor/cmock/config/production_environment.rb +14 -14
  431. data/vendor/cmock/config/test_environment.rb +16 -16
  432. data/vendor/cmock/docs/CMock_Summary.md +689 -603
  433. data/vendor/cmock/docs/ThrowTheSwitchCodingStandard.md +207 -207
  434. data/vendor/cmock/examples/make_example/Makefile +30 -30
  435. data/vendor/cmock/examples/make_example/src/foo.c +5 -5
  436. data/vendor/cmock/examples/make_example/src/foo.h +5 -5
  437. data/vendor/cmock/examples/make_example/src/main.c +15 -15
  438. data/vendor/cmock/examples/make_example/test/test_foo.c +17 -17
  439. data/vendor/cmock/examples/make_example/test/test_main.c +15 -15
  440. data/vendor/cmock/examples/temp_sensor/gcc.yml +44 -44
  441. data/vendor/cmock/examples/temp_sensor/iar_v4.yml +92 -92
  442. data/vendor/cmock/examples/temp_sensor/iar_v5.yml +81 -81
  443. data/vendor/cmock/examples/temp_sensor/rakefile.rb +42 -42
  444. data/vendor/cmock/examples/temp_sensor/rakefile_helper.rb +272 -272
  445. data/vendor/cmock/examples/temp_sensor/src/AT91SAM7X256.h +2556 -2556
  446. data/vendor/cmock/examples/temp_sensor/src/AdcConductor.c +42 -42
  447. data/vendor/cmock/examples/temp_sensor/src/AdcConductor.h +11 -11
  448. data/vendor/cmock/examples/temp_sensor/src/AdcHardware.c +27 -27
  449. data/vendor/cmock/examples/temp_sensor/src/AdcHardware.h +9 -9
  450. data/vendor/cmock/examples/temp_sensor/src/AdcHardwareConfigurator.c +18 -18
  451. data/vendor/cmock/examples/temp_sensor/src/AdcHardwareConfigurator.h +10 -10
  452. data/vendor/cmock/examples/temp_sensor/src/AdcModel.c +33 -33
  453. data/vendor/cmock/examples/temp_sensor/src/AdcModel.h +13 -13
  454. data/vendor/cmock/examples/temp_sensor/src/AdcTemperatureSensor.c +51 -51
  455. data/vendor/cmock/examples/temp_sensor/src/AdcTemperatureSensor.h +10 -10
  456. data/vendor/cmock/examples/temp_sensor/src/Executor.c +25 -25
  457. data/vendor/cmock/examples/temp_sensor/src/Executor.h +9 -9
  458. data/vendor/cmock/examples/temp_sensor/src/IntrinsicsWrapper.c +18 -18
  459. data/vendor/cmock/examples/temp_sensor/src/IntrinsicsWrapper.h +7 -7
  460. data/vendor/cmock/examples/temp_sensor/src/Main.c +46 -46
  461. data/vendor/cmock/examples/temp_sensor/src/Main.h +7 -7
  462. data/vendor/cmock/examples/temp_sensor/src/Model.c +10 -10
  463. data/vendor/cmock/examples/temp_sensor/src/Model.h +8 -8
  464. data/vendor/cmock/examples/temp_sensor/src/ModelConfig.h +7 -7
  465. data/vendor/cmock/examples/temp_sensor/src/TaskScheduler.c +72 -72
  466. data/vendor/cmock/examples/temp_sensor/src/TaskScheduler.h +11 -11
  467. data/vendor/cmock/examples/temp_sensor/src/TemperatureCalculator.c +27 -27
  468. data/vendor/cmock/examples/temp_sensor/src/TemperatureCalculator.h +6 -6
  469. data/vendor/cmock/examples/temp_sensor/src/TemperatureFilter.c +39 -39
  470. data/vendor/cmock/examples/temp_sensor/src/TemperatureFilter.h +10 -10
  471. data/vendor/cmock/examples/temp_sensor/src/TimerConductor.c +15 -15
  472. data/vendor/cmock/examples/temp_sensor/src/TimerConductor.h +9 -9
  473. data/vendor/cmock/examples/temp_sensor/src/TimerConfigurator.c +51 -51
  474. data/vendor/cmock/examples/temp_sensor/src/TimerConfigurator.h +15 -15
  475. data/vendor/cmock/examples/temp_sensor/src/TimerHardware.c +15 -15
  476. data/vendor/cmock/examples/temp_sensor/src/TimerHardware.h +8 -8
  477. data/vendor/cmock/examples/temp_sensor/src/TimerInterruptConfigurator.c +55 -55
  478. data/vendor/cmock/examples/temp_sensor/src/TimerInterruptConfigurator.h +13 -13
  479. data/vendor/cmock/examples/temp_sensor/src/TimerInterruptHandler.c +25 -25
  480. data/vendor/cmock/examples/temp_sensor/src/TimerInterruptHandler.h +10 -10
  481. data/vendor/cmock/examples/temp_sensor/src/TimerModel.c +9 -9
  482. data/vendor/cmock/examples/temp_sensor/src/TimerModel.h +8 -8
  483. data/vendor/cmock/examples/temp_sensor/src/Types.h +103 -103
  484. data/vendor/cmock/examples/temp_sensor/src/UsartBaudRateRegisterCalculator.c +18 -18
  485. data/vendor/cmock/examples/temp_sensor/src/UsartBaudRateRegisterCalculator.h +6 -6
  486. data/vendor/cmock/examples/temp_sensor/src/UsartConductor.c +21 -21
  487. data/vendor/cmock/examples/temp_sensor/src/UsartConductor.h +7 -7
  488. data/vendor/cmock/examples/temp_sensor/src/UsartConfigurator.c +39 -39
  489. data/vendor/cmock/examples/temp_sensor/src/UsartConfigurator.h +13 -13
  490. data/vendor/cmock/examples/temp_sensor/src/UsartHardware.c +22 -22
  491. data/vendor/cmock/examples/temp_sensor/src/UsartHardware.h +9 -9
  492. data/vendor/cmock/examples/temp_sensor/src/UsartModel.c +34 -34
  493. data/vendor/cmock/examples/temp_sensor/src/UsartModel.h +10 -10
  494. data/vendor/cmock/examples/temp_sensor/src/UsartPutChar.c +16 -16
  495. data/vendor/cmock/examples/temp_sensor/src/UsartPutChar.h +8 -8
  496. data/vendor/cmock/examples/temp_sensor/src/UsartTransmitBufferStatus.c +7 -7
  497. data/vendor/cmock/examples/temp_sensor/src/UsartTransmitBufferStatus.h +8 -8
  498. data/vendor/cmock/examples/temp_sensor/test/TestAdcConductor.c +121 -121
  499. data/vendor/cmock/examples/temp_sensor/test/TestAdcHardware.c +44 -44
  500. data/vendor/cmock/examples/temp_sensor/test/TestAdcHardwareConfigurator.c +43 -43
  501. data/vendor/cmock/examples/temp_sensor/test/TestAdcModel.c +33 -33
  502. data/vendor/cmock/examples/temp_sensor/test/TestAdcTemperatureSensor.c +47 -47
  503. data/vendor/cmock/examples/temp_sensor/test/TestExecutor.c +36 -36
  504. data/vendor/cmock/examples/temp_sensor/test/TestMain.c +24 -24
  505. data/vendor/cmock/examples/temp_sensor/test/TestModel.c +20 -20
  506. data/vendor/cmock/examples/temp_sensor/test/TestTaskScheduler.c +104 -104
  507. data/vendor/cmock/examples/temp_sensor/test/TestTemperatureCalculator.c +33 -33
  508. data/vendor/cmock/examples/temp_sensor/test/TestTemperatureFilter.c +69 -69
  509. data/vendor/cmock/examples/temp_sensor/test/TestTimerConductor.c +32 -32
  510. data/vendor/cmock/examples/temp_sensor/test/TestTimerConfigurator.c +112 -112
  511. data/vendor/cmock/examples/temp_sensor/test/TestTimerHardware.c +26 -26
  512. data/vendor/cmock/examples/temp_sensor/test/TestTimerInterruptConfigurator.c +78 -78
  513. data/vendor/cmock/examples/temp_sensor/test/TestTimerInterruptHandler.c +66 -66
  514. data/vendor/cmock/examples/temp_sensor/test/TestTimerModel.c +18 -18
  515. data/vendor/cmock/examples/temp_sensor/test/TestUsartBaudRateRegisterCalculator.c +21 -21
  516. data/vendor/cmock/examples/temp_sensor/test/TestUsartConductor.c +40 -40
  517. data/vendor/cmock/examples/temp_sensor/test/TestUsartConfigurator.c +77 -77
  518. data/vendor/cmock/examples/temp_sensor/test/TestUsartHardware.c +37 -37
  519. data/vendor/cmock/examples/temp_sensor/test/TestUsartModel.c +40 -40
  520. data/vendor/cmock/examples/temp_sensor/test/TestUsartPutChar.c +43 -43
  521. data/vendor/cmock/examples/temp_sensor/test/TestUsartTransmitBufferStatus.c +22 -22
  522. data/vendor/cmock/lib/cmock.rb +86 -86
  523. data/vendor/cmock/lib/cmock_config.rb +153 -145
  524. data/vendor/cmock/lib/cmock_file_writer.rb +44 -44
  525. data/vendor/cmock/lib/cmock_generator.rb +268 -264
  526. data/vendor/cmock/lib/cmock_generator_plugin_array.rb +63 -63
  527. data/vendor/cmock/lib/cmock_generator_plugin_callback.rb +88 -98
  528. data/vendor/cmock/lib/cmock_generator_plugin_cexception.rb +51 -51
  529. data/vendor/cmock/lib/cmock_generator_plugin_expect.rb +103 -104
  530. data/vendor/cmock/lib/cmock_generator_plugin_expect_any_args.rb +53 -54
  531. data/vendor/cmock/lib/cmock_generator_plugin_ignore.rb +75 -75
  532. data/vendor/cmock/lib/cmock_generator_plugin_ignore_arg.rb +42 -42
  533. data/vendor/cmock/lib/cmock_generator_plugin_return_thru_ptr.rb +79 -73
  534. data/vendor/cmock/lib/cmock_generator_utils.rb +253 -240
  535. data/vendor/cmock/lib/cmock_header_parser.rb +364 -337
  536. data/vendor/cmock/lib/cmock_plugin_manager.rb +55 -55
  537. data/vendor/cmock/lib/cmock_unityhelper_parser.rb +75 -75
  538. data/vendor/cmock/meson.build +72 -0
  539. data/vendor/cmock/scripts/create_makefile.rb +202 -202
  540. data/vendor/cmock/scripts/create_mock.rb +8 -8
  541. data/vendor/cmock/scripts/create_runner.rb +20 -20
  542. data/vendor/cmock/scripts/test_summary.rb +19 -19
  543. data/vendor/cmock/src/cmock.c +216 -210
  544. data/vendor/cmock/src/cmock.h +40 -38
  545. data/vendor/cmock/src/cmock_internals.h +91 -89
  546. data/vendor/cmock/src/meson.build +17 -0
  547. data/vendor/cmock/test/c/TestCMockC.c +333 -323
  548. data/vendor/cmock/test/c/TestCMockC.yml +14 -13
  549. data/vendor/cmock/test/c/TestCMockCDynamic.c +186 -186
  550. data/vendor/cmock/test/c/TestCMockCDynamic.yml +12 -12
  551. data/vendor/cmock/test/c/TestCMockCDynamic_Runner.c +36 -36
  552. data/vendor/cmock/test/c/TestCMockC_Runner.c +41 -39
  553. data/vendor/cmock/test/iar/iar_v4/Resource/at91SAM7X256_FLASH.xcl +185 -185
  554. data/vendor/cmock/test/iar/iar_v4/Resource/at91SAM7X256_RAM.xcl +185 -185
  555. data/vendor/cmock/test/iar/iar_v4/Resource/ioat91sam7x256.ddf +2259 -2259
  556. data/vendor/cmock/test/iar/iar_v4/cmock_demo.dep +3691 -3691
  557. data/vendor/cmock/test/iar/iar_v4/cmock_demo.ewp +2581 -2581
  558. data/vendor/cmock/test/iar/iar_v4/incIAR/AT91SAM7X-EK.h +61 -61
  559. data/vendor/cmock/test/iar/iar_v4/incIAR/AT91SAM7X256.inc +2314 -2314
  560. data/vendor/cmock/test/iar/iar_v4/incIAR/AT91SAM7X256.rdf +4704 -4704
  561. data/vendor/cmock/test/iar/iar_v4/incIAR/AT91SAM7X256.tcl +3407 -3407
  562. data/vendor/cmock/test/iar/iar_v4/incIAR/AT91SAM7X256_inc.h +2268 -2268
  563. data/vendor/cmock/test/iar/iar_v4/incIAR/ioat91sam7x256.h +4380 -4380
  564. data/vendor/cmock/test/iar/iar_v4/incIAR/lib_AT91SAM7X256.h +4211 -4211
  565. data/vendor/cmock/test/iar/iar_v4/settings/cmock_demo.cspy.bat +32 -32
  566. data/vendor/cmock/test/iar/iar_v4/srcIAR/Cstartup.s79 +265 -265
  567. data/vendor/cmock/test/iar/iar_v4/srcIAR/Cstartup_SAM7.c +98 -98
  568. data/vendor/cmock/test/iar/iar_v5/Resource/at91SAM7X256_FLASH.icf +43 -43
  569. data/vendor/cmock/test/iar/iar_v5/Resource/at91SAM7X256_RAM.icf +42 -42
  570. data/vendor/cmock/test/iar/iar_v5/cmock_demo.dep +4204 -4204
  571. data/vendor/cmock/test/iar/iar_v5/cmock_demo.ewp +2426 -2426
  572. data/vendor/cmock/test/iar/iar_v5/incIAR/AT91SAM7X-EK.h +61 -61
  573. data/vendor/cmock/test/iar/iar_v5/incIAR/AT91SAM7X256_inc.h +2268 -2268
  574. data/vendor/cmock/test/iar/iar_v5/incIAR/lib_AT91SAM7X256.h +4211 -4211
  575. data/vendor/cmock/test/iar/iar_v5/incIAR/project.h +30 -30
  576. data/vendor/cmock/test/iar/iar_v5/settings/BasicInterrupt_SAM7X.cspy.bat +33 -33
  577. data/vendor/cmock/test/iar/iar_v5/settings/BasicInterrupt_SAM7X_FLASH_Debug.jlink +12 -12
  578. data/vendor/cmock/test/iar/iar_v5/settings/cmock_demo.cspy.bat +33 -33
  579. data/vendor/cmock/test/iar/iar_v5/settings/cmock_demo_Binary.jlink +12 -12
  580. data/vendor/cmock/test/iar/iar_v5/settings/cmock_demo_FLASH_Debug.jlink +12 -12
  581. data/vendor/cmock/test/iar/iar_v5/settings/cmock_demo_RAM_Debug.jlink +12 -12
  582. data/vendor/cmock/test/iar/iar_v5/srcIAR/Cstartup.s +299 -299
  583. data/vendor/cmock/test/iar/iar_v5/srcIAR/Cstartup_SAM7.c +98 -98
  584. data/vendor/cmock/test/rakefile +106 -106
  585. data/vendor/cmock/test/rakefile_helper.rb +382 -381
  586. data/vendor/cmock/test/system/systest_generator.rb +193 -194
  587. data/vendor/cmock/test/system/test_compilation/callingconv.h +11 -11
  588. data/vendor/cmock/test/system/test_compilation/config.yml +9 -9
  589. data/vendor/cmock/test/system/test_compilation/const.h +37 -37
  590. data/vendor/cmock/test/system/test_compilation/osek.h +275 -275
  591. data/vendor/cmock/test/system/test_compilation/parsing.h +89 -52
  592. data/vendor/cmock/test/system/test_interactions/all_plugins_but_other_limits.yml +375 -375
  593. data/vendor/cmock/test/system/test_interactions/all_plugins_coexist.yml +459 -459
  594. data/vendor/cmock/test/system/test_interactions/array_and_pointer_handling.yml +446 -446
  595. data/vendor/cmock/test/system/test_interactions/basic_expect_and_return.yml +124 -124
  596. data/vendor/cmock/test/system/test_interactions/const_primitives_handling.yml +87 -87
  597. data/vendor/cmock/test/system/test_interactions/doesnt_leave_details_behind.yml +308 -308
  598. data/vendor/cmock/test/system/test_interactions/enforce_strict_ordering.yml +247 -247
  599. data/vendor/cmock/test/system/test_interactions/expect_and_return_custom_types.yml +108 -108
  600. data/vendor/cmock/test/system/test_interactions/expect_and_return_treat_as.yml +173 -173
  601. data/vendor/cmock/test/system/test_interactions/expect_and_throw.yml +170 -170
  602. data/vendor/cmock/test/system/test_interactions/expect_any_args.yml +238 -238
  603. data/vendor/cmock/test/system/test_interactions/fancy_pointer_handling.yml +210 -210
  604. data/vendor/cmock/test/system/test_interactions/function_pointer_handling.yml +82 -82
  605. data/vendor/cmock/test/system/test_interactions/ignore_and_return.yml +329 -329
  606. data/vendor/cmock/test/system/test_interactions/ignore_strict_mock_calling.yml +37 -37
  607. data/vendor/cmock/test/system/test_interactions/newer_standards_stuff1.yml +52 -52
  608. data/vendor/cmock/test/system/test_interactions/nonstandard_parsed_stuff_1.yml +91 -91
  609. data/vendor/cmock/test/system/test_interactions/nonstandard_parsed_stuff_2.yml +59 -59
  610. data/vendor/cmock/test/system/test_interactions/out_of_memory.yml +65 -65
  611. data/vendor/cmock/test/system/test_interactions/parsing_challenges.yml +242 -242
  612. data/vendor/cmock/test/system/test_interactions/return_thru_ptr_and_expect_any_args.yml +235 -235
  613. data/vendor/cmock/test/system/test_interactions/return_thru_ptr_ignore_arg.yml +231 -231
  614. data/vendor/cmock/test/system/test_interactions/struct_union_enum_expect_and_return.yml +277 -277
  615. data/vendor/cmock/test/system/test_interactions/struct_union_enum_expect_and_return_with_plugins.yml +280 -280
  616. data/vendor/cmock/test/system/test_interactions/stubs_with_callbacks.yml +221 -221
  617. data/vendor/cmock/test/system/test_interactions/unity_64bit_support.yml +77 -77
  618. data/vendor/cmock/test/system/test_interactions/unity_ignores.yml +139 -139
  619. data/vendor/cmock/test/system/test_interactions/unity_void_pointer_compare.yml +91 -0
  620. data/vendor/cmock/test/targets/clang_strict.yml +90 -90
  621. data/vendor/cmock/test/targets/gcc.yml +58 -58
  622. data/vendor/cmock/test/targets/gcc_64.yml +58 -58
  623. data/vendor/cmock/test/targets/gcc_tiny.yml +80 -80
  624. data/vendor/cmock/test/targets/iar_arm_v4.yml +110 -110
  625. data/vendor/cmock/test/targets/iar_arm_v5.yml +95 -95
  626. data/vendor/cmock/test/test_helper.rb +44 -44
  627. data/vendor/cmock/test/unit/cmock_config_test.rb +120 -120
  628. data/vendor/cmock/test/unit/cmock_config_test.yml +5 -5
  629. data/vendor/cmock/test/unit/cmock_file_writer_test.rb +27 -27
  630. data/vendor/cmock/test/unit/cmock_generator_main_test.rb +548 -542
  631. data/vendor/cmock/test/unit/cmock_generator_plugin_array_test.rb +141 -141
  632. data/vendor/cmock/test/unit/cmock_generator_plugin_callback_test.rb +281 -259
  633. data/vendor/cmock/test/unit/cmock_generator_plugin_cexception_test.rb +96 -96
  634. data/vendor/cmock/test/unit/cmock_generator_plugin_expect_a_test.rb +183 -186
  635. data/vendor/cmock/test/unit/cmock_generator_plugin_expect_any_args_test.rb +67 -60
  636. data/vendor/cmock/test/unit/cmock_generator_plugin_expect_b_test.rb +200 -203
  637. data/vendor/cmock/test/unit/cmock_generator_plugin_ignore_arg_test.rb +116 -116
  638. data/vendor/cmock/test/unit/cmock_generator_plugin_ignore_test.rb +105 -105
  639. data/vendor/cmock/test/unit/cmock_generator_plugin_return_thru_ptr_test.rb +136 -136
  640. data/vendor/cmock/test/unit/cmock_generator_utils_test.rb +415 -394
  641. data/vendor/cmock/test/unit/cmock_header_parser_test.rb +1728 -1699
  642. data/vendor/cmock/test/unit/cmock_plugin_manager_test.rb +100 -91
  643. data/vendor/cmock/test/unit/cmock_unityhelper_parser_test.rb +223 -223
  644. data/vendor/cmock/vendor/behaviors/Manifest.txt +9 -9
  645. data/vendor/cmock/vendor/behaviors/Rakefile +19 -19
  646. data/vendor/cmock/vendor/behaviors/lib/behaviors.rb +76 -76
  647. data/vendor/cmock/vendor/behaviors/lib/behaviors/reporttask.rb +158 -158
  648. data/vendor/cmock/vendor/behaviors/test/behaviors_tasks_test.rb +73 -73
  649. data/vendor/cmock/vendor/behaviors/test/behaviors_test.rb +50 -50
  650. data/vendor/cmock/vendor/behaviors/test/tasks_test/Rakefile +19 -19
  651. data/vendor/cmock/vendor/behaviors/test/tasks_test/lib/user.rb +2 -2
  652. data/vendor/cmock/vendor/behaviors/test/tasks_test/test/user_test.rb +17 -17
  653. data/vendor/cmock/vendor/c_exception/Gemfile +4 -4
  654. data/vendor/cmock/vendor/c_exception/Gemfile.lock +12 -12
  655. data/vendor/cmock/vendor/c_exception/LICENSE.txt +30 -30
  656. data/vendor/cmock/vendor/c_exception/README.md +162 -162
  657. data/vendor/cmock/vendor/c_exception/Rakefile +42 -42
  658. data/vendor/cmock/vendor/c_exception/docs/CException.md +292 -292
  659. data/vendor/cmock/vendor/c_exception/docs/ThrowTheSwitchCodingStandard.md +207 -207
  660. data/vendor/cmock/vendor/c_exception/lib/CException.c +46 -46
  661. data/vendor/cmock/vendor/c_exception/lib/CException.h +115 -110
  662. data/vendor/cmock/vendor/c_exception/makefile +23 -23
  663. data/vendor/cmock/vendor/c_exception/test/CExceptionConfig.h +46 -46
  664. data/vendor/cmock/vendor/c_exception/test/TestException.c +391 -391
  665. data/vendor/cmock/vendor/c_exception/test/TestException_Runner.c +67 -67
  666. data/vendor/cmock/vendor/unity/CMakeLists.txt +31 -0
  667. data/vendor/{unity/docs/license.txt → cmock/vendor/unity/LICENSE.txt} +21 -21
  668. data/vendor/cmock/vendor/unity/README.md +191 -231
  669. data/vendor/cmock/vendor/unity/auto/colour_prompt.rb +119 -118
  670. data/vendor/cmock/vendor/unity/auto/colour_reporter.rb +39 -39
  671. data/vendor/cmock/vendor/unity/auto/generate_config.yml +36 -36
  672. data/vendor/cmock/vendor/unity/auto/generate_module.rb +309 -308
  673. data/vendor/cmock/vendor/unity/auto/generate_test_runner.rb +495 -457
  674. data/vendor/cmock/vendor/unity/auto/parse_output.rb +322 -323
  675. data/vendor/cmock/vendor/unity/auto/run_test.erb +36 -0
  676. data/vendor/cmock/vendor/unity/auto/stylize_as_junit.rb +251 -252
  677. data/vendor/cmock/vendor/unity/auto/test_file_filter.rb +25 -25
  678. data/vendor/cmock/vendor/unity/auto/type_sanitizer.rb +6 -6
  679. data/vendor/cmock/vendor/unity/auto/unity_test_summary.py +139 -139
  680. data/vendor/cmock/vendor/unity/auto/unity_test_summary.rb +135 -136
  681. data/vendor/cmock/vendor/unity/auto/unity_to_junit.py +146 -146
  682. data/vendor/cmock/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +206 -206
  683. data/vendor/cmock/vendor/unity/docs/UnityAssertionsReference.md +850 -779
  684. data/vendor/cmock/vendor/unity/docs/UnityConfigurationGuide.md +541 -433
  685. data/vendor/cmock/vendor/unity/docs/UnityGettingStartedGuide.md +251 -192
  686. data/vendor/cmock/vendor/unity/docs/UnityHelperScriptsGuide.md +266 -260
  687. data/vendor/cmock/vendor/unity/examples/example_1/makefile +72 -71
  688. data/vendor/cmock/vendor/unity/examples/example_1/readme.txt +4 -4
  689. data/vendor/cmock/vendor/unity/examples/example_1/src/ProductionCode.c +24 -24
  690. data/vendor/cmock/vendor/unity/examples/example_1/src/ProductionCode.h +3 -3
  691. data/vendor/cmock/vendor/unity/examples/example_1/src/ProductionCode2.c +11 -11
  692. data/vendor/cmock/vendor/unity/examples/example_1/src/ProductionCode2.h +2 -2
  693. data/vendor/cmock/vendor/unity/examples/example_1/test/TestProductionCode.c +62 -62
  694. data/vendor/cmock/vendor/unity/examples/example_1/test/TestProductionCode2.c +31 -31
  695. data/vendor/cmock/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -53
  696. data/vendor/cmock/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -57
  697. data/vendor/cmock/vendor/unity/examples/example_2/makefile +71 -70
  698. data/vendor/cmock/vendor/unity/examples/example_2/readme.txt +4 -4
  699. data/vendor/cmock/vendor/unity/examples/example_2/src/ProductionCode.c +24 -24
  700. data/vendor/cmock/vendor/unity/examples/example_2/src/ProductionCode.h +3 -3
  701. data/vendor/cmock/vendor/unity/examples/example_2/src/ProductionCode2.c +11 -11
  702. data/vendor/cmock/vendor/unity/examples/example_2/src/ProductionCode2.h +2 -2
  703. data/vendor/cmock/vendor/unity/examples/example_2/test/TestProductionCode.c +64 -64
  704. data/vendor/cmock/vendor/unity/examples/example_2/test/TestProductionCode2.c +33 -33
  705. data/vendor/cmock/vendor/unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +8 -8
  706. data/vendor/cmock/vendor/unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +10 -10
  707. data/vendor/cmock/vendor/unity/examples/example_2/test/test_runners/all_tests.c +12 -12
  708. data/vendor/cmock/vendor/unity/examples/example_3/helper/UnityHelper.c +10 -10
  709. data/vendor/cmock/vendor/unity/examples/example_3/helper/UnityHelper.h +12 -12
  710. data/vendor/cmock/vendor/unity/examples/example_3/rakefile.rb +38 -43
  711. data/vendor/cmock/vendor/unity/examples/example_3/rakefile_helper.rb +250 -249
  712. data/vendor/cmock/vendor/unity/examples/example_3/readme.txt +13 -13
  713. data/vendor/cmock/vendor/unity/examples/example_3/src/ProductionCode.c +24 -24
  714. data/vendor/cmock/vendor/unity/examples/example_3/src/ProductionCode.h +3 -3
  715. data/vendor/cmock/vendor/unity/examples/example_3/src/ProductionCode2.c +11 -11
  716. data/vendor/cmock/vendor/unity/examples/example_3/src/ProductionCode2.h +2 -2
  717. data/vendor/cmock/vendor/unity/examples/example_3/target_gcc_32.yml +47 -46
  718. data/vendor/cmock/vendor/unity/examples/example_3/test/TestProductionCode.c +62 -62
  719. data/vendor/cmock/vendor/unity/examples/example_3/test/TestProductionCode2.c +31 -31
  720. data/vendor/cmock/vendor/unity/examples/example_4/meson.build +17 -0
  721. data/vendor/cmock/vendor/unity/examples/example_4/readme.txt +15 -0
  722. data/vendor/cmock/vendor/unity/examples/example_4/src/ProductionCode.c +24 -0
  723. data/vendor/cmock/vendor/unity/examples/example_4/src/ProductionCode.h +3 -0
  724. data/vendor/cmock/vendor/unity/examples/example_4/src/ProductionCode2.c +11 -0
  725. data/vendor/cmock/vendor/unity/examples/example_4/src/ProductionCode2.h +2 -0
  726. data/vendor/cmock/vendor/unity/examples/example_4/src/meson.build +21 -0
  727. data/vendor/cmock/vendor/unity/examples/example_4/subprojects/unity.wrap +4 -0
  728. data/vendor/cmock/vendor/unity/examples/example_4/test/TestProductionCode.c +63 -0
  729. data/vendor/cmock/vendor/unity/examples/example_4/test/TestProductionCode2.c +35 -0
  730. data/vendor/cmock/vendor/unity/examples/example_4/test/meson.build +12 -0
  731. data/vendor/cmock/vendor/unity/examples/example_4/test/test_runners/TestProductionCode2_Runner.c +53 -0
  732. data/vendor/cmock/vendor/unity/examples/example_4/test/test_runners/TestProductionCode_Runner.c +57 -0
  733. data/vendor/cmock/vendor/unity/examples/example_4/test/test_runners/meson.build +16 -0
  734. data/vendor/cmock/vendor/unity/examples/unity_config.h +263 -247
  735. data/vendor/cmock/vendor/unity/extras/eclipse/error_parsers.txt +26 -26
  736. data/vendor/cmock/vendor/unity/extras/fixture/rakefile.rb +44 -48
  737. data/vendor/cmock/vendor/unity/extras/fixture/rakefile_helper.rb +183 -178
  738. data/vendor/cmock/vendor/unity/extras/fixture/readme.md +17 -0
  739. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.c +275 -436
  740. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.h +83 -83
  741. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_internals.h +50 -51
  742. data/vendor/cmock/vendor/unity/extras/fixture/test/Makefile +72 -75
  743. data/vendor/cmock/vendor/unity/extras/fixture/test/main/AllTests.c +20 -22
  744. data/vendor/cmock/vendor/unity/extras/fixture/test/template_fixture_tests.c +39 -39
  745. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_Test.c +245 -543
  746. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +32 -57
  747. data/vendor/cmock/vendor/unity/extras/memory/rakefile.rb +45 -0
  748. data/vendor/cmock/vendor/unity/extras/memory/rakefile_helper.rb +187 -0
  749. data/vendor/cmock/vendor/unity/extras/memory/readme.md +49 -0
  750. data/vendor/cmock/vendor/unity/extras/memory/src/unity_memory.c +202 -0
  751. data/vendor/cmock/vendor/unity/extras/{fixture/src/unity_fixture_malloc_overrides.h → memory/src/unity_memory.h} +60 -47
  752. data/vendor/cmock/vendor/unity/extras/memory/test/Makefile +78 -0
  753. data/vendor/cmock/vendor/unity/extras/memory/test/unity_memory_Test.c +325 -0
  754. data/vendor/cmock/vendor/unity/extras/memory/test/unity_memory_TestRunner.c +49 -0
  755. data/vendor/{unity/extras/fixture → cmock/vendor/unity/extras/memory}/test/unity_output_Spy.c +56 -57
  756. data/vendor/{unity/extras/fixture → cmock/vendor/unity/extras/memory}/test/unity_output_Spy.h +16 -17
  757. data/vendor/cmock/vendor/unity/meson.build +69 -0
  758. data/vendor/cmock/vendor/unity/src/CMakeLists.txt +22 -0
  759. data/vendor/cmock/vendor/unity/src/meson.build +16 -0
  760. data/vendor/cmock/vendor/unity/src/unity.c +2085 -1572
  761. data/vendor/cmock/vendor/unity/src/unity.h +617 -503
  762. data/vendor/cmock/vendor/unity/src/unity_internals.h +1002 -924
  763. data/vendor/cmock/vendor/unity/test/Makefile +67 -68
  764. data/vendor/cmock/vendor/unity/test/expectdata/testsample_cmd.c +61 -61
  765. data/vendor/cmock/vendor/unity/test/expectdata/testsample_def.c +57 -57
  766. data/vendor/cmock/vendor/unity/test/expectdata/testsample_head1.c +55 -55
  767. data/vendor/cmock/vendor/unity/test/expectdata/testsample_head1.h +15 -15
  768. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_cmd.c +80 -80
  769. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_def.c +76 -76
  770. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_head1.c +75 -75
  771. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_head1.h +13 -13
  772. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_new1.c +89 -89
  773. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_new2.c +89 -89
  774. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_param.c +77 -77
  775. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_run1.c +89 -89
  776. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_run2.c +89 -89
  777. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_yaml.c +90 -90
  778. data/vendor/cmock/vendor/unity/test/expectdata/testsample_new1.c +67 -67
  779. data/vendor/cmock/vendor/unity/test/expectdata/testsample_new2.c +70 -70
  780. data/vendor/cmock/vendor/unity/test/expectdata/testsample_param.c +58 -58
  781. data/vendor/cmock/vendor/unity/test/expectdata/testsample_run1.c +67 -67
  782. data/vendor/cmock/vendor/unity/test/expectdata/testsample_run2.c +70 -70
  783. data/vendor/cmock/vendor/unity/test/expectdata/testsample_yaml.c +71 -71
  784. data/vendor/cmock/vendor/unity/test/rakefile +124 -125
  785. data/vendor/cmock/vendor/unity/test/rakefile_helper.rb +269 -260
  786. data/vendor/cmock/vendor/unity/test/spec/generate_module_existing_file_spec.rb +158 -158
  787. data/vendor/cmock/vendor/unity/test/targets/ansi.yml +49 -0
  788. data/vendor/cmock/vendor/unity/test/targets/clang_file.yml +78 -78
  789. data/vendor/cmock/vendor/unity/test/targets/clang_strict.yml +78 -78
  790. data/vendor/cmock/vendor/unity/test/targets/gcc_32.yml +49 -49
  791. data/vendor/cmock/vendor/unity/test/targets/gcc_64.yml +50 -50
  792. data/vendor/cmock/vendor/unity/test/targets/gcc_auto_limits.yml +47 -47
  793. data/vendor/cmock/vendor/unity/test/targets/gcc_auto_stdint.yml +59 -59
  794. data/vendor/cmock/vendor/unity/test/targets/gcc_manual_math.yml +47 -47
  795. data/vendor/cmock/vendor/unity/test/targets/hitech_picc18.yml +101 -101
  796. data/vendor/cmock/vendor/unity/test/targets/iar_arm_v4.yml +90 -90
  797. data/vendor/cmock/vendor/unity/test/targets/iar_arm_v5.yml +80 -80
  798. data/vendor/cmock/vendor/unity/test/targets/iar_arm_v5_3.yml +80 -80
  799. data/vendor/cmock/vendor/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +94 -94
  800. data/vendor/cmock/vendor/unity/test/targets/iar_cortexm3_v5.yml +84 -84
  801. data/vendor/cmock/vendor/unity/test/targets/iar_msp430.yml +95 -95
  802. data/vendor/cmock/vendor/unity/test/targets/iar_sh2a_v6.yml +86 -86
  803. data/vendor/cmock/vendor/unity/test/testdata/CException.h +11 -11
  804. data/vendor/cmock/vendor/unity/test/testdata/Defs.h +8 -8
  805. data/vendor/cmock/vendor/unity/test/testdata/cmock.h +14 -14
  806. data/vendor/cmock/vendor/unity/test/testdata/mockMock.h +13 -13
  807. data/vendor/cmock/vendor/unity/test/testdata/testRunnerGenerator.c +189 -186
  808. data/vendor/cmock/vendor/unity/test/testdata/testRunnerGeneratorSmall.c +70 -70
  809. data/vendor/cmock/vendor/unity/test/testdata/testRunnerGeneratorWithMocks.c +197 -195
  810. data/vendor/cmock/vendor/unity/test/tests/test_generate_test_runner.rb +1268 -1252
  811. data/vendor/cmock/vendor/unity/test/tests/testparameterized.c +171 -113
  812. data/vendor/cmock/vendor/unity/test/tests/testunity.c +8168 -5371
  813. data/vendor/deep_merge/MIT-LICENSE +20 -20
  814. data/vendor/deep_merge/README +94 -94
  815. data/vendor/deep_merge/Rakefile +28 -28
  816. data/vendor/deep_merge/lib/deep_merge.rb +211 -211
  817. data/vendor/deep_merge/test/test_deep_merge.rb +553 -553
  818. data/vendor/diy/History.txt +28 -28
  819. data/vendor/diy/README.rdoc +233 -233
  820. data/vendor/diy/Rakefile +33 -33
  821. data/vendor/diy/TODO.txt +9 -9
  822. data/vendor/diy/diy.gemspec +131 -131
  823. data/vendor/diy/lib/diy.rb +403 -403
  824. data/vendor/diy/lib/diy/factory.rb +36 -36
  825. data/vendor/diy/sample_code/car.rb +7 -7
  826. data/vendor/diy/sample_code/chassis.rb +5 -5
  827. data/vendor/diy/sample_code/diy_example.rb +26 -26
  828. data/vendor/diy/sample_code/engine.rb +5 -5
  829. data/vendor/diy/sample_code/objects.yml +10 -10
  830. data/vendor/diy/test/constructor.rb +119 -119
  831. data/vendor/diy/test/diy_test.rb +608 -608
  832. data/vendor/diy/test/factory_test.rb +79 -79
  833. data/vendor/diy/test/files/broken_construction.yml +7 -7
  834. data/vendor/diy/test/files/cat/cat.rb +3 -3
  835. data/vendor/diy/test/files/cat/extra_conflict.yml +5 -5
  836. data/vendor/diy/test/files/cat/heritage.rb +2 -2
  837. data/vendor/diy/test/files/cat/needs_input.yml +3 -3
  838. data/vendor/diy/test/files/cat/the_cat_lineage.rb +1 -1
  839. data/vendor/diy/test/files/dog/dog_model.rb +3 -3
  840. data/vendor/diy/test/files/dog/dog_presenter.rb +3 -3
  841. data/vendor/diy/test/files/dog/dog_view.rb +2 -2
  842. data/vendor/diy/test/files/dog/file_resolver.rb +2 -2
  843. data/vendor/diy/test/files/dog/other_thing.rb +2 -2
  844. data/vendor/diy/test/files/dog/simple.yml +11 -11
  845. data/vendor/diy/test/files/donkey/foo.rb +8 -8
  846. data/vendor/diy/test/files/donkey/foo/bar/qux.rb +7 -7
  847. data/vendor/diy/test/files/factory/beef.rb +5 -5
  848. data/vendor/diy/test/files/factory/dog.rb +6 -6
  849. data/vendor/diy/test/files/factory/factory.yml +19 -19
  850. data/vendor/diy/test/files/factory/farm/llama.rb +7 -7
  851. data/vendor/diy/test/files/factory/farm/pork.rb +7 -7
  852. data/vendor/diy/test/files/factory/kitten.rb +13 -13
  853. data/vendor/diy/test/files/fud/objects.yml +13 -13
  854. data/vendor/diy/test/files/fud/toy.rb +14 -14
  855. data/vendor/diy/test/files/functions/attached_things_builder.rb +1 -1
  856. data/vendor/diy/test/files/functions/invalid_method.yml +4 -4
  857. data/vendor/diy/test/files/functions/method_extractor.rb +2 -2
  858. data/vendor/diy/test/files/functions/nonsingleton_objects.yml +5 -5
  859. data/vendor/diy/test/files/functions/objects.yml +21 -21
  860. data/vendor/diy/test/files/functions/thing.rb +2 -2
  861. data/vendor/diy/test/files/functions/thing_builder.rb +24 -24
  862. data/vendor/diy/test/files/functions/things_builder.rb +2 -2
  863. data/vendor/diy/test/files/gnu/objects.yml +14 -14
  864. data/vendor/diy/test/files/gnu/thinger.rb +7 -7
  865. data/vendor/diy/test/files/goat/base.rb +8 -8
  866. data/vendor/diy/test/files/goat/can.rb +6 -6
  867. data/vendor/diy/test/files/goat/goat.rb +6 -6
  868. data/vendor/diy/test/files/goat/objects.yml +12 -12
  869. data/vendor/diy/test/files/goat/paper.rb +6 -6
  870. data/vendor/diy/test/files/goat/plane.rb +7 -7
  871. data/vendor/diy/test/files/goat/shirt.rb +6 -6
  872. data/vendor/diy/test/files/goat/wings.rb +8 -8
  873. data/vendor/diy/test/files/horse/holder_thing.rb +3 -3
  874. data/vendor/diy/test/files/horse/objects.yml +7 -7
  875. data/vendor/diy/test/files/namespace/animal/bird.rb +5 -5
  876. data/vendor/diy/test/files/namespace/animal/cat.rb +5 -5
  877. data/vendor/diy/test/files/namespace/animal/reptile/hardshell/turtle.rb +8 -8
  878. data/vendor/diy/test/files/namespace/animal/reptile/lizard.rb +7 -7
  879. data/vendor/diy/test/files/namespace/bad_module_specified.yml +8 -8
  880. data/vendor/diy/test/files/namespace/class_name_combine.yml +8 -8
  881. data/vendor/diy/test/files/namespace/no_module_specified.yml +8 -8
  882. data/vendor/diy/test/files/namespace/objects.yml +21 -21
  883. data/vendor/diy/test/files/namespace/road.rb +2 -2
  884. data/vendor/diy/test/files/namespace/sky.rb +2 -2
  885. data/vendor/diy/test/files/namespace/subcontext.yml +22 -22
  886. data/vendor/diy/test/files/non_singleton/air.rb +2 -2
  887. data/vendor/diy/test/files/non_singleton/fat_cat.rb +3 -3
  888. data/vendor/diy/test/files/non_singleton/objects.yml +19 -19
  889. data/vendor/diy/test/files/non_singleton/pig.rb +3 -3
  890. data/vendor/diy/test/files/non_singleton/thread_spinner.rb +3 -3
  891. data/vendor/diy/test/files/non_singleton/tick.rb +3 -3
  892. data/vendor/diy/test/files/non_singleton/yard.rb +2 -2
  893. data/vendor/diy/test/files/yak/core_model.rb +3 -3
  894. data/vendor/diy/test/files/yak/core_presenter.rb +3 -3
  895. data/vendor/diy/test/files/yak/core_view.rb +1 -1
  896. data/vendor/diy/test/files/yak/data_source.rb +1 -1
  897. data/vendor/diy/test/files/yak/fringe_model.rb +3 -3
  898. data/vendor/diy/test/files/yak/fringe_presenter.rb +3 -3
  899. data/vendor/diy/test/files/yak/fringe_view.rb +1 -1
  900. data/vendor/diy/test/files/yak/giant_squid.rb +3 -3
  901. data/vendor/diy/test/files/yak/krill.rb +2 -2
  902. data/vendor/diy/test/files/yak/my_objects.yml +21 -21
  903. data/vendor/diy/test/files/yak/sub_sub_context_test.yml +27 -27
  904. data/vendor/diy/test/test_helper.rb +55 -55
  905. data/vendor/hardmock/CHANGES +78 -78
  906. data/vendor/hardmock/LICENSE +7 -7
  907. data/vendor/hardmock/README +70 -70
  908. data/vendor/hardmock/Rakefile +8 -8
  909. data/vendor/hardmock/config/environment.rb +12 -12
  910. data/vendor/hardmock/lib/assert_error.rb +23 -23
  911. data/vendor/hardmock/lib/extend_test_unit.rb +14 -14
  912. data/vendor/hardmock/lib/hardmock.rb +86 -86
  913. data/vendor/hardmock/lib/hardmock/errors.rb +22 -22
  914. data/vendor/hardmock/lib/hardmock/expectation.rb +229 -229
  915. data/vendor/hardmock/lib/hardmock/expectation_builder.rb +9 -9
  916. data/vendor/hardmock/lib/hardmock/expector.rb +26 -26
  917. data/vendor/hardmock/lib/hardmock/method_cleanout.rb +33 -33
  918. data/vendor/hardmock/lib/hardmock/mock.rb +180 -180
  919. data/vendor/hardmock/lib/hardmock/mock_control.rb +53 -53
  920. data/vendor/hardmock/lib/hardmock/stubbing.rb +210 -210
  921. data/vendor/hardmock/lib/hardmock/trapper.rb +31 -31
  922. data/vendor/hardmock/lib/hardmock/utils.rb +9 -9
  923. data/vendor/hardmock/lib/test_unit_before_after.rb +169 -169
  924. data/vendor/hardmock/rake_tasks/rdoc.rake +19 -19
  925. data/vendor/hardmock/rake_tasks/rdoc_options.rb +4 -4
  926. data/vendor/hardmock/rake_tasks/test.rake +22 -22
  927. data/vendor/hardmock/test/functional/assert_error_test.rb +52 -52
  928. data/vendor/hardmock/test/functional/auto_verify_test.rb +178 -178
  929. data/vendor/hardmock/test/functional/direct_mock_usage_test.rb +396 -396
  930. data/vendor/hardmock/test/functional/hardmock_test.rb +434 -434
  931. data/vendor/hardmock/test/functional/stubbing_test.rb +479 -479
  932. data/vendor/hardmock/test/test_helper.rb +43 -43
  933. data/vendor/hardmock/test/unit/expectation_builder_test.rb +19 -19
  934. data/vendor/hardmock/test/unit/expectation_test.rb +372 -372
  935. data/vendor/hardmock/test/unit/expector_test.rb +57 -57
  936. data/vendor/hardmock/test/unit/method_cleanout_test.rb +36 -36
  937. data/vendor/hardmock/test/unit/mock_control_test.rb +175 -175
  938. data/vendor/hardmock/test/unit/mock_test.rb +279 -279
  939. data/vendor/hardmock/test/unit/test_unit_before_after_test.rb +452 -452
  940. data/vendor/hardmock/test/unit/trapper_test.rb +62 -62
  941. data/vendor/hardmock/test/unit/verify_error_test.rb +40 -40
  942. data/vendor/unity/CMakeLists.txt +31 -0
  943. data/vendor/unity/LICENSE.txt +21 -0
  944. data/vendor/unity/README.md +191 -231
  945. data/vendor/unity/auto/colour_prompt.rb +119 -118
  946. data/vendor/unity/auto/colour_reporter.rb +39 -39
  947. data/vendor/unity/auto/generate_config.yml +36 -36
  948. data/vendor/unity/auto/generate_module.rb +309 -308
  949. data/vendor/unity/auto/generate_test_runner.rb +495 -457
  950. data/vendor/unity/auto/parse_output.rb +322 -323
  951. data/vendor/unity/auto/run_test.erb +36 -0
  952. data/vendor/unity/auto/stylize_as_junit.rb +251 -252
  953. data/vendor/unity/auto/test_file_filter.rb +25 -25
  954. data/vendor/unity/auto/type_sanitizer.rb +6 -6
  955. data/vendor/unity/auto/unity_test_summary.py +139 -139
  956. data/vendor/unity/auto/unity_test_summary.rb +135 -136
  957. data/vendor/unity/auto/unity_to_junit.py +146 -146
  958. data/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +206 -206
  959. data/vendor/unity/docs/UnityAssertionsReference.md +850 -779
  960. data/vendor/unity/docs/UnityConfigurationGuide.md +541 -433
  961. data/vendor/unity/docs/UnityGettingStartedGuide.md +251 -192
  962. data/vendor/unity/docs/UnityHelperScriptsGuide.md +266 -260
  963. data/vendor/unity/examples/example_1/makefile +72 -71
  964. data/vendor/unity/examples/example_1/readme.txt +4 -4
  965. data/vendor/unity/examples/example_1/src/ProductionCode.c +24 -24
  966. data/vendor/unity/examples/example_1/src/ProductionCode.h +3 -3
  967. data/vendor/unity/examples/example_1/src/ProductionCode2.c +11 -11
  968. data/vendor/unity/examples/example_1/src/ProductionCode2.h +2 -2
  969. data/vendor/unity/examples/example_1/test/TestProductionCode.c +62 -62
  970. data/vendor/unity/examples/example_1/test/TestProductionCode2.c +31 -31
  971. data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -53
  972. data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -57
  973. data/vendor/unity/examples/example_2/makefile +71 -70
  974. data/vendor/unity/examples/example_2/readme.txt +4 -4
  975. data/vendor/unity/examples/example_2/src/ProductionCode.c +24 -24
  976. data/vendor/unity/examples/example_2/src/ProductionCode.h +3 -3
  977. data/vendor/unity/examples/example_2/src/ProductionCode2.c +11 -11
  978. data/vendor/unity/examples/example_2/src/ProductionCode2.h +2 -2
  979. data/vendor/unity/examples/example_2/test/TestProductionCode.c +64 -64
  980. data/vendor/unity/examples/example_2/test/TestProductionCode2.c +33 -33
  981. data/vendor/unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +8 -8
  982. data/vendor/unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +10 -10
  983. data/vendor/unity/examples/example_2/test/test_runners/all_tests.c +12 -12
  984. data/vendor/unity/examples/example_3/helper/UnityHelper.c +10 -10
  985. data/vendor/unity/examples/example_3/helper/UnityHelper.h +12 -12
  986. data/vendor/unity/examples/example_3/rakefile.rb +38 -43
  987. data/vendor/unity/examples/example_3/rakefile_helper.rb +250 -249
  988. data/vendor/unity/examples/example_3/readme.txt +13 -13
  989. data/vendor/unity/examples/example_3/src/ProductionCode.c +24 -24
  990. data/vendor/unity/examples/example_3/src/ProductionCode.h +3 -3
  991. data/vendor/unity/examples/example_3/src/ProductionCode2.c +11 -11
  992. data/vendor/unity/examples/example_3/src/ProductionCode2.h +2 -2
  993. data/vendor/unity/examples/example_3/target_gcc_32.yml +47 -46
  994. data/vendor/unity/examples/example_3/test/TestProductionCode.c +62 -62
  995. data/vendor/unity/examples/example_3/test/TestProductionCode2.c +31 -31
  996. data/vendor/unity/examples/example_4/meson.build +17 -0
  997. data/vendor/unity/examples/example_4/readme.txt +15 -0
  998. data/vendor/unity/examples/example_4/src/ProductionCode.c +24 -0
  999. data/vendor/unity/examples/example_4/src/ProductionCode.h +3 -0
  1000. data/vendor/unity/examples/example_4/src/ProductionCode2.c +11 -0
  1001. data/vendor/unity/examples/example_4/src/ProductionCode2.h +2 -0
  1002. data/vendor/unity/examples/example_4/src/meson.build +21 -0
  1003. data/vendor/unity/examples/example_4/subprojects/unity.wrap +4 -0
  1004. data/vendor/unity/examples/example_4/test/TestProductionCode.c +63 -0
  1005. data/vendor/unity/examples/example_4/test/TestProductionCode2.c +35 -0
  1006. data/vendor/unity/examples/example_4/test/meson.build +12 -0
  1007. data/vendor/unity/examples/example_4/test/test_runners/TestProductionCode2_Runner.c +53 -0
  1008. data/vendor/unity/examples/example_4/test/test_runners/TestProductionCode_Runner.c +57 -0
  1009. data/vendor/unity/examples/example_4/test/test_runners/meson.build +16 -0
  1010. data/vendor/unity/examples/unity_config.h +263 -247
  1011. data/vendor/unity/extras/eclipse/error_parsers.txt +26 -26
  1012. data/vendor/unity/extras/fixture/rakefile.rb +44 -48
  1013. data/vendor/unity/extras/fixture/rakefile_helper.rb +183 -178
  1014. data/vendor/unity/extras/fixture/readme.md +17 -0
  1015. data/vendor/unity/extras/fixture/src/unity_fixture.c +275 -436
  1016. data/vendor/unity/extras/fixture/src/unity_fixture.h +83 -83
  1017. data/vendor/unity/extras/fixture/src/unity_fixture_internals.h +50 -51
  1018. data/vendor/unity/extras/fixture/test/Makefile +72 -75
  1019. data/vendor/unity/extras/fixture/test/main/AllTests.c +20 -22
  1020. data/vendor/unity/extras/fixture/test/template_fixture_tests.c +39 -39
  1021. data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +245 -543
  1022. data/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +32 -57
  1023. data/vendor/unity/extras/memory/rakefile.rb +45 -0
  1024. data/vendor/unity/extras/memory/rakefile_helper.rb +187 -0
  1025. data/vendor/unity/extras/memory/readme.md +49 -0
  1026. data/vendor/unity/extras/memory/src/unity_memory.c +202 -0
  1027. data/vendor/unity/extras/memory/src/unity_memory.h +60 -0
  1028. data/vendor/unity/extras/memory/test/Makefile +78 -0
  1029. data/vendor/unity/extras/memory/test/unity_memory_Test.c +325 -0
  1030. data/vendor/unity/extras/memory/test/unity_memory_TestRunner.c +49 -0
  1031. data/vendor/unity/extras/memory/test/unity_output_Spy.c +56 -0
  1032. data/vendor/unity/extras/memory/test/unity_output_Spy.h +16 -0
  1033. data/vendor/unity/meson.build +69 -0
  1034. data/vendor/unity/src/CMakeLists.txt +22 -0
  1035. data/vendor/unity/src/meson.build +16 -0
  1036. data/vendor/unity/src/unity.c +2085 -1572
  1037. data/vendor/unity/src/unity.h +617 -503
  1038. data/vendor/unity/src/unity_internals.h +1002 -924
  1039. data/vendor/unity/test/Makefile +67 -68
  1040. data/vendor/unity/test/expectdata/testsample_cmd.c +61 -61
  1041. data/vendor/unity/test/expectdata/testsample_def.c +57 -57
  1042. data/vendor/unity/test/expectdata/testsample_head1.c +55 -55
  1043. data/vendor/unity/test/expectdata/testsample_head1.h +15 -15
  1044. data/vendor/unity/test/expectdata/testsample_mock_cmd.c +80 -80
  1045. data/vendor/unity/test/expectdata/testsample_mock_def.c +76 -76
  1046. data/vendor/unity/test/expectdata/testsample_mock_head1.c +75 -75
  1047. data/vendor/unity/test/expectdata/testsample_mock_head1.h +13 -13
  1048. data/vendor/unity/test/expectdata/testsample_mock_new1.c +89 -89
  1049. data/vendor/unity/test/expectdata/testsample_mock_new2.c +89 -89
  1050. data/vendor/unity/test/expectdata/testsample_mock_param.c +77 -77
  1051. data/vendor/unity/test/expectdata/testsample_mock_run1.c +89 -89
  1052. data/vendor/unity/test/expectdata/testsample_mock_run2.c +89 -89
  1053. data/vendor/unity/test/expectdata/testsample_mock_yaml.c +90 -90
  1054. data/vendor/unity/test/expectdata/testsample_new1.c +67 -67
  1055. data/vendor/unity/test/expectdata/testsample_new2.c +70 -70
  1056. data/vendor/unity/test/expectdata/testsample_param.c +58 -58
  1057. data/vendor/unity/test/expectdata/testsample_run1.c +67 -67
  1058. data/vendor/unity/test/expectdata/testsample_run2.c +70 -70
  1059. data/vendor/unity/test/expectdata/testsample_yaml.c +71 -71
  1060. data/vendor/unity/test/rakefile +124 -125
  1061. data/vendor/unity/test/rakefile_helper.rb +269 -260
  1062. data/vendor/unity/test/spec/generate_module_existing_file_spec.rb +158 -158
  1063. data/vendor/unity/test/targets/ansi.yml +49 -0
  1064. data/vendor/unity/test/targets/clang_file.yml +78 -78
  1065. data/vendor/unity/test/targets/clang_strict.yml +78 -78
  1066. data/vendor/unity/test/targets/gcc_32.yml +49 -49
  1067. data/vendor/unity/test/targets/gcc_64.yml +50 -50
  1068. data/vendor/unity/test/targets/gcc_auto_limits.yml +47 -47
  1069. data/vendor/unity/test/targets/gcc_auto_stdint.yml +59 -59
  1070. data/vendor/unity/test/targets/gcc_manual_math.yml +47 -47
  1071. data/vendor/unity/test/targets/hitech_picc18.yml +101 -101
  1072. data/vendor/unity/test/targets/iar_arm_v4.yml +90 -90
  1073. data/vendor/unity/test/targets/iar_arm_v5.yml +80 -80
  1074. data/vendor/unity/test/targets/iar_arm_v5_3.yml +80 -80
  1075. data/vendor/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +94 -94
  1076. data/vendor/unity/test/targets/iar_cortexm3_v5.yml +84 -84
  1077. data/vendor/unity/test/targets/iar_msp430.yml +95 -95
  1078. data/vendor/unity/test/targets/iar_sh2a_v6.yml +86 -86
  1079. data/vendor/unity/test/testdata/CException.h +11 -11
  1080. data/vendor/unity/test/testdata/Defs.h +8 -8
  1081. data/vendor/unity/test/testdata/cmock.h +14 -14
  1082. data/vendor/unity/test/testdata/mockMock.h +13 -13
  1083. data/vendor/unity/test/testdata/testRunnerGenerator.c +189 -186
  1084. data/vendor/unity/test/testdata/testRunnerGeneratorSmall.c +70 -70
  1085. data/vendor/unity/test/testdata/testRunnerGeneratorWithMocks.c +197 -195
  1086. data/vendor/unity/test/tests/test_generate_test_runner.rb +1268 -1252
  1087. data/vendor/unity/test/tests/testparameterized.c +171 -113
  1088. data/vendor/unity/test/tests/testunity.c +8168 -5371
  1089. metadata +201 -27
  1090. data/lib/ceedling/version.rb.erb +0 -15
  1091. data/vendor/c_exception/release/build.info +0 -2
  1092. data/vendor/c_exception/release/version.info +0 -2
  1093. data/vendor/cmock/release/build.info +0 -2
  1094. data/vendor/cmock/release/version.info +0 -2
  1095. data/vendor/cmock/vendor/c_exception/release/build.info +0 -2
  1096. data/vendor/cmock/vendor/c_exception/release/version.info +0 -2
  1097. data/vendor/cmock/vendor/unity/release/build.info +0 -2
  1098. data/vendor/cmock/vendor/unity/release/version.info +0 -2
  1099. data/vendor/unity/extras/fixture/readme.txt +0 -9
  1100. data/vendor/unity/release/build.info +0 -2
  1101. data/vendor/unity/release/version.info +0 -2
@@ -1,1699 +1,1728 @@
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 :when_no_prototypes, :error
23
- @config.expect :verbosity, 1
24
- @config.expect :treat_externs, :exclude
25
-
26
- @parser = CMockHeaderParser.new(@config)
27
- end
28
-
29
- after do
30
- end
31
-
32
- it "create and initialize variables to defaults appropriately" do
33
- assert_equal([], @parser.funcs)
34
- assert_equal(['const', '__ramfunc', 'funky_attrib', 'SQLITE_API'], @parser.c_attributes)
35
- assert_equal(['void','MY_FUNKY_VOID'], @parser.treat_as_void)
36
- end
37
-
38
- it "strip out line comments" do
39
- source =
40
- " abcd;\n" +
41
- "// hello;\n" +
42
- "who // is you\n"
43
-
44
- expected =
45
- [
46
- "abcd",
47
- "who"
48
- ]
49
-
50
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
51
- end
52
-
53
- it "remove block comments" do
54
- source =
55
- " no_comments;\n" +
56
- "// basic_line_comment;\n" +
57
- "/* basic_block_comment;*/\n" +
58
- "pre_block; /* start_of_block_comment;\n" +
59
- "// embedded_line_comment_in_block_comment; */\n" +
60
- "// /* commented_out_block_comment_line\n" +
61
- "shown_because_block_comment_invalid_from_line_comment;\n" +
62
- "// */\n" +
63
- "//* shorter_commented_out_block_comment_line; \n" +
64
- "shown_because_block_comment_invalid_from_shorter_line_comment;\n" +
65
- "/*/\n" +
66
- "not_shown_because_line_above_started_comment;\n" +
67
- "//*/\n" +
68
- "/* \n" +
69
- "not_shown_because_block_comment_started_this_time;\n" +
70
- "/*/\n" +
71
- "shown_because_line_above_ended_comment_this_time;\n" +
72
- "//*/\n"
73
-
74
- expected =
75
- [
76
- "no_comments",
77
- "pre_block",
78
- "shown_because_block_comment_invalid_from_line_comment",
79
- "shown_because_block_comment_invalid_from_shorter_line_comment",
80
- "shown_because_line_above_ended_comment_this_time"
81
- ]
82
-
83
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
84
- end
85
-
86
- it "remove strippables from the beginning or end of function declarations" do
87
- source =
88
- "void* my_calloc(size_t, size_t) STRIPPABLE;\n" +
89
- "void\n" +
90
- " my_realloc(void*, size_t) STRIPPABLE;\n" +
91
- "extern int\n" +
92
- " my_printf (void *my_object, const char *my_format, ...)\n" +
93
- " STRIPPABLE;\n" +
94
- " void STRIPPABLE universal_handler ();\n"
95
-
96
- expected =
97
- [
98
- "void* my_calloc(size_t, size_t)",
99
- "void my_realloc(void*, size_t)",
100
- "void universal_handler()"
101
- ]
102
-
103
- assert_equal(expected, @parser.import_source(source))
104
- end
105
-
106
- it "remove gcc's function __attribute__'s" do
107
- source =
108
- "void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)));\n" +
109
- "void\n" +
110
- " my_realloc(void*, size_t) __attribute__((alloc_size(2)));\n" +
111
- "extern int\n" +
112
- " my_printf (void *my_object, const char *my_format, ...)\n" +
113
- " __attribute__ ((format (printf, 2, 3)));\n" +
114
- " void __attribute__ ((interrupt)) universal_handler ();\n"
115
-
116
- expected =
117
- [
118
- "void* my_calloc(size_t, size_t)",
119
- "void my_realloc(void*, size_t)",
120
- "void universal_handler()"
121
- ]
122
-
123
- assert_equal(expected, @parser.import_source(source))
124
- end
125
-
126
- it "remove preprocessor directives" do
127
- source =
128
- "#when stuff_happens\n" +
129
- "#ifdef _TEST\n" +
130
- "#pragma stack_switch"
131
-
132
- expected = []
133
-
134
- assert_equal(expected, @parser.import_source(source))
135
- end
136
-
137
-
138
- it "remove assembler pragma sections" do
139
- source =
140
- " #pragma\tasm\n" +
141
- " .foo\n" +
142
- " lda %m\n" +
143
- " nop\n" +
144
- "# pragma endasm \n" +
145
- "foo"
146
-
147
- expected = ["foo"]
148
-
149
- assert_equal(expected, @parser.import_source(source))
150
- end
151
-
152
-
153
- it "smush lines together that contain continuation characters" do
154
- source =
155
- "hoo hah \\\n" +
156
- "when \\ \n"
157
-
158
- expected =
159
- [
160
- "hoo hah when"
161
- ]
162
-
163
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
164
- end
165
-
166
-
167
- it "remove C macro definitions" do
168
- source =
169
- "#define this is the first line\\\n" +
170
- "and the second\\\n" +
171
- "and the third that should be removed\n" +
172
- "but I'm here\n"
173
-
174
- expected = ["but I'm here"]
175
-
176
- assert_equal(expected, @parser.import_source(source))
177
- end
178
-
179
-
180
- it "remove typedef statements" do
181
- source =
182
- "typedef uint32 (unsigned int);\n" +
183
- "const typedef int INT;\n" +
184
- "int notatypedef;\n" +
185
- "int typedef_isnt_me;\n" +
186
- " typedef who cares what really comes here \n" + # exercise multiline typedef
187
- " continuation;\n" +
188
- "this should remain!;\n" +
189
- "typedef blah bleh;\n" +
190
- "typedef struct shell_command_struct {\n" +
191
- " char_ptr COMMAND;\n" +
192
- " int_32 (*SHELL_FUNC)(int_32 argc);\n" +
193
- "} SHELL_COMMAND_STRUCT, * SHELL_COMMAND_PTR;\n" +
194
- "typedef struct shell_command_struct {\n" +
195
- " char_ptr COMMAND;\n" +
196
- " int_32 (*SHELL_FUNC)(int_32 argc, char_ptr argv[]);\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);\n" +
201
- "};\n"
202
-
203
- expected =
204
- [
205
- "int notatypedef",
206
- "int typedef_isnt_me",
207
- "this should remain!"
208
- ]
209
-
210
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
211
- end
212
-
213
-
214
- it "remove enum statements" do
215
- source =
216
- "enum _NamedEnum {\n" +
217
- " THING1 = (0x0001),\n" +
218
- " THING2 = (0x0001 << 5),\n" +
219
- "}ListOValues;\n\n" +
220
- "don't delete me!!\n" +
221
- " modifier_str enum _NamedEnum {THING1 = (0x0001), THING2 = (0x0001 << 5)} ListOValues;\n\n" +
222
- "typedef enum {\n" +
223
- " THING1,\n" +
224
- " THING2,\n" +
225
- "} Thinger;\n" +
226
- "or me!!\n"
227
-
228
- assert_equal(["don't delete me!! or me!!"], @parser.import_source(source).map!{|s|s.strip})
229
- end
230
-
231
-
232
- it "remove union statements" do
233
- source =
234
- "union _NamedDoohicky {\n" +
235
- " unsigned int a;\n" +
236
- " char b;\n" +
237
- "} Doohicky;\n\n" +
238
- "I want to live!!\n" +
239
- "some_modifier union { unsigned int a; char b;} Whatever;\n" +
240
- "typedef union {\n" +
241
- " unsigned int a;\n" +
242
- " char b;\n" +
243
- "} Whatever;\n" +
244
- "me too!!\n"
245
-
246
- assert_equal(["I want to live!! me too!!"], @parser.import_source(source).map!{|s|s.strip})
247
- end
248
-
249
-
250
- it "remove struct statements" do
251
- source =
252
- "struct _NamedStruct1 {\n" +
253
- " unsigned int a;\n" +
254
- " signed long int b;\n" +
255
- "} Thing ;\n\n" +
256
- "extern struct ForwardDeclared_t TestDataType1;\n" +
257
- "void foo(void);\n" +
258
- "struct\n"+
259
- " MultilineForwardDeclared_t\n" +
260
- " TestDataType2;\n" +
261
- "struct THINGER foo(void);\n" +
262
- "typedef struct {\n" +
263
- " unsigned int a;\n" +
264
- " signed char b;\n" +
265
- "}Thinger;\n" +
266
- "I want to live!!\n"
267
-
268
- assert_equal(["void foo(void)", "struct THINGER foo(void)", "I want to live!!"],
269
- @parser.import_source(source).map!{|s|s.strip})
270
- end
271
-
272
- it "remove externed and inline functions" do
273
- source =
274
- " extern uint32 foobar(unsigned int);\n" +
275
- "uint32 extern_name_func(unsigned int);\n" +
276
- "uint32 funcinline(unsigned int);\n" +
277
- "extern void bar(unsigned int);\n" +
278
- "inline void bar(unsigned int);\n" +
279
- "extern\n" +
280
- "void kinda_ugly_on_the_next_line(unsigned int);\n"
281
-
282
- expected =
283
- [
284
- "uint32 extern_name_func(unsigned int)",
285
- "uint32 funcinline(unsigned int)"
286
- ]
287
-
288
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
289
- end
290
-
291
- it "remove function definitions but keep function declarations" do
292
- source =
293
- "uint32 func_with_decl_a(unsigned int);\n" +
294
- "uint32 func_with_decl_a(unsigned int a) { return a; }\n" +
295
- "uint32 func_with_decl_b(unsigned int);\n" +
296
- "uint32 func_with_decl_b(unsigned int a)\n" +
297
- "{\n" +
298
- " bar((unsigned int) a);\n" +
299
- " stripme(a);\n" +
300
- "}\n"
301
-
302
- expected =
303
- [
304
- "uint32 func_with_decl_a(unsigned int)",
305
- "uint32 func_with_decl_a", #okay. it's not going to be interpretted as another function
306
- "uint32 func_with_decl_b(unsigned int)",
307
- "uint32 func_with_decl_b", #okay. it's not going to be interpretted as another function
308
- ]
309
-
310
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
311
- end
312
-
313
- it "remove function definitions with nested braces but keep function declarations" do
314
- source =
315
- "uint32 func_with_decl_a(unsigned int);\n" +
316
- "uint32 func_with_decl_a(unsigned int a) {\n" +
317
- " while (stuff) {\n" +
318
- " not_a_definition1(void);\n" +
319
- " }\n" +
320
- " not_a_definition2(blah, bleh);\n" +
321
- " return a;\n" +
322
- "}\n" +
323
- "uint32 func_with_decl_b(unsigned int);\n" +
324
- "uint32 func_with_decl_b(unsigned int a)\n" +
325
- "{\n" +
326
- " bar((unsigned int) a);\n" +
327
- " stripme(a);\n" +
328
- "}\n" +
329
- "uint32 func_with_decl_c(unsigned int);\n" +
330
- "uint32 func_with_decl_c(unsigned int a)\n" +
331
- "{\n" +
332
- " if(a > 0)\n" +
333
- " {\n" +
334
- " return 1;\n" +
335
- " }\n" +
336
- " else\n"+
337
- " {\n" +
338
- " return 2;\n" +
339
- " }\n" +
340
- "}\n"
341
-
342
- expected =
343
- [
344
- "uint32 func_with_decl_a(unsigned int)",
345
- "uint32 func_with_decl_a", #okay. it's not going to be interpretted as another function
346
- "uint32 func_with_decl_b(unsigned int)",
347
- "uint32 func_with_decl_b", #okay. it's not going to be interpretted as another function
348
- "uint32 func_with_decl_c(unsigned int)",
349
- "uint32 func_with_decl_c", #okay. it's not going to be interpretted as another function
350
- ]
351
-
352
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
353
- end
354
-
355
- it "remove a fully defined inline function" do
356
- source =
357
- "inline void foo(unsigned int a) { oranges = a; }\n" +
358
- "inline void bar(unsigned int a) { apples = a; };\n" +
359
- "inline void bar(unsigned int a)\n" +
360
- "{" +
361
- " bananas = a;\n" +
362
- "}"
363
-
364
- # ensure it's expected type of exception
365
- assert_raises RuntimeError do
366
- @parser.parse("module", source)
367
- end
368
-
369
- assert_equal([], @parser.funcs)
370
-
371
- # verify exception message
372
- begin
373
- @parser.parse("module", source)
374
- rescue RuntimeError => e
375
- assert_equal("ERROR: No function prototypes found!", e.message)
376
- end
377
- end
378
-
379
- it "remove a fully defined inline function that is multiple lines" do
380
- source =
381
- "inline void bar(unsigned int a)\n" +
382
- "{" +
383
- " bananas = a;\n" +
384
- " grapes = a;\n" +
385
- " apples(bananas, grapes);\n" +
386
- "}"
387
-
388
- # ensure it's expected type of exception
389
- assert_raises RuntimeError do
390
- @parser.parse("module", source)
391
- end
392
-
393
- assert_equal([], @parser.funcs)
394
-
395
- # verify exception message
396
- begin
397
- @parser.parse("module", source)
398
- rescue RuntimeError => e
399
- assert_equal("ERROR: No function prototypes found!", e.message)
400
- end
401
- end
402
-
403
- it "remove a fully defined inline function that contains nested braces" do
404
- source =
405
- "inline void bar(unsigned int a)\n" +
406
- "{" +
407
- " apples(bananas, grapes);\n" +
408
- " if (bananas == a)\n" +
409
- " {\n" +
410
- " oranges(a);\n" +
411
- " grapes = a;\n" +
412
- " }\n" +
413
- " grapefruit(bananas, grapes);\n" +
414
- "}"
415
-
416
- # ensure it's expected type of exception
417
- assert_raises RuntimeError do
418
- @parser.parse("module", source)
419
- end
420
-
421
- assert_equal([], @parser.funcs)
422
-
423
- # verify exception message
424
- begin
425
- @parser.parse("module", source)
426
- rescue RuntimeError => e
427
- assert_equal("ERROR: No function prototypes found!", e.message)
428
- end
429
- end
430
-
431
- it "remove just inline functions if externs to be included" do
432
- source =
433
- " extern uint32 foobar(unsigned int);\n" +
434
- "uint32 extern_name_func(unsigned int);\n" +
435
- "uint32 funcinline(unsigned int);\n" +
436
- "extern void bar(unsigned int);\n" +
437
- "inline void bar(unsigned int);\n" +
438
- "extern\n" +
439
- "void kinda_ugly_on_the_next_line(unsigned int);\n"
440
-
441
- expected =
442
- [ "extern uint32 foobar(unsigned int)",
443
- "uint32 extern_name_func(unsigned int)",
444
- "uint32 funcinline(unsigned int)",
445
- "extern void bar(unsigned int)",
446
- "extern void kinda_ugly_on_the_next_line(unsigned int)"
447
- ]
448
-
449
- @parser.treat_externs = :include
450
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
451
- end
452
-
453
-
454
- it "remove defines" do
455
- source =
456
- "#define whatever you feel like defining\n" +
457
- "void hello(void);\n" +
458
- "#DEFINE I JUST DON'T CARE\n" +
459
- "#deFINE\n" +
460
- "#define get_foo() \\\n ((Thing)foo.bar)" # exercise multiline define
461
-
462
- expected =
463
- [
464
- "void hello(void)",
465
- ]
466
-
467
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
468
- end
469
-
470
-
471
- it "remove keywords that would keep things from going smoothly in the future" do
472
- source =
473
- "const int TheMatrix(register int Trinity, unsigned int *restrict Neo)"
474
-
475
- expected =
476
- [
477
- "const int TheMatrix(int Trinity, unsigned int * Neo)",
478
- ]
479
-
480
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
481
- end
482
-
483
-
484
- # some code actually typedef's void even though it's not ANSI C and is, frankly, weird
485
- # since cmock treats void specially, we can't let void be obfuscated
486
- it "handle odd case of typedef'd void returned" do
487
- source = "MY_FUNKY_VOID FunkyVoidReturned(int a)"
488
- expected = { :var_arg=>nil,
489
- :name=>"FunkyVoidReturned",
490
- :return=>{ :type => "void",
491
- :name => 'cmock_to_return',
492
- :ptr? => false,
493
- :const? => false,
494
- :const_ptr? => false,
495
- :str => "void cmock_to_return",
496
- :void? => true
497
- },
498
- :modifier=>"",
499
- :contains_ptr? => false,
500
- :args=>[{:type=>"int", :name=>"a", :ptr? => false, :const? => false, :const_ptr? => false}],
501
- :args_string=>"int a",
502
- :args_call=>"a"}
503
- assert_equal(expected, @parser.parse_declaration(source))
504
- end
505
-
506
- it "handle odd case of typedef'd void as arg" do
507
- source = "int FunkyVoidAsArg(MY_FUNKY_VOID)"
508
- expected = { :var_arg=>nil,
509
- :name=>"FunkyVoidAsArg",
510
- :return=>{ :type => "int",
511
- :name => 'cmock_to_return',
512
- :ptr? => false,
513
- :const? => false,
514
- :const_ptr? => false,
515
- :str => "int cmock_to_return",
516
- :void? => false
517
- },
518
- :modifier=>"",
519
- :contains_ptr? => false,
520
- :args=>[],
521
- :args_string=>"void",
522
- :args_call=>"" }
523
- assert_equal(expected, @parser.parse_declaration(source))
524
- end
525
-
526
- it "handle odd case of typedef'd void as arg pointer" do
527
- source = "char FunkyVoidPointer(MY_FUNKY_VOID* bluh)"
528
- expected = { :var_arg=>nil,
529
- :name=>"FunkyVoidPointer",
530
- :return=>{ :type => "char",
531
- :name => 'cmock_to_return',
532
- :ptr? => false,
533
- :const? => false,
534
- :const_ptr? => false,
535
- :str => "char cmock_to_return",
536
- :void? => false
537
- },
538
- :modifier=>"",
539
- :contains_ptr? => true,
540
- :args=>[{:type=>"MY_FUNKY_VOID*", :name=>"bluh", :ptr? => true, :const? => false, :const_ptr? => false}],
541
- :args_string=>"MY_FUNKY_VOID* bluh",
542
- :args_call=>"bluh" }
543
- assert_equal(expected, @parser.parse_declaration(source))
544
- end
545
-
546
-
547
- it "strip default values from function parameter lists" do
548
- source =
549
- "void Foo(int a = 57, float b=37.52, char c= 'd', char* e=\"junk\");\n"
550
-
551
- expected =
552
- [
553
- "void Foo(int a, float b, char c, char* e)"
554
- ]
555
-
556
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
557
- end
558
-
559
-
560
- it "raise upon empty file" do
561
- source = ''
562
-
563
- # ensure it's expected type of exception
564
- assert_raises RuntimeError do
565
- @parser.parse("module", source)
566
- end
567
-
568
- assert_equal([], @parser.funcs)
569
-
570
- # verify exception message
571
- begin
572
- @parser.parse("module", source)
573
- rescue RuntimeError => e
574
- assert_equal("ERROR: No function prototypes found!", e.message)
575
- end
576
- end
577
-
578
- it "clean up module names that contain spaces, dashes, and such" do
579
- source = 'void meh(int (*func)(int));'
580
-
581
- retval = @parser.parse("C:\Ugly Module-Name", source)
582
- assert (retval[:typedefs][0] =~ /CUglyModuleName/)
583
- end
584
-
585
- it "raise upon no function prototypes found in file" do
586
- source =
587
- "typedef void SILLY_VOID_TYPE1;\n" +
588
- "typedef (void) SILLY_VOID_TYPE2 ;\n" +
589
- "typedef ( void ) (*FUNCPTR)(void);\n\n" +
590
- "#define get_foo() \\\n ((Thing)foo.bar)"
591
-
592
- # ensure it's expected type of exception
593
- assert_raises(RuntimeError) do
594
- @parser.parse("module", source)
595
- end
596
-
597
- assert_equal([], @parser.funcs)
598
-
599
- # verify exception message
600
- begin
601
- @parser.parse("module", source)
602
- rescue RuntimeError => e
603
- assert_equal("ERROR: No function prototypes found!", e.message)
604
- end
605
- end
606
-
607
-
608
- it "raise upon prototype parsing failure" do
609
- source = "void (int, )"
610
-
611
- # ensure it's expected type of exception
612
- assert_raises(RuntimeError) do
613
- @parser.parse("module", source)
614
- end
615
-
616
- # verify exception message
617
- begin
618
- @parser.parse("module", source)
619
- rescue RuntimeError => e
620
- assert(e.message.include?("Failed Parsing Declaration Prototype!"))
621
- end
622
- end
623
-
624
- it "extract and return function declarations with retval and args" do
625
-
626
- source = "int Foo(int a, unsigned int b)"
627
- expected = { :var_arg=>nil,
628
- :name=>"Foo",
629
- :return=>{ :type => "int",
630
- :name => 'cmock_to_return',
631
- :ptr? => false,
632
- :const? => false,
633
- :const_ptr? => false,
634
- :str => "int cmock_to_return",
635
- :void? => false
636
- },
637
- :modifier=>"",
638
- :contains_ptr? => false,
639
- :args=>[ {:type=>"int", :name=>"a", :ptr? => false, :const? => false, :const_ptr? => false},
640
- {:type=>"unsigned int", :name=>"b", :ptr? => false, :const? => false, :const_ptr? => false}
641
- ],
642
- :args_string=>"int a, unsigned int b",
643
- :args_call=>"a, b" }
644
- assert_equal(expected, @parser.parse_declaration(source))
645
- end
646
-
647
- it "extract and return function declarations with no retval" do
648
-
649
- source = "void FunkyChicken( uint la, int de, bool da)"
650
- expected = { :var_arg=>nil,
651
- :return=>{ :type => "void",
652
- :name => 'cmock_to_return',
653
- :ptr? => false,
654
- :const? => false,
655
- :const_ptr? => false,
656
- :str => "void cmock_to_return",
657
- :void? => true
658
- },
659
- :name=>"FunkyChicken",
660
- :modifier=>"",
661
- :contains_ptr? => false,
662
- :args=>[ {:type=>"uint", :name=>"la", :ptr? => false, :const? => false, :const_ptr? => false},
663
- {:type=>"int", :name=>"de", :ptr? => false, :const? => false, :const_ptr? => false},
664
- {:type=>"bool", :name=>"da", :ptr? => false, :const? => false, :const_ptr? => false}
665
- ],
666
- :args_string=>"uint la, int de, bool da",
667
- :args_call=>"la, de, da" }
668
- assert_equal(expected, @parser.parse_declaration(source))
669
- end
670
-
671
- it "extract and return function declarations with implied voids" do
672
-
673
- source = "void tat()"
674
- expected = { :var_arg=>nil,
675
- :return=>{ :type => "void",
676
- :name => 'cmock_to_return',
677
- :ptr? => false,
678
- :const? => false,
679
- :const_ptr? => false,
680
- :str => "void cmock_to_return",
681
- :void? => true
682
- },
683
- :name=>"tat",
684
- :modifier=>"",
685
- :contains_ptr? => false,
686
- :args=>[ ],
687
- :args_string=>"void",
688
- :args_call=>"" }
689
- assert_equal(expected, @parser.parse_declaration(source))
690
- end
691
-
692
- it "extract modifiers properly" do
693
-
694
- source = "const int TheMatrix(int Trinity, unsigned int * Neo)"
695
- expected = { :var_arg=>nil,
696
- :return=>{ :type => "int",
697
- :name => 'cmock_to_return',
698
- :ptr? => false,
699
- :const? => true,
700
- :const_ptr? => false,
701
- :str => "int cmock_to_return",
702
- :void? => false
703
- },
704
- :name=>"TheMatrix",
705
- :modifier=>"const",
706
- :contains_ptr? => true,
707
- :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
708
- {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
709
- ],
710
- :args_string=>"int Trinity, unsigned int* Neo",
711
- :args_call=>"Trinity, Neo" }
712
- assert_equal(expected, @parser.parse_declaration(source))
713
- end
714
-
715
- it "extract c calling conventions properly" do
716
-
717
- source = "const int __stdcall TheMatrix(int Trinity, unsigned int * Neo)"
718
- expected = { :var_arg=>nil,
719
- :return=>{ :type => "int",
720
- :name => 'cmock_to_return',
721
- :ptr? => false,
722
- :const? => true,
723
- :const_ptr? => false,
724
- :str => "int cmock_to_return",
725
- :void? => false
726
- },
727
- :name=>"TheMatrix",
728
- :modifier=>"const",
729
- :c_calling_convention=>"__stdcall",
730
- :contains_ptr? => true,
731
- :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
732
- {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
733
- ],
734
- :args_string=>"int Trinity, unsigned int* Neo",
735
- :args_call=>"Trinity, Neo" }
736
- assert_equal(expected, @parser.parse_declaration(source))
737
- end
738
-
739
- it "fully parse multiple prototypes" do
740
-
741
- source = "const int TheMatrix(int Trinity, unsigned int * Neo);\n" +
742
- "int Morpheus(int, unsigned int*);\n"
743
-
744
- expected = [{ :var_arg=>nil,
745
- :return=> { :type => "int",
746
- :name => 'cmock_to_return',
747
- :ptr? => false,
748
- :const? => true,
749
- :const_ptr? => false,
750
- :str => "int cmock_to_return",
751
- :void? => false
752
- },
753
- :name=>"TheMatrix",
754
- :modifier=>"const",
755
- :contains_ptr? => true,
756
- :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
757
- {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
758
- ],
759
- :args_string=>"int Trinity, unsigned int* Neo",
760
- :args_call=>"Trinity, Neo" },
761
- { :var_arg=>nil,
762
- :return=> { :type => "int",
763
- :name => 'cmock_to_return',
764
- :ptr? => false,
765
- :const? => false,
766
- :const_ptr? => false,
767
- :str => "int cmock_to_return",
768
- :void? => false
769
- },
770
- :name=>"Morpheus",
771
- :modifier=>"",
772
- :contains_ptr? => true,
773
- :args=>[ {:type=>"int", :name=>"cmock_arg1", :ptr? => false, :const? => false, :const_ptr? => false},
774
- {:type=>"unsigned int*", :name=>"cmock_arg2", :ptr? => true, :const? => false, :const_ptr? => false}
775
- ],
776
- :args_string=>"int cmock_arg1, unsigned int* cmock_arg2",
777
- :args_call=>"cmock_arg1, cmock_arg2"
778
- }]
779
- assert_equal(expected, @parser.parse("module", source)[:functions])
780
- end
781
-
782
- it "not extract for mocking multiply defined prototypes" do
783
-
784
- source = "const int TheMatrix(int Trinity, unsigned int * Neo);\n" +
785
- "const int TheMatrix(int, unsigned int*);\n"
786
-
787
- expected = [{ :var_arg=>nil,
788
- :name=>"TheMatrix",
789
- :return=> { :type => "int",
790
- :name => 'cmock_to_return',
791
- :ptr? => false,
792
- :const? => true,
793
- :const_ptr? => false,
794
- :str => "int cmock_to_return",
795
- :void? => false
796
- },
797
- :modifier=>"const",
798
- :contains_ptr? => true,
799
- :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
800
- {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
801
- ],
802
- :args_string=>"int Trinity, unsigned int* Neo",
803
- :args_call=>"Trinity, Neo"
804
- }]
805
- assert_equal(expected, @parser.parse("module", source)[:functions])
806
- end
807
-
808
- it "should properly handle const before return type" do
809
- sources = [
810
- "const int * PorkRoast(void);\n",
811
- "const int* PorkRoast(void);\n",
812
- "const int *PorkRoast(void);\n"
813
- ]
814
-
815
- expected = [{ :var_arg => nil,
816
- :name => "PorkRoast",
817
- :return => { :type => "const int*",
818
- :name => 'cmock_to_return',
819
- :ptr? => true,
820
- :const? => true,
821
- :const_ptr? => false,
822
- :str => "const int* cmock_to_return",
823
- :void? => false
824
- },
825
- :modifier => "",
826
- :contains_ptr? => false,
827
- :args => [],
828
- :args_string => "void",
829
- :args_call => ""
830
- }]
831
-
832
- sources.each do |source|
833
- assert_equal(expected, @parser.parse("module", source)[:functions])
834
- end
835
- end
836
-
837
- it "should properly handle const before return type" do
838
- sources = [
839
- "int const * PorkRoast(void);\n",
840
- "int const* PorkRoast(void);\n",
841
- "int const *PorkRoast(void);\n"
842
- ]
843
-
844
- expected = [{ :var_arg => nil,
845
- :name => "PorkRoast",
846
- :return => { :type => "int const*",
847
- :name => 'cmock_to_return',
848
- :ptr? => true,
849
- :const? => true,
850
- :const_ptr? => false,
851
- :str => "int const* cmock_to_return",
852
- :void? => false
853
- },
854
- :modifier => "",
855
- :contains_ptr? => false,
856
- :args => [],
857
- :args_string => "void",
858
- :args_call => ""
859
- }]
860
-
861
- sources.each do |source|
862
- assert_equal(expected, @parser.parse("module", source)[:functions])
863
- end
864
- end
865
-
866
- it "should properly handle const applied after asterisk in return type (not legal C, but sometimes used)" do
867
-
868
- source = "int * const PorkRoast(void);\n"
869
-
870
- expected = [{ :var_arg=>nil,
871
- :name=>"PorkRoast",
872
- :return=> { :type => "int*",
873
- :name => 'cmock_to_return',
874
- :ptr? => true,
875
- :const? => false,
876
- :const_ptr? => true,
877
- :str => "int* cmock_to_return",
878
- :void? => false
879
- },
880
- :modifier=>"const",
881
- :contains_ptr? => false,
882
- :args=>[],
883
- :args_string=>"void",
884
- :args_call=>""
885
- }]
886
- assert_equal(expected, @parser.parse("module", source)[:functions])
887
- end
888
-
889
- it "properly parse const and pointer argument types with no arg names" do
890
-
891
- source = "void foo(int const*, int*const, const int*, const int*const, int const*const, int*, int, const int);\n"
892
-
893
- expected = [{ :name => "foo",
894
- :modifier => "",
895
- :return => { :type => "void",
896
- :name => "cmock_to_return",
897
- :str => "void cmock_to_return",
898
- :void? => true,
899
- :ptr? => false,
900
- :const? => false,
901
- :const_ptr? => false
902
- },
903
- :var_arg => nil,
904
- :args_string => "int const* cmock_arg1, int* const cmock_arg2, const int* cmock_arg3, const int* const cmock_arg4, " +
905
- "int const* const cmock_arg5, int* cmock_arg6, int cmock_arg7, const int cmock_arg8",
906
- :args => [{ :type=>"int const*", :name => "cmock_arg1", :ptr? => true, :const? => true, :const_ptr? => false },
907
- { :type=>"int*", :name => "cmock_arg2", :ptr? => true, :const? => false, :const_ptr? => true },
908
- { :type=>"const int*", :name => "cmock_arg3", :ptr? => true, :const? => true, :const_ptr? => false },
909
- { :type=>"const int*", :name => "cmock_arg4", :ptr? => true, :const? => true, :const_ptr? => true },
910
- { :type=>"int const*", :name => "cmock_arg5", :ptr? => true, :const? => true, :const_ptr? => true },
911
- { :type=>"int*", :name => "cmock_arg6", :ptr? => true, :const? => false, :const_ptr? => false },
912
- { :type=>"int", :name => "cmock_arg7", :ptr? => false, :const? => false, :const_ptr? => false },
913
- { :type=>"int", :name => "cmock_arg8", :ptr? => false, :const? => true, :const_ptr? => false }],
914
- :args_call => "cmock_arg1, cmock_arg2, cmock_arg3, cmock_arg4, cmock_arg5, cmock_arg6, cmock_arg7, cmock_arg8",
915
- :contains_ptr? => true
916
- }]
917
- assert_equal(expected, @parser.parse("module", source)[:functions])
918
- end
919
-
920
- it "properly parse const and pointer argument types with arg names" do
921
-
922
- source = "void bar(int const* param1, int*const param2, const int* param3, const int*const param4,\n" +
923
- " int const*const param5, int*param6, int param7, const int param8);\n"
924
-
925
- expected = [{ :name => "bar",
926
- :modifier => "",
927
- :return => { :type => "void",
928
- :name => "cmock_to_return",
929
- :str => "void cmock_to_return",
930
- :void? => true,
931
- :ptr? => false,
932
- :const? => false,
933
- :const_ptr? => false
934
- },
935
- :var_arg => nil,
936
- :args_string => "int const* param1, int* const param2, const int* param3, const int* const param4, " +
937
- "int const* const param5, int* param6, int param7, const int param8",
938
- :args => [{ :type=>"int const*", :name => "param1", :ptr? => true, :const? => true, :const_ptr? => false },
939
- { :type=>"int*", :name => "param2", :ptr? => true, :const? => false, :const_ptr? => true },
940
- { :type=>"const int*", :name => "param3", :ptr? => true, :const? => true, :const_ptr? => false },
941
- { :type=>"const int*", :name => "param4", :ptr? => true, :const? => true, :const_ptr? => true },
942
- { :type=>"int const*", :name => "param5", :ptr? => true, :const? => true, :const_ptr? => true },
943
- { :type=>"int*", :name => "param6", :ptr? => true, :const? => false, :const_ptr? => false },
944
- { :type=>"int", :name => "param7", :ptr? => false, :const? => false, :const_ptr? => false },
945
- { :type=>"int", :name => "param8", :ptr? => false, :const? => true, :const_ptr? => false }],
946
- :args_call => "param1, param2, param3, param4, param5, param6, param7, param8",
947
- :contains_ptr? => true
948
- }]
949
- assert_equal(expected, @parser.parse("module", source)[:functions])
950
- end
951
-
952
- it "properly detect typedef'd variants of void and use those" do
953
-
954
- source = "typedef (void) FUNKY_VOID_T;\n" +
955
- "typedef void CHUNKY_VOID_T;\n" +
956
- "FUNKY_VOID_T DrHorrible(int SingAlong);\n" +
957
- "int CaptainHammer(CHUNKY_VOID_T);\n"
958
-
959
- expected = [{ :var_arg=>nil,
960
- :name=>"DrHorrible",
961
- :return => { :type => "void",
962
- :name => 'cmock_to_return',
963
- :ptr? => false,
964
- :const? => false,
965
- :const_ptr? => false,
966
- :str => "void cmock_to_return",
967
- :void? => true
968
- },
969
- :modifier=>"",
970
- :contains_ptr? => false,
971
- :args=>[ {:type=>"int", :name=>"SingAlong", :ptr? => false, :const? => false, :const_ptr? => false} ],
972
- :args_string=>"int SingAlong",
973
- :args_call=>"SingAlong"
974
- },
975
- { :var_arg=>nil,
976
- :return=> { :type => "int",
977
- :name => 'cmock_to_return',
978
- :ptr? => false,
979
- :const? => false,
980
- :const_ptr? => false,
981
- :str => "int cmock_to_return",
982
- :void? => false
983
- },
984
- :name=>"CaptainHammer",
985
- :modifier=>"",
986
- :contains_ptr? => false,
987
- :args=>[ ],
988
- :args_string=>"void",
989
- :args_call=>""
990
- }]
991
- assert_equal(expected, @parser.parse("module", source)[:functions])
992
- end
993
-
994
- it "be ok with structs inside of function declarations" do
995
-
996
- source = "int DrHorrible(struct SingAlong Blog);\n" +
997
- "void Penny(struct const _KeepYourHeadUp_ * const BillyBuddy);\n" +
998
- "struct TheseArentTheHammer CaptainHammer(void);\n"
999
-
1000
- expected = [{ :var_arg=>nil,
1001
- :return =>{ :type => "int",
1002
- :name => 'cmock_to_return',
1003
- :ptr? => false,
1004
- :const? => false,
1005
- :const_ptr? => false,
1006
- :str => "int cmock_to_return",
1007
- :void? => false
1008
- },
1009
- :name=>"DrHorrible",
1010
- :modifier=>"",
1011
- :contains_ptr? => false,
1012
- :args=>[ {:type=>"struct SingAlong", :name=>"Blog", :ptr? => false, :const? => false, :const_ptr? => false} ],
1013
- :args_string=>"struct SingAlong Blog",
1014
- :args_call=>"Blog"
1015
- },
1016
- { :var_arg=>nil,
1017
- :return=> { :type => "void",
1018
- :name => 'cmock_to_return',
1019
- :ptr? => false,
1020
- :const? => false,
1021
- :const_ptr? => false,
1022
- :str => "void cmock_to_return",
1023
- :void? => true
1024
- },
1025
- :name=>"Penny",
1026
- :modifier=>"",
1027
- :contains_ptr? => true,
1028
- :args=>[ {:type=>"struct const _KeepYourHeadUp_*", :name=>"BillyBuddy", :ptr? => true, :const? => true, :const_ptr? => true} ],
1029
- :args_string=>"struct const _KeepYourHeadUp_* const BillyBuddy",
1030
- :args_call=>"BillyBuddy"
1031
- },
1032
- { :var_arg=>nil,
1033
- :return=> { :type => "struct TheseArentTheHammer",
1034
- :name => 'cmock_to_return',
1035
- :ptr? => false,
1036
- :const? => false,
1037
- :const_ptr? => false,
1038
- :str => "struct TheseArentTheHammer cmock_to_return",
1039
- :void? => false
1040
- },
1041
- :name=>"CaptainHammer",
1042
- :modifier=>"",
1043
- :contains_ptr? => false,
1044
- :args=>[ ],
1045
- :args_string=>"void",
1046
- :args_call=>""
1047
- }]
1048
- assert_equal(expected, @parser.parse("module", source)[:functions])
1049
- end
1050
-
1051
- it "extract functions containing unions with union specifier" do
1052
- source = "void OrangePeel(union STARS_AND_STRIPES * a, union AFL_CIO b)"
1053
- expected = [{ :var_arg=>nil,
1054
- :return=>{ :type => "void",
1055
- :name => 'cmock_to_return',
1056
- :ptr? => false,
1057
- :const? => false,
1058
- :const_ptr? => false,
1059
- :str => "void cmock_to_return",
1060
- :void? => true
1061
- },
1062
- :name=>"OrangePeel",
1063
- :modifier=>"",
1064
- :contains_ptr? => true,
1065
- :args=>[ {:type=>"union STARS_AND_STRIPES*", :name=>"a", :ptr? => true, :const? => false, :const_ptr? => false},
1066
- {:type=>"union AFL_CIO", :name=>"b", :ptr? => false, :const? => false, :const_ptr? => false}
1067
- ],
1068
- :args_string=>"union STARS_AND_STRIPES* a, union AFL_CIO b",
1069
- :args_call=>"a, b" }]
1070
- result = @parser.parse("module", source)
1071
- assert_equal(expected, result[:functions])
1072
- end
1073
-
1074
- it "not be thwarted by variables named with primitive types as part of the name" do
1075
- source = "void ApplePeel(const unsigned int const_param, int int_param, int integer, char character, int* const constant)"
1076
- expected = [{ :var_arg=>nil,
1077
- :return=>{ :type => "void",
1078
- :name => 'cmock_to_return',
1079
- :ptr? => false,
1080
- :const? => false,
1081
- :const_ptr? => false,
1082
- :str => "void cmock_to_return",
1083
- :void? => true
1084
- },
1085
- :name=>"ApplePeel",
1086
- :modifier=>"",
1087
- :contains_ptr? => true,
1088
- :args=>[ {:type=> "unsigned int", :name=>"const_param", :ptr? => false, :const? => true, :const_ptr? => false},
1089
- {:type=>"int", :name=>"int_param", :ptr? => false, :const? => false, :const_ptr? => false},
1090
- {:type=>"int", :name=>"integer", :ptr? => false, :const? => false, :const_ptr? => false},
1091
- {:type=>"char", :name=>"character", :ptr? => false, :const? => false, :const_ptr? => false},
1092
- {:type=>"int*", :name=>"constant", :ptr? => true, :const? => false, :const_ptr? => true}
1093
- ],
1094
- :args_string=>"const unsigned int const_param, int int_param, int integer, char character, int* const constant",
1095
- :args_call=>"const_param, int_param, integer, character, constant" }]
1096
- result = @parser.parse("module", source)
1097
- assert_equal(expected, result[:functions])
1098
- end
1099
-
1100
- it "not be thwarted by custom types named similarly to primitive types" do
1101
- source = "void LemonPeel(integer param, character thing, longint * junk, constant value, int32_t const number)"
1102
- expected = [{:var_arg=>nil,
1103
- :return=>{ :type => "void",
1104
- :name => 'cmock_to_return',
1105
- :ptr? => false,
1106
- :const? => false,
1107
- :const_ptr? => false,
1108
- :str => "void cmock_to_return",
1109
- :void? => true
1110
- },
1111
- :name=>"LemonPeel",
1112
- :modifier=>"",
1113
- :contains_ptr? => true,
1114
- :args=>[ {:type=>"integer", :name=>"param", :ptr? => false, :const? => false, :const_ptr? => false},
1115
- {:type=>"character", :name=>"thing", :ptr? => false, :const? => false, :const_ptr? => false},
1116
- {:type=>"longint*", :name=>"junk", :ptr? => true, :const? => false, :const_ptr? => false},
1117
- {:type=>"constant", :name=>"value", :ptr? => false, :const? => false, :const_ptr? => false},
1118
- {:type=>"int32_t", :name=>"number", :ptr? => false, :const? => true, :const_ptr? => false}
1119
- ],
1120
- :args_string=>"integer param, character thing, longint* junk, constant value, int32_t const number",
1121
- :args_call=>"param, thing, junk, value, number" }]
1122
- result = @parser.parse("module", source)
1123
- assert_equal(expected, result[:functions])
1124
- end
1125
-
1126
- it "handle some of those chains of C name specifiers naturally" do
1127
- source = "void CoinOperated(signed char abc, const unsigned long int xyz_123, unsigned int const abc_123, long long arm_of_the_law)"
1128
- expected = [{:var_arg=>nil,
1129
- :return=>{ :type => "void",
1130
- :name => 'cmock_to_return',
1131
- :ptr? => false,
1132
- :const? => false,
1133
- :const_ptr? => false,
1134
- :str => "void cmock_to_return",
1135
- :void? => true
1136
- },
1137
- :name=>"CoinOperated",
1138
- :modifier=>"",
1139
- :contains_ptr? => false,
1140
- :args=>[ {:type=>"signed char", :name=>"abc", :ptr? => false, :const? => false, :const_ptr? => false},
1141
- {:type=>"unsigned long int", :name=>"xyz_123", :ptr? => false, :const? => true, :const_ptr? => false},
1142
- {:type=>"unsigned int", :name=>"abc_123", :ptr? => false, :const? => true, :const_ptr? => false},
1143
- {:type=>"long long", :name=>"arm_of_the_law", :ptr? => false, :const? => false, :const_ptr? => false}
1144
- ],
1145
- :args_string=>"signed char abc, const unsigned long int xyz_123, unsigned int const abc_123, long long arm_of_the_law",
1146
- :args_call=>"abc, xyz_123, abc_123, arm_of_the_law" }]
1147
- result = @parser.parse("module", source)
1148
- assert_equal(expected, result[:functions])
1149
- end
1150
-
1151
- it "handle custom types of various formats" do
1152
- source = "void CardOperated(CUSTOM_TYPE abc, CUSTOM_TYPE* xyz_123, CUSTOM_TYPE const abcxyz, struct CUSTOM_TYPE const * const abc123)"
1153
- expected = [{:var_arg=>nil,
1154
- :return=>{ :type => "void",
1155
- :name => 'cmock_to_return',
1156
- :ptr? => false,
1157
- :const? => false,
1158
- :const_ptr? => false,
1159
- :str => "void cmock_to_return",
1160
- :void? => true
1161
- },
1162
- :name=>"CardOperated",
1163
- :modifier=>"",
1164
- :contains_ptr? => true,
1165
- :args=>[ {:type=>"CUSTOM_TYPE", :name=>"abc", :ptr? => false, :const? => false, :const_ptr? => false},
1166
- {:type=>"CUSTOM_TYPE*", :name=>"xyz_123", :ptr? => true, :const? => false, :const_ptr? => false},
1167
- {:type=>"CUSTOM_TYPE", :name=>"abcxyz", :ptr? => false, :const? => true, :const_ptr? => false},
1168
- {:type=>"struct CUSTOM_TYPE const*", :name=>"abc123", :ptr? => true, :const? => true, :const_ptr? => true}
1169
- ],
1170
- :args_string=>"CUSTOM_TYPE abc, CUSTOM_TYPE* xyz_123, CUSTOM_TYPE const abcxyz, struct CUSTOM_TYPE const* const abc123",
1171
- :args_call=>"abc, xyz_123, abcxyz, abc123" }]
1172
- result = @parser.parse("module", source)
1173
- assert_equal(expected, result[:functions])
1174
- end
1175
-
1176
- it "handle arrays and treat them as pointers or strings" do
1177
- source = "void KeyOperated(CUSTOM_TYPE thing1[], int thing2 [ ], char thing3 [][2 ][ 3], int* thing4[4])"
1178
- expected = [{:var_arg=>nil,
1179
- :return=>{ :type => "void",
1180
- :name => 'cmock_to_return',
1181
- :ptr? => false,
1182
- :const? => false,
1183
- :const_ptr? => false,
1184
- :str => "void cmock_to_return",
1185
- :void? => true
1186
- },
1187
- :name=>"KeyOperated",
1188
- :modifier=>"",
1189
- :contains_ptr? => true,
1190
- :args=>[ {:type=>"CUSTOM_TYPE*", :name=>"thing1", :ptr? => true, :const? => false, :const_ptr? => false},
1191
- {:type=>"int*", :name=>"thing2", :ptr? => true, :const? => false, :const_ptr? => false},
1192
- {: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
1193
- {: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
1194
- ],
1195
- :args_string=>"CUSTOM_TYPE* thing1, int* thing2, char* thing3, int** thing4",
1196
- :args_call=>"thing1, thing2, thing3, thing4" }]
1197
- result = @parser.parse("module", source)
1198
- assert_equal(expected, result[:functions])
1199
- end
1200
-
1201
- it "give a reasonable guess when dealing with weird combinations of custom types and modifiers" do
1202
- source = "void Cheese(unsigned CUSTOM_TYPE abc, unsigned xyz, CUSTOM_TYPE1 CUSTOM_TYPE2 pdq)"
1203
- expected = [{:var_arg=>nil,
1204
- :return=>{ :type => "void",
1205
- :name => 'cmock_to_return',
1206
- :ptr? => false,
1207
- :const? => false,
1208
- :const_ptr? => false,
1209
- :str => "void cmock_to_return",
1210
- :void? => true
1211
- },
1212
- :name=>"Cheese",
1213
- :modifier=>"",
1214
- :contains_ptr? => false,
1215
- :args=>[ {:type=>"unsigned CUSTOM_TYPE", :name=>"abc", :ptr? => false, :const? => false, :const_ptr? => false},
1216
- {:type=>"unsigned", :name=>"xyz", :ptr? => false, :const? => false, :const_ptr? => false},
1217
- {:type=>"CUSTOM_TYPE1 CUSTOM_TYPE2", :name=>"pdq", :ptr? => false, :const? => false, :const_ptr? => false}
1218
- ],
1219
- :args_string=>"unsigned CUSTOM_TYPE abc, unsigned xyz, CUSTOM_TYPE1 CUSTOM_TYPE2 pdq",
1220
- :args_call=>"abc, xyz, pdq" }]
1221
- result = @parser.parse("module", source)
1222
- assert_equal(expected, result[:functions])
1223
- end
1224
-
1225
- it "extract functions containing a function pointer" do
1226
- source = "void FunkyTurkey(unsigned int (*func_ptr)(int, char))"
1227
- expected = [{ :var_arg=>nil,
1228
- :return=>{ :type => "void",
1229
- :name => 'cmock_to_return',
1230
- :ptr? => false,
1231
- :const? => false,
1232
- :const_ptr? => false,
1233
- :str => "void cmock_to_return",
1234
- :void? => true
1235
- },
1236
- :name=>"FunkyTurkey",
1237
- :modifier=>"",
1238
- :contains_ptr? => false,
1239
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1240
- ],
1241
- :args_string=>"cmock_module_func_ptr1 func_ptr",
1242
- :args_call=>"func_ptr" }]
1243
- typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char);"]
1244
- result = @parser.parse("module", source)
1245
- assert_equal(expected, result[:functions])
1246
- assert_equal(typedefs, result[:typedefs])
1247
- end
1248
-
1249
- it "extract functions containing a function pointer with a void" do
1250
- source = "void FunkyTurkey(void (*func_ptr)(void))"
1251
- expected = [{ :var_arg=>nil,
1252
- :return=>{ :type => "void",
1253
- :name => 'cmock_to_return',
1254
- :ptr? => false,
1255
- :const? => false,
1256
- :const_ptr? => false,
1257
- :str => "void cmock_to_return",
1258
- :void? => true
1259
- },
1260
- :name=>"FunkyTurkey",
1261
- :modifier=>"",
1262
- :contains_ptr? => false,
1263
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1264
- ],
1265
- :args_string=>"cmock_module_func_ptr1 func_ptr",
1266
- :args_call=>"func_ptr" }]
1267
- typedefs = ["typedef void(*cmock_module_func_ptr1)(void);"]
1268
- result = @parser.parse("module", source)
1269
- assert_equal(expected, result[:functions])
1270
- assert_equal(typedefs, result[:typedefs])
1271
- end
1272
-
1273
- it "extract functions containing a function pointer with an implied void" do
1274
- source = "void FunkyTurkey(unsigned int (*func_ptr)())"
1275
- expected = [{ :var_arg=>nil,
1276
- :return=>{ :type => "void",
1277
- :name => 'cmock_to_return',
1278
- :ptr? => false,
1279
- :const? => false,
1280
- :const_ptr? => false,
1281
- :str => "void cmock_to_return",
1282
- :void? => true
1283
- },
1284
- :name=>"FunkyTurkey",
1285
- :modifier=>"",
1286
- :contains_ptr? => false,
1287
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1288
- ],
1289
- :args_string=>"cmock_module_func_ptr1 func_ptr",
1290
- :args_call=>"func_ptr" }]
1291
- typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)();"]
1292
- result = @parser.parse("module", source)
1293
- assert_equal(expected, result[:functions])
1294
- assert_equal(typedefs, result[:typedefs])
1295
- end
1296
-
1297
- it "extract functions containing a constant function pointer and a pointer in the nested arg list" do
1298
- source = "void FunkyChicken(unsigned int (* const func_ptr)(unsigned long int * , char))"
1299
- expected = [{ :var_arg=>nil,
1300
- :return=>{ :type => "void",
1301
- :name => 'cmock_to_return',
1302
- :ptr? => false,
1303
- :const? => false,
1304
- :const_ptr? => false,
1305
- :str => "void cmock_to_return",
1306
- :void? => true
1307
- },
1308
- :name=>"FunkyChicken",
1309
- :modifier=>"",
1310
- :contains_ptr? => false,
1311
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => true, :const_ptr? => false}
1312
- ],
1313
- :args_string=>"cmock_module_func_ptr1 const func_ptr",
1314
- :args_call=>"func_ptr" }]
1315
- typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(unsigned long int* , char);"]
1316
- result = @parser.parse("module", source)
1317
- assert_equal(expected, result[:functions])
1318
- assert_equal(typedefs, result[:typedefs])
1319
- end
1320
-
1321
- # it "extract functions containing a function pointer taking a vararg" do
1322
- # source = "void FunkyParrot(unsigned int (*func_ptr)(int, char, ...))"
1323
- # expected = [{ :var_arg=>nil,
1324
- # :return=>{ :type => "void",
1325
- # :name => 'cmock_to_return',
1326
- # :ptr? => false,
1327
- # :const? => false,
1328
- # :const_ptr? => false,
1329
- # :str => "void cmock_to_return",
1330
- # :void? => true
1331
- # },
1332
- # :name=>"FunkyParrot",
1333
- # :modifier=>"",
1334
- # :contains_ptr? => false,
1335
- # :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1336
- # ],
1337
- # :args_string=>"cmock_module_func_ptr1 func_ptr",
1338
- # :args_call=>"func_ptr" }]
1339
- # typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char, ...);"]
1340
- # result = @parser.parse("module", source)
1341
- # assert_equal(expected, result[:functions])
1342
- # assert_equal(typedefs, result[:typedefs])
1343
- # end
1344
-
1345
- it "extract functions containing a function pointer with extra parenthesis and two sets" do
1346
- source = "void FunkyBudgie(int (((* func_ptr1)(int, char))), void (*func_ptr2)(void))"
1347
- expected = [{ :var_arg=>nil,
1348
- :return=>{ :type => "void",
1349
- :name => 'cmock_to_return',
1350
- :ptr? => false,
1351
- :const? => false,
1352
- :const_ptr? => false,
1353
- :str => "void cmock_to_return",
1354
- :void? => true
1355
- },
1356
- :name=>"FunkyBudgie",
1357
- :modifier=>"",
1358
- :contains_ptr? => false,
1359
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr1", :ptr? => false, :const? => false, :const_ptr? => false},
1360
- {:type=>"cmock_module_func_ptr2", :name=>"func_ptr2", :ptr? => false, :const? => false, :const_ptr? => false}
1361
- ],
1362
- :args_string=>"cmock_module_func_ptr1 func_ptr1, cmock_module_func_ptr2 func_ptr2",
1363
- :args_call=>"func_ptr1, func_ptr2" }]
1364
- typedefs = ["typedef int(*cmock_module_func_ptr1)(int, char);", "typedef void(*cmock_module_func_ptr2)(void);"]
1365
- result = @parser.parse("module", source)
1366
- assert_equal(expected, result[:functions])
1367
- assert_equal(typedefs, result[:typedefs])
1368
- end
1369
-
1370
- it "extract functions containing a function pointers, structs and other things" do
1371
- source = "struct mytype *FunkyRobin(uint16_t num1, uint16_t num2, void (*func_ptr1)(uint16_t num3, struct mytype2 *s));"
1372
- expected = [{ :var_arg=>nil,
1373
- :return=>{ :type => "struct mytype*",
1374
- :name => 'cmock_to_return',
1375
- :ptr? => true,
1376
- :const? => false,
1377
- :const_ptr? => false,
1378
- :str => "struct mytype* cmock_to_return",
1379
- :void? => false
1380
- },
1381
- :name=>"FunkyRobin",
1382
- :modifier=>"",
1383
- :contains_ptr? => false,
1384
- :args=>[ {:type=>"uint16_t", :name=>"num1", :ptr? => false, :const? => false, :const_ptr? => false},
1385
- {:type=>"uint16_t", :name=>"num2", :ptr? => false, :const? => false, :const_ptr? => false},
1386
- {:type=>"cmock_module_func_ptr1", :name=>"func_ptr1", :ptr? => false, :const? => false, :const_ptr? => false}
1387
- ],
1388
- :args_string=>"uint16_t num1, uint16_t num2, cmock_module_func_ptr1 func_ptr1",
1389
- :args_call=>"num1, num2, func_ptr1" }]
1390
- typedefs = ["typedef void(*cmock_module_func_ptr1)(uint16_t num3, struct mytype2* s);"]
1391
- result = @parser.parse("module", source)
1392
- assert_equal(expected, result[:functions])
1393
- assert_equal(typedefs, result[:typedefs])
1394
- end
1395
-
1396
- it "extract functions containing an anonymous function pointer" do
1397
- source = "void FunkyFowl(unsigned int (* const)(int, char))"
1398
- expected = [{ :var_arg=>nil,
1399
- :return=>{ :type => "void",
1400
- :name => 'cmock_to_return',
1401
- :ptr? => false,
1402
- :const? => false,
1403
- :const_ptr? => false,
1404
- :str => "void cmock_to_return",
1405
- :void? => true
1406
- },
1407
- :name=>"FunkyFowl",
1408
- :modifier=>"",
1409
- :contains_ptr? => false,
1410
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"cmock_arg1", :ptr? => false, :const? => true, :const_ptr? => false}
1411
- ],
1412
- :args_string=>"cmock_module_func_ptr1 const cmock_arg1",
1413
- :args_call=>"cmock_arg1" }]
1414
- typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char);"]
1415
- result = @parser.parse("module", source)
1416
- assert_equal(expected, result[:functions])
1417
- assert_equal(typedefs, result[:typedefs])
1418
- end
1419
-
1420
- it "extract functions returning a function pointer" do
1421
- source = "unsigned short (*FunkyPidgeon( const char op_code ))( int, long int )"
1422
- expected = [{ :var_arg=>nil,
1423
- :return=>{ :type => "cmock_module_func_ptr1",
1424
- :name => 'cmock_to_return',
1425
- :ptr? => false,
1426
- :const? => false,
1427
- :const_ptr? => false,
1428
- :str => "cmock_module_func_ptr1 cmock_to_return",
1429
- :void? => false
1430
- },
1431
- :name=>"FunkyPidgeon",
1432
- :modifier=>"",
1433
- :contains_ptr? => false,
1434
- :args=>[ {:type=>"char", :name=>"op_code", :ptr? => false, :const? => true, :const_ptr? => false}
1435
- ],
1436
- :args_string=>"const char op_code",
1437
- :args_call=>"op_code" }]
1438
- typedefs = ["typedef unsigned short(*cmock_module_func_ptr1)( int, long int );"]
1439
- result = @parser.parse("module", source)
1440
- assert_equal(expected, result[:functions])
1441
- assert_equal(typedefs, result[:typedefs])
1442
- end
1443
-
1444
- it "extract functions returning a function pointer with implied void" do
1445
- source = "unsigned short (*FunkyTweetie())()"
1446
- expected = [{ :var_arg=>nil,
1447
- :return=>{ :type => "cmock_module_func_ptr1",
1448
- :name => 'cmock_to_return',
1449
- :ptr? => false,
1450
- :const? => false,
1451
- :const_ptr? => false,
1452
- :str => "cmock_module_func_ptr1 cmock_to_return",
1453
- :void? => false
1454
- },
1455
- :name=>"FunkyTweetie",
1456
- :modifier=>"",
1457
- :contains_ptr? => false,
1458
- :args=>[],
1459
- :args_string=>"void",
1460
- :args_call=>"" }]
1461
- typedefs = ["typedef unsigned short(*cmock_module_func_ptr1)();"]
1462
- result = @parser.parse("module", source)
1463
- assert_equal(expected, result[:functions])
1464
- assert_equal(typedefs, result[:typedefs])
1465
- end
1466
-
1467
- it "extract functions returning a function pointer where everything is a void" do
1468
- source = "void (* FunkySeaGull(void))(void)"
1469
- expected = [{ :var_arg=>nil,
1470
- :return=>{ :type => "cmock_module_func_ptr1",
1471
- :name => 'cmock_to_return',
1472
- :ptr? => false,
1473
- :const? => false,
1474
- :const_ptr? => false,
1475
- :str => "cmock_module_func_ptr1 cmock_to_return",
1476
- :void? => false
1477
- },
1478
- :name=>"FunkySeaGull",
1479
- :modifier=>"",
1480
- :contains_ptr? => false,
1481
- :args=>[],
1482
- :args_string=>"void",
1483
- :args_call=>"" }]
1484
- typedefs = ["typedef void(*cmock_module_func_ptr1)(void);"]
1485
- result = @parser.parse("module", source)
1486
- assert_equal(expected, result[:functions])
1487
- assert_equal(typedefs, result[:typedefs])
1488
- end
1489
-
1490
- it "extract functions returning a function pointer with some pointer nonsense" do
1491
- source = "unsigned int * (* FunkyMacaw(double* foo, THING *bar))(unsigned int)"
1492
- expected = [{ :var_arg=>nil,
1493
- :return=>{ :type => "cmock_module_func_ptr1",
1494
- :name => 'cmock_to_return',
1495
- :ptr? => false,
1496
- :const? => false,
1497
- :const_ptr? => false,
1498
- :str => "cmock_module_func_ptr1 cmock_to_return",
1499
- :void? => false
1500
- },
1501
- :name=>"FunkyMacaw",
1502
- :modifier=>"",
1503
- :contains_ptr? => true,
1504
- :args=>[ {:type=>"double*", :name=>"foo", :ptr? => true, :const? => false, :const_ptr? => false},
1505
- {:type=>"THING*", :name=>"bar", :ptr? => true, :const? => false, :const_ptr? => false}
1506
- ],
1507
- :args_string=>"double* foo, THING* bar",
1508
- :args_call=>"foo, bar" }]
1509
- typedefs = ["typedef unsigned int *(*cmock_module_func_ptr1)(unsigned int);"]
1510
- result = @parser.parse("module", source)
1511
- assert_equal(expected, result[:functions])
1512
- assert_equal(typedefs, result[:typedefs])
1513
- end
1514
-
1515
- it "extract this SQLite3 function with an anonymous function pointer arg (regression test)" do
1516
- source = "SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*))"
1517
- expected = [{ :var_arg=>nil,
1518
- :return=>{ :type => "int",
1519
- :name => "cmock_to_return",
1520
- :ptr? => false,
1521
- :const? => false,
1522
- :const_ptr? => false,
1523
- :str => "int cmock_to_return",
1524
- :void? => false
1525
- },
1526
- :name=>"sqlite3_bind_text",
1527
- :modifier=>"SQLITE_API",
1528
- :contains_ptr? => true,
1529
- :args=>[ {:type=>"sqlite3_stmt*", :name=>"cmock_arg2", :ptr? => true, :const? => false, :const_ptr? => false},
1530
- {:type=>"int", :name=>"cmock_arg3", :ptr? => false, :const? => false, :const_ptr? => false},
1531
- {:type=>"const char*", :name=>"cmock_arg4", :ptr? => false, :const? => true, :const_ptr? => false},
1532
- {:type=>"int", :name=>"n", :ptr? => false, :const? => false, :const_ptr? => false},
1533
- {:type=>"cmock_module_func_ptr1", :name=>"cmock_arg1", :ptr? => false, :const? => false, :const_ptr? => false}
1534
- ],
1535
- :args_string=>"sqlite3_stmt* cmock_arg2, int cmock_arg3, const char* cmock_arg4, int n, cmock_module_func_ptr1 cmock_arg1",
1536
- :args_call=>"cmock_arg2, cmock_arg3, cmock_arg4, n, cmock_arg1" }]
1537
- typedefs = ["typedef void(*cmock_module_func_ptr1)(void*);"]
1538
- result = @parser.parse("module", source)
1539
- assert_equal(expected, result[:functions])
1540
- assert_equal(typedefs, result[:typedefs])
1541
- end
1542
-
1543
- it "extract functions with varargs" do
1544
- source = "int XFiles(int Scully, int Mulder, ...);\n"
1545
- expected = [{ :var_arg=>"...",
1546
- :return=> { :type => "int",
1547
- :name => 'cmock_to_return',
1548
- :ptr? => false,
1549
- :const? => false,
1550
- :const_ptr? => false,
1551
- :str => "int cmock_to_return",
1552
- :void? => false
1553
- },
1554
- :name=>"XFiles",
1555
- :modifier=>"",
1556
- :contains_ptr? => false,
1557
- :args=>[ {:type=>"int", :name=>"Scully", :ptr? => false, :const? => false, :const_ptr? => false},
1558
- {:type=>"int", :name=>"Mulder", :ptr? => false, :const? => false, :const_ptr? => false}
1559
- ],
1560
- :args_string=>"int Scully, int Mulder",
1561
- :args_call=>"Scully, Mulder"
1562
- }]
1563
- assert_equal(expected, @parser.parse("module", source)[:functions])
1564
- end
1565
-
1566
- it "extract functions with void pointers" do
1567
- source = "void* MoreSillySongs(void* stuff);\n"
1568
- expected = [{ :var_arg=>nil,
1569
- :return=> { :type => "void*",
1570
- :name => 'cmock_to_return',
1571
- :ptr? => true,
1572
- :const? => false,
1573
- :const_ptr? => false,
1574
- :str => "void* cmock_to_return",
1575
- :void? => false
1576
- },
1577
- :name=>"MoreSillySongs",
1578
- :modifier=>"",
1579
- :contains_ptr? => true,
1580
- :args=>[ {:type=>"void*", :name=>"stuff", :ptr? => true, :const? => false, :const_ptr? => false}
1581
- ],
1582
- :args_string=>"void* stuff",
1583
- :args_call=>"stuff"
1584
- }]
1585
- assert_equal(expected, @parser.parse("module", source)[:functions])
1586
- end
1587
-
1588
- it "extract functions with strippable confusing junk like gcc attributes" do
1589
- source = "int LaverneAndShirley(int Lenny, int Squiggy) __attribute__((weak)) __attribute__ ((deprecated));\n"
1590
- expected = [{ :var_arg=>nil,
1591
- :return=> { :type => "int",
1592
- :name => 'cmock_to_return',
1593
- :ptr? => false,
1594
- :const? => false,
1595
- :const_ptr? => false,
1596
- :str => "int cmock_to_return",
1597
- :void? => false
1598
- },
1599
- :name=>"LaverneAndShirley",
1600
- :modifier=>"",
1601
- :contains_ptr? => false,
1602
- :args=>[ {:type=>"int", :name=>"Lenny", :ptr? => false, :const? => false, :const_ptr? => false},
1603
- {:type=>"int", :name=>"Squiggy", :ptr? => false, :const? => false, :const_ptr? => false}
1604
- ],
1605
- :args_string=>"int Lenny, int Squiggy",
1606
- :args_call=>"Lenny, Squiggy"
1607
- }]
1608
- assert_equal(expected, @parser.parse("module", source)[:functions])
1609
- end
1610
-
1611
- it "extract functions with strippable confusing junk like gcc attributes with parenthesis" do
1612
- source = "int TheCosbyShow(int Cliff, int Claire) __attribute__((weak, alias (\"__f\"));\n"
1613
- expected = [{ :var_arg=>nil,
1614
- :return=> { :type => "int",
1615
- :name => 'cmock_to_return',
1616
- :ptr? => false,
1617
- :const? => false,
1618
- :const_ptr? => false,
1619
- :str => "int cmock_to_return",
1620
- :void? => false
1621
- },
1622
- :name=>"TheCosbyShow",
1623
- :modifier=>"",
1624
- :contains_ptr? => false,
1625
- :args=>[ {:type=>"int", :name=>"Cliff", :ptr? => false, :const? => false, :const_ptr? => false},
1626
- {:type=>"int", :name=>"Claire", :ptr? => false, :const? => false, :const_ptr? => false}
1627
- ],
1628
- :args_string=>"int Cliff, int Claire",
1629
- :args_call=>"Cliff, Claire"
1630
- }]
1631
- assert_equal(expected, @parser.parse("module", source)[:functions])
1632
- end
1633
-
1634
- it "divines all permutations of ptr, const, and const_ptr correctly" do
1635
- truth_table = [
1636
- # argument ptr const const_ptr
1637
- [ "constNOTconst constNOTconst", false, false, false ],
1638
- [ "const constNOTconst constNOTconst", false, true, false ],
1639
- [ "constNOTconst const constNOTconst", false, true, false ],
1640
- [ "constNOTconst *constNOTconst", true, false, false ],
1641
- [ "const constNOTconst *constNOTconst", true, true, false ],
1642
- [ "constNOTconst const *constNOTconst", true, true, false ],
1643
- [ "constNOTconst *const constNOTconst", true, false, true ],
1644
- [ "const constNOTconst *const constNOTconst", true, true, true ],
1645
- [ "constNOTconst const *const constNOTconst", true, true, true ],
1646
- [ "constNOTconst **constNOTconst", true, false, false ],
1647
- [ "const constNOTconst **constNOTconst", true, false, false ],
1648
- [ "constNOTconst const **constNOTconst", true, false, false ],
1649
- [ "constNOTconst *const *constNOTconst", true, true, false ],
1650
- [ "const constNOTconst *const *constNOTconst", true, true, false ],
1651
- [ "constNOTconst const *const *constNOTconst", true, true, false ],
1652
- [ "constNOTconst **const constNOTconst", true, false, true ],
1653
- [ "const constNOTconst **const constNOTconst", true, false, true ],
1654
- [ "constNOTconst const **const constNOTconst", true, false, true ],
1655
- [ "constNOTconst *const *const constNOTconst", true, true, true ],
1656
- [ "const constNOTconst *const *const constNOTconst", true, true, true ],
1657
- [ "constNOTconst const *const *const constNOTconst", true, true, true ]
1658
- ]
1659
-
1660
- truth_table.each do |entry|
1661
- assert_equal(@parser.divine_ptr(entry[0]), entry[1])
1662
- assert_equal(@parser.divine_const(entry[0]), entry[2])
1663
- assert_equal(@parser.divine_ptr_and_const(entry[0]),
1664
- { ptr?: entry[1], const?: entry[2], const_ptr?: entry[3] })
1665
- end
1666
- end
1667
-
1668
- it "divines ptr correctly for string types" do
1669
- truth_table = [
1670
- # argument ptr
1671
- [ "char s", false ],
1672
- [ "const char s", false ],
1673
- [ "char const s", false ],
1674
- [ "char *s", false ],
1675
- [ "const char *s", false ],
1676
- [ "char const *s", false ],
1677
- [ "char *const s", false ],
1678
- [ "const char *const s", false ],
1679
- [ "char const *const s", false ],
1680
- [ "char **s", true ],
1681
- [ "const char **s", true ],
1682
- [ "char const **s", true ],
1683
- [ "char *const *s", true ],
1684
- [ "const char *const *s", true ],
1685
- [ "char const *const *s", true ],
1686
- [ "char **const s", true ],
1687
- [ "const char **const s", true ],
1688
- [ "char const **const s", true ],
1689
- [ "char *const *const s", true ],
1690
- [ "const char *const *const s", true ],
1691
- [ "char const *const *const s", true ]
1692
- ]
1693
-
1694
- truth_table.each do |entry|
1695
- assert_equal(@parser.divine_ptr(entry[0]), entry[1])
1696
- end
1697
- end
1698
-
1699
- 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 :array_size_type, ['int', 'size_t']
27
+ @config.expect :array_size_name, 'size|len'
28
+
29
+ @parser = CMockHeaderParser.new(@config)
30
+ end
31
+
32
+ after do
33
+ end
34
+
35
+ it "create and initialize variables to defaults appropriately" do
36
+ assert_equal([], @parser.funcs)
37
+ assert_equal(['const', '__ramfunc', 'funky_attrib', 'SQLITE_API'], @parser.c_attributes)
38
+ assert_equal(['void','MY_FUNKY_VOID'], @parser.treat_as_void)
39
+ end
40
+
41
+ it "strip out line comments" do
42
+ source =
43
+ " abcd;\n" +
44
+ "// hello;\n" +
45
+ "who // is you\n"
46
+
47
+ expected =
48
+ [
49
+ "abcd",
50
+ "who"
51
+ ]
52
+
53
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
54
+ end
55
+
56
+ it "remove block comments" do
57
+ source =
58
+ " no_comments;\n" +
59
+ "// basic_line_comment;\n" +
60
+ "/* basic_block_comment;*/\n" +
61
+ "pre_block; /* start_of_block_comment;\n" +
62
+ "// embedded_line_comment_in_block_comment; */\n" +
63
+ "// /* commented_out_block_comment_line\n" +
64
+ "shown_because_block_comment_invalid_from_line_comment;\n" +
65
+ "// */\n" +
66
+ "//* shorter_commented_out_block_comment_line; \n" +
67
+ "shown_because_block_comment_invalid_from_shorter_line_comment;\n" +
68
+ "/*/\n" +
69
+ "not_shown_because_line_above_started_comment;\n" +
70
+ "//*/\n" +
71
+ "/* \n" +
72
+ "not_shown_because_block_comment_started_this_time;\n" +
73
+ "/*/\n" +
74
+ "shown_because_line_above_ended_comment_this_time;\n" +
75
+ "//*/\n"
76
+
77
+ expected =
78
+ [
79
+ "no_comments",
80
+ "pre_block",
81
+ "shown_because_block_comment_invalid_from_line_comment",
82
+ "shown_because_block_comment_invalid_from_shorter_line_comment",
83
+ "shown_because_line_above_ended_comment_this_time"
84
+ ]
85
+
86
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
87
+ end
88
+
89
+ it "remove strippables from the beginning or end of function declarations" do
90
+ source =
91
+ "void* my_calloc(size_t, size_t) STRIPPABLE;\n" +
92
+ "void\n" +
93
+ " my_realloc(void*, size_t) STRIPPABLE;\n" +
94
+ "extern int\n" +
95
+ " my_printf (void *my_object, const char *my_format, ...)\n" +
96
+ " STRIPPABLE;\n" +
97
+ " void STRIPPABLE universal_handler ();\n"
98
+
99
+ expected =
100
+ [
101
+ "void* my_calloc(size_t, size_t)",
102
+ "void my_realloc(void*, size_t)",
103
+ "void universal_handler()"
104
+ ]
105
+
106
+ assert_equal(expected, @parser.import_source(source))
107
+ end
108
+
109
+ it "remove gcc's function __attribute__'s" do
110
+ source =
111
+ "void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)));\n" +
112
+ "void\n" +
113
+ " my_realloc(void*, size_t) __attribute__((alloc_size(2)));\n" +
114
+ "extern int\n" +
115
+ " my_printf (void *my_object, const char *my_format, ...)\n" +
116
+ " __attribute__ ((format (printf, 2, 3)));\n" +
117
+ " void __attribute__ ((interrupt)) universal_handler ();\n"
118
+
119
+ expected =
120
+ [
121
+ "void* my_calloc(size_t, size_t)",
122
+ "void my_realloc(void*, size_t)",
123
+ "void universal_handler()"
124
+ ]
125
+
126
+ assert_equal(expected, @parser.import_source(source))
127
+ end
128
+
129
+ it "remove preprocessor directives" do
130
+ source =
131
+ "#when stuff_happens\n" +
132
+ "#ifdef _TEST\n" +
133
+ "#pragma stack_switch"
134
+
135
+ expected = []
136
+
137
+ assert_equal(expected, @parser.import_source(source))
138
+ end
139
+
140
+
141
+ it "remove assembler pragma sections" do
142
+ source =
143
+ " #pragma\tasm\n" +
144
+ " .foo\n" +
145
+ " lda %m\n" +
146
+ " nop\n" +
147
+ "# pragma endasm \n" +
148
+ "foo"
149
+
150
+ expected = ["foo"]
151
+
152
+ assert_equal(expected, @parser.import_source(source))
153
+ end
154
+
155
+
156
+ it "smush lines together that contain continuation characters" do
157
+ source =
158
+ "hoo hah \\\n" +
159
+ "when \\ \n"
160
+
161
+ expected =
162
+ [
163
+ "hoo hah when"
164
+ ]
165
+
166
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
167
+ end
168
+
169
+
170
+ it "remove C macro definitions" do
171
+ source =
172
+ "#define this is the first line\\\n" +
173
+ "and the second\\\n" +
174
+ "and the third that should be removed\n" +
175
+ "but I'm here\n"
176
+
177
+ expected = ["but I'm here"]
178
+
179
+ assert_equal(expected, @parser.import_source(source))
180
+ end
181
+
182
+
183
+ it "remove typedef statements" do
184
+ source =
185
+ "typedef uint32 (unsigned int);\n" +
186
+ "const typedef int INT;\n" +
187
+ "int notatypedef;\n" +
188
+ "int typedef_isnt_me;\n" +
189
+ " typedef who cares what really comes here \n" + # exercise multiline typedef
190
+ " continuation;\n" +
191
+ "this should remain!;\n" +
192
+ "typedef blah bleh;\n" +
193
+ "typedef struct shell_command_struct {\n" +
194
+ " char_ptr COMMAND;\n" +
195
+ " int_32 (*SHELL_FUNC)(int_32 argc);\n" +
196
+ "} SHELL_COMMAND_STRUCT, * SHELL_COMMAND_PTR;\n" +
197
+ "typedef struct shell_command_struct {\n" +
198
+ " char_ptr COMMAND;\n" +
199
+ " int_32 (*SHELL_FUNC)(int_32 argc, char_ptr argv[]);\n" +
200
+ "} SHELL_COMMAND_STRUCT, * SHELL_COMMAND_PTR;\n" +
201
+ "typedef struct shell_command_struct {\n" +
202
+ " char_ptr COMMAND;\n" +
203
+ " int_32 (*SHELL_FUNC)(int_32 argc);\n" +
204
+ "};\n"
205
+
206
+ expected =
207
+ [
208
+ "int notatypedef",
209
+ "int typedef_isnt_me",
210
+ "this should remain!"
211
+ ]
212
+
213
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
214
+ end
215
+
216
+
217
+ it "remove enum statements" do
218
+ source =
219
+ "enum _NamedEnum {\n" +
220
+ " THING1 = (0x0001),\n" +
221
+ " THING2 = (0x0001 << 5),\n" +
222
+ "}ListOValues;\n\n" +
223
+ "don't delete me!!\n" +
224
+ " modifier_str enum _NamedEnum {THING1 = (0x0001), THING2 = (0x0001 << 5)} ListOValues;\n\n" +
225
+ "typedef enum {\n" +
226
+ " THING1,\n" +
227
+ " THING2,\n" +
228
+ "} Thinger;\n" +
229
+ "or me!!\n"
230
+
231
+ assert_equal(["don't delete me!! or me!!"], @parser.import_source(source).map!{|s|s.strip})
232
+ end
233
+
234
+
235
+ it "remove union statements" do
236
+ source =
237
+ "union _NamedDoohicky {\n" +
238
+ " unsigned int a;\n" +
239
+ " char b;\n" +
240
+ "} Doohicky;\n\n" +
241
+ "I want to live!!\n" +
242
+ "some_modifier union { unsigned int a; char b;} Whatever;\n" +
243
+ "typedef union {\n" +
244
+ " unsigned int a;\n" +
245
+ " char b;\n" +
246
+ "} Whatever;\n" +
247
+ "me too!!\n"
248
+
249
+ assert_equal(["I want to live!! me too!!"], @parser.import_source(source).map!{|s|s.strip})
250
+ end
251
+
252
+
253
+ it "remove struct statements" do
254
+ source =
255
+ "struct _NamedStruct1 {\n" +
256
+ " unsigned int a;\n" +
257
+ " signed long int b;\n" +
258
+ "} Thing ;\n\n" +
259
+ "extern struct ForwardDeclared_t TestDataType1;\n" +
260
+ "void foo(void);\n" +
261
+ "struct\n"+
262
+ " MultilineForwardDeclared_t\n" +
263
+ " TestDataType2;\n" +
264
+ "struct THINGER foo(void);\n" +
265
+ "typedef struct {\n" +
266
+ " unsigned int a;\n" +
267
+ " signed char b;\n" +
268
+ "}Thinger;\n" +
269
+ "I want to live!!\n"
270
+
271
+ assert_equal(["void foo(void)", "struct THINGER foo(void)", "I want to live!!"],
272
+ @parser.import_source(source).map!{|s|s.strip})
273
+ end
274
+
275
+ it "remove externed and inline functions" do
276
+ source =
277
+ " extern uint32 foobar(unsigned int);\n" +
278
+ "uint32 extern_name_func(unsigned int);\n" +
279
+ "uint32 funcinline(unsigned int);\n" +
280
+ "extern void bar(unsigned int);\n" +
281
+ "inline void bar(unsigned int);\n" +
282
+ "extern\n" +
283
+ "void kinda_ugly_on_the_next_line(unsigned int);\n"
284
+
285
+ expected =
286
+ [
287
+ "uint32 extern_name_func(unsigned int)",
288
+ "uint32 funcinline(unsigned int)"
289
+ ]
290
+
291
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
292
+ end
293
+
294
+ it "remove function definitions but keep function declarations" do
295
+ source =
296
+ "uint32 func_with_decl_a(unsigned int);\n" +
297
+ "uint32 func_with_decl_a(unsigned int a) { return a; }\n" +
298
+ "uint32 func_with_decl_b(unsigned int);\n" +
299
+ "uint32 func_with_decl_b(unsigned int a)\n" +
300
+ "{\n" +
301
+ " bar((unsigned int) a);\n" +
302
+ " stripme(a);\n" +
303
+ "}\n"
304
+
305
+ expected =
306
+ [
307
+ "uint32 func_with_decl_a(unsigned int)",
308
+ "uint32 func_with_decl_a", #okay. it's not going to be interpretted as another function
309
+ "uint32 func_with_decl_b(unsigned int)",
310
+ "uint32 func_with_decl_b", #okay. it's not going to be interpretted as another function
311
+ ]
312
+
313
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
314
+ end
315
+
316
+ it "remove function definitions with nested braces but keep function declarations" do
317
+ source =
318
+ "uint32 func_with_decl_a(unsigned int);\n" +
319
+ "uint32 func_with_decl_a(unsigned int a) {\n" +
320
+ " while (stuff) {\n" +
321
+ " not_a_definition1(void);\n" +
322
+ " }\n" +
323
+ " not_a_definition2(blah, bleh);\n" +
324
+ " return a;\n" +
325
+ "}\n" +
326
+ "uint32 func_with_decl_b(unsigned int);\n" +
327
+ "uint32 func_with_decl_b(unsigned int a)\n" +
328
+ "{\n" +
329
+ " bar((unsigned int) a);\n" +
330
+ " stripme(a);\n" +
331
+ "}\n" +
332
+ "uint32 func_with_decl_c(unsigned int);\n" +
333
+ "uint32 func_with_decl_c(unsigned int a)\n" +
334
+ "{\n" +
335
+ " if(a > 0)\n" +
336
+ " {\n" +
337
+ " return 1;\n" +
338
+ " }\n" +
339
+ " else\n"+
340
+ " {\n" +
341
+ " return 2;\n" +
342
+ " }\n" +
343
+ "}\n"
344
+
345
+ expected =
346
+ [
347
+ "uint32 func_with_decl_a(unsigned int)",
348
+ "uint32 func_with_decl_a", #okay. it's not going to be interpretted as another function
349
+ "uint32 func_with_decl_b(unsigned int)",
350
+ "uint32 func_with_decl_b", #okay. it's not going to be interpretted as another function
351
+ "uint32 func_with_decl_c(unsigned int)",
352
+ "uint32 func_with_decl_c", #okay. it's not going to be interpretted as another function
353
+ ]
354
+
355
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
356
+ end
357
+
358
+ it "remove a fully defined inline function" do
359
+ source =
360
+ "inline void foo(unsigned int a) { oranges = a; }\n" +
361
+ "inline void bar(unsigned int a) { apples = a; };\n" +
362
+ "inline void bar(unsigned int a)\n" +
363
+ "{" +
364
+ " bananas = a;\n" +
365
+ "}"
366
+
367
+ # ensure it's expected type of exception
368
+ assert_raises RuntimeError do
369
+ @parser.parse("module", source)
370
+ end
371
+
372
+ assert_equal([], @parser.funcs)
373
+
374
+ # verify exception message
375
+ begin
376
+ @parser.parse("module", source)
377
+ rescue RuntimeError => e
378
+ assert_equal("ERROR: No function prototypes found!", e.message)
379
+ end
380
+ end
381
+
382
+ it "remove a fully defined inline function that is multiple lines" do
383
+ source =
384
+ "inline void bar(unsigned int a)\n" +
385
+ "{" +
386
+ " bananas = a;\n" +
387
+ " grapes = a;\n" +
388
+ " apples(bananas, grapes);\n" +
389
+ "}"
390
+
391
+ # ensure it's expected type of exception
392
+ assert_raises RuntimeError do
393
+ @parser.parse("module", source)
394
+ end
395
+
396
+ assert_equal([], @parser.funcs)
397
+
398
+ # verify exception message
399
+ begin
400
+ @parser.parse("module", source)
401
+ rescue RuntimeError => e
402
+ assert_equal("ERROR: No function prototypes found!", e.message)
403
+ end
404
+ end
405
+
406
+ it "remove a fully defined inline function that contains nested braces" do
407
+ source =
408
+ "inline void bar(unsigned int a)\n" +
409
+ "{" +
410
+ " apples(bananas, grapes);\n" +
411
+ " if (bananas == a)\n" +
412
+ " {\n" +
413
+ " oranges(a);\n" +
414
+ " grapes = a;\n" +
415
+ " }\n" +
416
+ " grapefruit(bananas, grapes);\n" +
417
+ "}"
418
+
419
+ # ensure it's expected type of exception
420
+ assert_raises RuntimeError do
421
+ @parser.parse("module", source)
422
+ end
423
+
424
+ assert_equal([], @parser.funcs)
425
+
426
+ # verify exception message
427
+ begin
428
+ @parser.parse("module", source)
429
+ rescue RuntimeError => e
430
+ assert_equal("ERROR: No function prototypes found!", e.message)
431
+ end
432
+ end
433
+
434
+ it "remove just inline functions if externs to be included" do
435
+ source =
436
+ " extern uint32 foobar(unsigned int);\n" +
437
+ "uint32 extern_name_func(unsigned int);\n" +
438
+ "uint32 funcinline(unsigned int);\n" +
439
+ "extern void bar(unsigned int);\n" +
440
+ "inline void bar(unsigned int);\n" +
441
+ "extern\n" +
442
+ "void kinda_ugly_on_the_next_line(unsigned int);\n"
443
+
444
+ expected =
445
+ [ "extern uint32 foobar(unsigned int)",
446
+ "uint32 extern_name_func(unsigned int)",
447
+ "uint32 funcinline(unsigned int)",
448
+ "extern void bar(unsigned int)",
449
+ "extern void kinda_ugly_on_the_next_line(unsigned int)"
450
+ ]
451
+
452
+ @parser.treat_externs = :include
453
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
454
+ end
455
+
456
+
457
+ it "remove defines" do
458
+ source =
459
+ "#define whatever you feel like defining\n" +
460
+ "void hello(void);\n" +
461
+ "#DEFINE I JUST DON'T CARE\n" +
462
+ "#deFINE\n" +
463
+ "#define get_foo() \\\n ((Thing)foo.bar)" # exercise multiline define
464
+
465
+ expected =
466
+ [
467
+ "void hello(void)",
468
+ ]
469
+
470
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
471
+ end
472
+
473
+
474
+ it "remove keywords that would keep things from going smoothly in the future" do
475
+ source =
476
+ "const int TheMatrix(register int Trinity, unsigned int *restrict Neo)"
477
+
478
+ expected =
479
+ [
480
+ "const int TheMatrix(int Trinity, unsigned int * Neo)",
481
+ ]
482
+
483
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
484
+ end
485
+
486
+
487
+ # some code actually typedef's void even though it's not ANSI C and is, frankly, weird
488
+ # since cmock treats void specially, we can't let void be obfuscated
489
+ it "handle odd case of typedef'd void returned" do
490
+ source = "MY_FUNKY_VOID FunkyVoidReturned(int a)"
491
+ expected = { :var_arg=>nil,
492
+ :name=>"FunkyVoidReturned",
493
+ :return=>{ :type => "void",
494
+ :name => 'cmock_to_return',
495
+ :ptr? => false,
496
+ :const? => false,
497
+ :const_ptr? => false,
498
+ :str => "void cmock_to_return",
499
+ :void? => true
500
+ },
501
+ :modifier=>"",
502
+ :contains_ptr? => false,
503
+ :args=>[{:type=>"int", :name=>"a", :ptr? => false, :const? => false, :const_ptr? => false}],
504
+ :args_string=>"int a",
505
+ :args_call=>"a"}
506
+ assert_equal(expected, @parser.parse_declaration(source))
507
+ end
508
+
509
+ it "handle odd case of typedef'd void as arg" do
510
+ source = "int FunkyVoidAsArg(MY_FUNKY_VOID)"
511
+ expected = { :var_arg=>nil,
512
+ :name=>"FunkyVoidAsArg",
513
+ :return=>{ :type => "int",
514
+ :name => 'cmock_to_return',
515
+ :ptr? => false,
516
+ :const? => false,
517
+ :const_ptr? => false,
518
+ :str => "int cmock_to_return",
519
+ :void? => false
520
+ },
521
+ :modifier=>"",
522
+ :contains_ptr? => false,
523
+ :args=>[],
524
+ :args_string=>"void",
525
+ :args_call=>"" }
526
+ assert_equal(expected, @parser.parse_declaration(source))
527
+ end
528
+
529
+ it "handle odd case of typedef'd void as arg pointer" do
530
+ source = "char FunkyVoidPointer(MY_FUNKY_VOID* bluh)"
531
+ expected = { :var_arg=>nil,
532
+ :name=>"FunkyVoidPointer",
533
+ :return=>{ :type => "char",
534
+ :name => 'cmock_to_return',
535
+ :ptr? => false,
536
+ :const? => false,
537
+ :const_ptr? => false,
538
+ :str => "char cmock_to_return",
539
+ :void? => false
540
+ },
541
+ :modifier=>"",
542
+ :contains_ptr? => true,
543
+ :args=>[{:type=>"MY_FUNKY_VOID*", :name=>"bluh", :ptr? => true, :const? => false, :const_ptr? => false}],
544
+ :args_string=>"MY_FUNKY_VOID* bluh",
545
+ :args_call=>"bluh" }
546
+ assert_equal(expected, @parser.parse_declaration(source))
547
+ end
548
+
549
+
550
+ it "strip default values from function parameter lists" do
551
+ source =
552
+ "void Foo(int a = 57, float b=37.52, char c= 'd', char* e=\"junk\");\n"
553
+
554
+ expected =
555
+ [
556
+ "void Foo(int a, float b, char c, char* e)"
557
+ ]
558
+
559
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
560
+ end
561
+
562
+
563
+ it "raise upon empty file" do
564
+ source = ''
565
+
566
+ # ensure it's expected type of exception
567
+ assert_raises RuntimeError do
568
+ @parser.parse("module", source)
569
+ end
570
+
571
+ assert_equal([], @parser.funcs)
572
+
573
+ # verify exception message
574
+ begin
575
+ @parser.parse("module", source)
576
+ rescue RuntimeError => e
577
+ assert_equal("ERROR: No function prototypes found!", e.message)
578
+ end
579
+ end
580
+
581
+ it "clean up module names that contain spaces, dashes, and such" do
582
+ source = 'void meh(int (*func)(int));'
583
+
584
+ retval = @parser.parse("C:\Ugly Module-Name", source)
585
+ assert (retval[:typedefs][0] =~ /CUglyModuleName/)
586
+ end
587
+
588
+ it "raise upon no function prototypes found in file" do
589
+ source =
590
+ "typedef void SILLY_VOID_TYPE1;\n" +
591
+ "typedef (void) SILLY_VOID_TYPE2 ;\n" +
592
+ "typedef ( void ) (*FUNCPTR)(void);\n\n" +
593
+ "#define get_foo() \\\n ((Thing)foo.bar)"
594
+
595
+ # ensure it's expected type of exception
596
+ assert_raises(RuntimeError) do
597
+ @parser.parse("module", source)
598
+ end
599
+
600
+ assert_equal([], @parser.funcs)
601
+
602
+ # verify exception message
603
+ begin
604
+ @parser.parse("module", source)
605
+ rescue RuntimeError => e
606
+ assert_equal("ERROR: No function prototypes found!", e.message)
607
+ end
608
+ end
609
+
610
+
611
+ it "raise upon prototype parsing failure" do
612
+ source = "void (int, )"
613
+
614
+ # ensure it's expected type of exception
615
+ assert_raises(RuntimeError) do
616
+ @parser.parse("module", source)
617
+ end
618
+
619
+ # verify exception message
620
+ begin
621
+ @parser.parse("module", source)
622
+ rescue RuntimeError => e
623
+ assert(e.message.include?("Failed Parsing Declaration Prototype!"))
624
+ end
625
+ end
626
+
627
+ it "extract and return function declarations with retval and args" do
628
+
629
+ source = "int Foo(int a, unsigned int b)"
630
+ expected = { :var_arg=>nil,
631
+ :name=>"Foo",
632
+ :return=>{ :type => "int",
633
+ :name => 'cmock_to_return',
634
+ :ptr? => false,
635
+ :const? => false,
636
+ :const_ptr? => false,
637
+ :str => "int cmock_to_return",
638
+ :void? => false
639
+ },
640
+ :modifier=>"",
641
+ :contains_ptr? => false,
642
+ :args=>[ {:type=>"int", :name=>"a", :ptr? => false, :const? => false, :const_ptr? => false},
643
+ {:type=>"unsigned int", :name=>"b", :ptr? => false, :const? => false, :const_ptr? => false}
644
+ ],
645
+ :args_string=>"int a, unsigned int b",
646
+ :args_call=>"a, b" }
647
+ assert_equal(expected, @parser.parse_declaration(source))
648
+ end
649
+
650
+ it "extract and return function declarations with no retval" do
651
+
652
+ source = "void FunkyChicken( uint la, int de, bool da)"
653
+ expected = { :var_arg=>nil,
654
+ :return=>{ :type => "void",
655
+ :name => 'cmock_to_return',
656
+ :ptr? => false,
657
+ :const? => false,
658
+ :const_ptr? => false,
659
+ :str => "void cmock_to_return",
660
+ :void? => true
661
+ },
662
+ :name=>"FunkyChicken",
663
+ :modifier=>"",
664
+ :contains_ptr? => false,
665
+ :args=>[ {:type=>"uint", :name=>"la", :ptr? => false, :const? => false, :const_ptr? => false},
666
+ {:type=>"int", :name=>"de", :ptr? => false, :const? => false, :const_ptr? => false},
667
+ {:type=>"bool", :name=>"da", :ptr? => false, :const? => false, :const_ptr? => false}
668
+ ],
669
+ :args_string=>"uint la, int de, bool da",
670
+ :args_call=>"la, de, da" }
671
+ assert_equal(expected, @parser.parse_declaration(source))
672
+ end
673
+
674
+ it "extract and return function declarations with implied voids" do
675
+
676
+ source = "void tat()"
677
+ expected = { :var_arg=>nil,
678
+ :return=>{ :type => "void",
679
+ :name => 'cmock_to_return',
680
+ :ptr? => false,
681
+ :const? => false,
682
+ :const_ptr? => false,
683
+ :str => "void cmock_to_return",
684
+ :void? => true
685
+ },
686
+ :name=>"tat",
687
+ :modifier=>"",
688
+ :contains_ptr? => false,
689
+ :args=>[ ],
690
+ :args_string=>"void",
691
+ :args_call=>"" }
692
+ assert_equal(expected, @parser.parse_declaration(source))
693
+ end
694
+
695
+ it "extract modifiers properly" do
696
+
697
+ source = "const int TheMatrix(int Trinity, unsigned int * Neo)"
698
+ expected = { :var_arg=>nil,
699
+ :return=>{ :type => "int",
700
+ :name => 'cmock_to_return',
701
+ :ptr? => false,
702
+ :const? => true,
703
+ :const_ptr? => false,
704
+ :str => "int cmock_to_return",
705
+ :void? => false
706
+ },
707
+ :name=>"TheMatrix",
708
+ :modifier=>"const",
709
+ :contains_ptr? => true,
710
+ :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
711
+ {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
712
+ ],
713
+ :args_string=>"int Trinity, unsigned int* Neo",
714
+ :args_call=>"Trinity, Neo" }
715
+ assert_equal(expected, @parser.parse_declaration(source))
716
+ end
717
+
718
+ it "extract c calling conventions properly" do
719
+
720
+ source = "const int __stdcall TheMatrix(int Trinity, unsigned int * Neo)"
721
+ expected = { :var_arg=>nil,
722
+ :return=>{ :type => "int",
723
+ :name => 'cmock_to_return',
724
+ :ptr? => false,
725
+ :const? => true,
726
+ :const_ptr? => false,
727
+ :str => "int cmock_to_return",
728
+ :void? => false
729
+ },
730
+ :name=>"TheMatrix",
731
+ :modifier=>"const",
732
+ :c_calling_convention=>"__stdcall",
733
+ :contains_ptr? => true,
734
+ :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
735
+ {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
736
+ ],
737
+ :args_string=>"int Trinity, unsigned int* Neo",
738
+ :args_call=>"Trinity, Neo" }
739
+ assert_equal(expected, @parser.parse_declaration(source))
740
+ end
741
+
742
+ it "fully parse multiple prototypes" do
743
+
744
+ source = "const int TheMatrix(int Trinity, unsigned int * Neo);\n" +
745
+ "int Morpheus(int, unsigned int*);\n"
746
+
747
+ expected = [{ :var_arg=>nil,
748
+ :return=> { :type => "int",
749
+ :name => 'cmock_to_return',
750
+ :ptr? => false,
751
+ :const? => true,
752
+ :const_ptr? => false,
753
+ :str => "int cmock_to_return",
754
+ :void? => false
755
+ },
756
+ :name=>"TheMatrix",
757
+ :modifier=>"const",
758
+ :contains_ptr? => true,
759
+ :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
760
+ {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
761
+ ],
762
+ :args_string=>"int Trinity, unsigned int* Neo",
763
+ :args_call=>"Trinity, Neo" },
764
+ { :var_arg=>nil,
765
+ :return=> { :type => "int",
766
+ :name => 'cmock_to_return',
767
+ :ptr? => false,
768
+ :const? => false,
769
+ :const_ptr? => false,
770
+ :str => "int cmock_to_return",
771
+ :void? => false
772
+ },
773
+ :name=>"Morpheus",
774
+ :modifier=>"",
775
+ :contains_ptr? => true,
776
+ :args=>[ {:type=>"int", :name=>"cmock_arg1", :ptr? => false, :const? => false, :const_ptr? => false},
777
+ {:type=>"unsigned int*", :name=>"cmock_arg2", :ptr? => true, :const? => false, :const_ptr? => false}
778
+ ],
779
+ :args_string=>"int cmock_arg1, unsigned int* cmock_arg2",
780
+ :args_call=>"cmock_arg1, cmock_arg2"
781
+ }]
782
+ assert_equal(expected, @parser.parse("module", source)[:functions])
783
+ end
784
+
785
+ it "not extract for mocking multiply defined prototypes" do
786
+
787
+ source = "const int TheMatrix(int Trinity, unsigned int * Neo);\n" +
788
+ "const int TheMatrix(int, unsigned int*);\n"
789
+
790
+ expected = [{ :var_arg=>nil,
791
+ :name=>"TheMatrix",
792
+ :return=> { :type => "int",
793
+ :name => 'cmock_to_return',
794
+ :ptr? => false,
795
+ :const? => true,
796
+ :const_ptr? => false,
797
+ :str => "int cmock_to_return",
798
+ :void? => false
799
+ },
800
+ :modifier=>"const",
801
+ :contains_ptr? => true,
802
+ :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false, :const_ptr? => false},
803
+ {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false, :const_ptr? => false}
804
+ ],
805
+ :args_string=>"int Trinity, unsigned int* Neo",
806
+ :args_call=>"Trinity, Neo"
807
+ }]
808
+ assert_equal(expected, @parser.parse("module", source)[:functions])
809
+ end
810
+
811
+ it "should properly handle const before return type" do
812
+ sources = [
813
+ "const int * PorkRoast(void);\n",
814
+ "const int* PorkRoast(void);\n",
815
+ "const int *PorkRoast(void);\n"
816
+ ]
817
+
818
+ expected = [{ :var_arg => nil,
819
+ :name => "PorkRoast",
820
+ :return => { :type => "const int*",
821
+ :name => 'cmock_to_return',
822
+ :ptr? => true,
823
+ :const? => true,
824
+ :const_ptr? => false,
825
+ :str => "const int* cmock_to_return",
826
+ :void? => false
827
+ },
828
+ :modifier => "",
829
+ :contains_ptr? => false,
830
+ :args => [],
831
+ :args_string => "void",
832
+ :args_call => ""
833
+ }]
834
+
835
+ sources.each do |source|
836
+ assert_equal(expected, @parser.parse("module", source)[:functions])
837
+ end
838
+ end
839
+
840
+ it "should properly handle const before return type" do
841
+ sources = [
842
+ "int const * PorkRoast(void);\n",
843
+ "int const* PorkRoast(void);\n",
844
+ "int const *PorkRoast(void);\n"
845
+ ]
846
+
847
+ expected = [{ :var_arg => nil,
848
+ :name => "PorkRoast",
849
+ :return => { :type => "int const*",
850
+ :name => 'cmock_to_return',
851
+ :ptr? => true,
852
+ :const? => true,
853
+ :const_ptr? => false,
854
+ :str => "int const* cmock_to_return",
855
+ :void? => false
856
+ },
857
+ :modifier => "",
858
+ :contains_ptr? => false,
859
+ :args => [],
860
+ :args_string => "void",
861
+ :args_call => ""
862
+ }]
863
+
864
+ sources.each do |source|
865
+ assert_equal(expected, @parser.parse("module", source)[:functions])
866
+ end
867
+ end
868
+
869
+ it "should properly handle const applied after asterisk in return type (not legal C, but sometimes used)" do
870
+
871
+ source = "int * const PorkRoast(void);\n"
872
+
873
+ expected = [{ :var_arg=>nil,
874
+ :name=>"PorkRoast",
875
+ :return=> { :type => "int*",
876
+ :name => 'cmock_to_return',
877
+ :ptr? => true,
878
+ :const? => false,
879
+ :const_ptr? => true,
880
+ :str => "int* cmock_to_return",
881
+ :void? => false
882
+ },
883
+ :modifier=>"const",
884
+ :contains_ptr? => false,
885
+ :args=>[],
886
+ :args_string=>"void",
887
+ :args_call=>""
888
+ }]
889
+ assert_equal(expected, @parser.parse("module", source)[:functions])
890
+ end
891
+
892
+ it "properly parse const and pointer argument types with no arg names" do
893
+
894
+ source = "void foo(int const*, int*const, const int*, const int*const, int const*const, int*, int, const int);\n"
895
+
896
+ expected = [{ :name => "foo",
897
+ :modifier => "",
898
+ :return => { :type => "void",
899
+ :name => "cmock_to_return",
900
+ :str => "void cmock_to_return",
901
+ :void? => true,
902
+ :ptr? => false,
903
+ :const? => false,
904
+ :const_ptr? => false
905
+ },
906
+ :var_arg => nil,
907
+ :args_string => "int const* cmock_arg1, int* const cmock_arg2, const int* cmock_arg3, const int* const cmock_arg4, " +
908
+ "int const* const cmock_arg5, int* cmock_arg6, int cmock_arg7, const int cmock_arg8",
909
+ :args => [{ :type=>"int const*", :name => "cmock_arg1", :ptr? => true, :const? => true, :const_ptr? => false },
910
+ { :type=>"int*", :name => "cmock_arg2", :ptr? => true, :const? => false, :const_ptr? => true },
911
+ { :type=>"const int*", :name => "cmock_arg3", :ptr? => true, :const? => true, :const_ptr? => false },
912
+ { :type=>"const int*", :name => "cmock_arg4", :ptr? => true, :const? => true, :const_ptr? => true },
913
+ { :type=>"int const*", :name => "cmock_arg5", :ptr? => true, :const? => true, :const_ptr? => true },
914
+ { :type=>"int*", :name => "cmock_arg6", :ptr? => true, :const? => false, :const_ptr? => false },
915
+ { :type=>"int", :name => "cmock_arg7", :ptr? => false, :const? => false, :const_ptr? => false },
916
+ { :type=>"int", :name => "cmock_arg8", :ptr? => false, :const? => true, :const_ptr? => false }],
917
+ :args_call => "cmock_arg1, cmock_arg2, cmock_arg3, cmock_arg4, cmock_arg5, cmock_arg6, cmock_arg7, cmock_arg8",
918
+ :contains_ptr? => true
919
+ }]
920
+ assert_equal(expected, @parser.parse("module", source)[:functions])
921
+ end
922
+
923
+ it "properly parse const and pointer argument types with arg names" do
924
+
925
+ source = "void bar(int const* param1, int*const param2, const int* param3, const int*const param4,\n" +
926
+ " int const*const param5, int*param6, int param7, const int param8);\n"
927
+
928
+ expected = [{ :name => "bar",
929
+ :modifier => "",
930
+ :return => { :type => "void",
931
+ :name => "cmock_to_return",
932
+ :str => "void cmock_to_return",
933
+ :void? => true,
934
+ :ptr? => false,
935
+ :const? => false,
936
+ :const_ptr? => false
937
+ },
938
+ :var_arg => nil,
939
+ :args_string => "int const* param1, int* const param2, const int* param3, const int* const param4, " +
940
+ "int const* const param5, int* param6, int param7, const int param8",
941
+ :args => [{ :type=>"int const*", :name => "param1", :ptr? => true, :const? => true, :const_ptr? => false },
942
+ { :type=>"int*", :name => "param2", :ptr? => true, :const? => false, :const_ptr? => true },
943
+ { :type=>"const int*", :name => "param3", :ptr? => true, :const? => true, :const_ptr? => false },
944
+ { :type=>"const int*", :name => "param4", :ptr? => true, :const? => true, :const_ptr? => true },
945
+ { :type=>"int const*", :name => "param5", :ptr? => true, :const? => true, :const_ptr? => true },
946
+ { :type=>"int*", :name => "param6", :ptr? => true, :const? => false, :const_ptr? => false },
947
+ { :type=>"int", :name => "param7", :ptr? => false, :const? => false, :const_ptr? => false },
948
+ { :type=>"int", :name => "param8", :ptr? => false, :const? => true, :const_ptr? => false }],
949
+ :args_call => "param1, param2, param3, param4, param5, param6, param7, param8",
950
+ :contains_ptr? => true
951
+ }]
952
+ assert_equal(expected, @parser.parse("module", source)[:functions])
953
+ end
954
+
955
+ it "converts typedef'd array arguments to pointers" do
956
+
957
+ source = "Book AddToBook(Book book, const IntArray values);\n"
958
+
959
+ expected = [{ :name => "AddToBook",
960
+ :modifier=>"",
961
+ :return => { :type => "Book",
962
+ :name => "cmock_to_return",
963
+ :str => "Book cmock_to_return",
964
+ :void? => false,
965
+ :ptr? => false,
966
+ :const? => false,
967
+ :const_ptr? => false
968
+ },
969
+ :var_arg => nil,
970
+ :args => [{ :type => "Page*", :name => "book", :ptr? => true, :const? => false, :const_ptr? => false },
971
+ { :type => "const int*", :name => "values", :ptr? => true, :const? => true, :const_ptr? => false }],
972
+ :args_string => "Book book, const IntArray values",
973
+ :args_call => "book, values",
974
+ :contains_ptr? => true
975
+ }]
976
+
977
+ assert_equal(expected, @parser.parse("module", source)[:functions])
978
+
979
+ end
980
+
981
+ it "properly detect typedef'd variants of void and use those" do
982
+
983
+ source = "typedef (void) FUNKY_VOID_T;\n" +
984
+ "typedef void CHUNKY_VOID_T;\n" +
985
+ "FUNKY_VOID_T DrHorrible(int SingAlong);\n" +
986
+ "int CaptainHammer(CHUNKY_VOID_T);\n"
987
+
988
+ expected = [{ :var_arg=>nil,
989
+ :name=>"DrHorrible",
990
+ :return => { :type => "void",
991
+ :name => 'cmock_to_return',
992
+ :ptr? => false,
993
+ :const? => false,
994
+ :const_ptr? => false,
995
+ :str => "void cmock_to_return",
996
+ :void? => true
997
+ },
998
+ :modifier=>"",
999
+ :contains_ptr? => false,
1000
+ :args=>[ {:type=>"int", :name=>"SingAlong", :ptr? => false, :const? => false, :const_ptr? => false} ],
1001
+ :args_string=>"int SingAlong",
1002
+ :args_call=>"SingAlong"
1003
+ },
1004
+ { :var_arg=>nil,
1005
+ :return=> { :type => "int",
1006
+ :name => 'cmock_to_return',
1007
+ :ptr? => false,
1008
+ :const? => false,
1009
+ :const_ptr? => false,
1010
+ :str => "int cmock_to_return",
1011
+ :void? => false
1012
+ },
1013
+ :name=>"CaptainHammer",
1014
+ :modifier=>"",
1015
+ :contains_ptr? => false,
1016
+ :args=>[ ],
1017
+ :args_string=>"void",
1018
+ :args_call=>""
1019
+ }]
1020
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1021
+ end
1022
+
1023
+ it "be ok with structs inside of function declarations" do
1024
+
1025
+ source = "int DrHorrible(struct SingAlong Blog);\n" +
1026
+ "void Penny(struct const _KeepYourHeadUp_ * const BillyBuddy);\n" +
1027
+ "struct TheseArentTheHammer CaptainHammer(void);\n"
1028
+
1029
+ expected = [{ :var_arg=>nil,
1030
+ :return =>{ :type => "int",
1031
+ :name => 'cmock_to_return',
1032
+ :ptr? => false,
1033
+ :const? => false,
1034
+ :const_ptr? => false,
1035
+ :str => "int cmock_to_return",
1036
+ :void? => false
1037
+ },
1038
+ :name=>"DrHorrible",
1039
+ :modifier=>"",
1040
+ :contains_ptr? => false,
1041
+ :args=>[ {:type=>"struct SingAlong", :name=>"Blog", :ptr? => false, :const? => false, :const_ptr? => false} ],
1042
+ :args_string=>"struct SingAlong Blog",
1043
+ :args_call=>"Blog"
1044
+ },
1045
+ { :var_arg=>nil,
1046
+ :return=> { :type => "void",
1047
+ :name => 'cmock_to_return',
1048
+ :ptr? => false,
1049
+ :const? => false,
1050
+ :const_ptr? => false,
1051
+ :str => "void cmock_to_return",
1052
+ :void? => true
1053
+ },
1054
+ :name=>"Penny",
1055
+ :modifier=>"",
1056
+ :contains_ptr? => true,
1057
+ :args=>[ {:type=>"struct const _KeepYourHeadUp_*", :name=>"BillyBuddy", :ptr? => true, :const? => true, :const_ptr? => true} ],
1058
+ :args_string=>"struct const _KeepYourHeadUp_* const BillyBuddy",
1059
+ :args_call=>"BillyBuddy"
1060
+ },
1061
+ { :var_arg=>nil,
1062
+ :return=> { :type => "struct TheseArentTheHammer",
1063
+ :name => 'cmock_to_return',
1064
+ :ptr? => false,
1065
+ :const? => false,
1066
+ :const_ptr? => false,
1067
+ :str => "struct TheseArentTheHammer cmock_to_return",
1068
+ :void? => false
1069
+ },
1070
+ :name=>"CaptainHammer",
1071
+ :modifier=>"",
1072
+ :contains_ptr? => false,
1073
+ :args=>[ ],
1074
+ :args_string=>"void",
1075
+ :args_call=>""
1076
+ }]
1077
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1078
+ end
1079
+
1080
+ it "extract functions containing unions with union specifier" do
1081
+ source = "void OrangePeel(union STARS_AND_STRIPES * a, union AFL_CIO b)"
1082
+ expected = [{ :var_arg=>nil,
1083
+ :return=>{ :type => "void",
1084
+ :name => 'cmock_to_return',
1085
+ :ptr? => false,
1086
+ :const? => false,
1087
+ :const_ptr? => false,
1088
+ :str => "void cmock_to_return",
1089
+ :void? => true
1090
+ },
1091
+ :name=>"OrangePeel",
1092
+ :modifier=>"",
1093
+ :contains_ptr? => true,
1094
+ :args=>[ {:type=>"union STARS_AND_STRIPES*", :name=>"a", :ptr? => true, :const? => false, :const_ptr? => false},
1095
+ {:type=>"union AFL_CIO", :name=>"b", :ptr? => false, :const? => false, :const_ptr? => false}
1096
+ ],
1097
+ :args_string=>"union STARS_AND_STRIPES* a, union AFL_CIO b",
1098
+ :args_call=>"a, b" }]
1099
+ result = @parser.parse("module", source)
1100
+ assert_equal(expected, result[:functions])
1101
+ end
1102
+
1103
+ it "not be thwarted by variables named with primitive types as part of the name" do
1104
+ source = "void ApplePeel(const unsigned int const_param, int int_param, int integer, char character, int* const constant)"
1105
+ expected = [{ :var_arg=>nil,
1106
+ :return=>{ :type => "void",
1107
+ :name => 'cmock_to_return',
1108
+ :ptr? => false,
1109
+ :const? => false,
1110
+ :const_ptr? => false,
1111
+ :str => "void cmock_to_return",
1112
+ :void? => true
1113
+ },
1114
+ :name=>"ApplePeel",
1115
+ :modifier=>"",
1116
+ :contains_ptr? => true,
1117
+ :args=>[ {:type=> "unsigned int", :name=>"const_param", :ptr? => false, :const? => true, :const_ptr? => false},
1118
+ {:type=>"int", :name=>"int_param", :ptr? => false, :const? => false, :const_ptr? => false},
1119
+ {:type=>"int", :name=>"integer", :ptr? => false, :const? => false, :const_ptr? => false},
1120
+ {:type=>"char", :name=>"character", :ptr? => false, :const? => false, :const_ptr? => false},
1121
+ {:type=>"int*", :name=>"constant", :ptr? => true, :const? => false, :const_ptr? => true}
1122
+ ],
1123
+ :args_string=>"const unsigned int const_param, int int_param, int integer, char character, int* const constant",
1124
+ :args_call=>"const_param, int_param, integer, character, constant" }]
1125
+ result = @parser.parse("module", source)
1126
+ assert_equal(expected, result[:functions])
1127
+ end
1128
+
1129
+ it "not be thwarted by custom types named similarly to primitive types" do
1130
+ source = "void LemonPeel(integer param, character thing, longint * junk, constant value, int32_t const number)"
1131
+ expected = [{:var_arg=>nil,
1132
+ :return=>{ :type => "void",
1133
+ :name => 'cmock_to_return',
1134
+ :ptr? => false,
1135
+ :const? => false,
1136
+ :const_ptr? => false,
1137
+ :str => "void cmock_to_return",
1138
+ :void? => true
1139
+ },
1140
+ :name=>"LemonPeel",
1141
+ :modifier=>"",
1142
+ :contains_ptr? => true,
1143
+ :args=>[ {:type=>"integer", :name=>"param", :ptr? => false, :const? => false, :const_ptr? => false},
1144
+ {:type=>"character", :name=>"thing", :ptr? => false, :const? => false, :const_ptr? => false},
1145
+ {:type=>"longint*", :name=>"junk", :ptr? => true, :const? => false, :const_ptr? => false},
1146
+ {:type=>"constant", :name=>"value", :ptr? => false, :const? => false, :const_ptr? => false},
1147
+ {:type=>"int32_t", :name=>"number", :ptr? => false, :const? => true, :const_ptr? => false}
1148
+ ],
1149
+ :args_string=>"integer param, character thing, longint* junk, constant value, int32_t const number",
1150
+ :args_call=>"param, thing, junk, value, number" }]
1151
+ result = @parser.parse("module", source)
1152
+ assert_equal(expected, result[:functions])
1153
+ end
1154
+
1155
+ it "handle some of those chains of C name specifiers naturally" do
1156
+ source = "void CoinOperated(signed char abc, const unsigned long int xyz_123, unsigned int const abc_123, long long arm_of_the_law)"
1157
+ expected = [{:var_arg=>nil,
1158
+ :return=>{ :type => "void",
1159
+ :name => 'cmock_to_return',
1160
+ :ptr? => false,
1161
+ :const? => false,
1162
+ :const_ptr? => false,
1163
+ :str => "void cmock_to_return",
1164
+ :void? => true
1165
+ },
1166
+ :name=>"CoinOperated",
1167
+ :modifier=>"",
1168
+ :contains_ptr? => false,
1169
+ :args=>[ {:type=>"signed char", :name=>"abc", :ptr? => false, :const? => false, :const_ptr? => false},
1170
+ {:type=>"unsigned long int", :name=>"xyz_123", :ptr? => false, :const? => true, :const_ptr? => false},
1171
+ {:type=>"unsigned int", :name=>"abc_123", :ptr? => false, :const? => true, :const_ptr? => false},
1172
+ {:type=>"long long", :name=>"arm_of_the_law", :ptr? => false, :const? => false, :const_ptr? => false}
1173
+ ],
1174
+ :args_string=>"signed char abc, const unsigned long int xyz_123, unsigned int const abc_123, long long arm_of_the_law",
1175
+ :args_call=>"abc, xyz_123, abc_123, arm_of_the_law" }]
1176
+ result = @parser.parse("module", source)
1177
+ assert_equal(expected, result[:functions])
1178
+ end
1179
+
1180
+ it "handle custom types of various formats" do
1181
+ source = "void CardOperated(CUSTOM_TYPE abc, CUSTOM_TYPE* xyz_123, CUSTOM_TYPE const abcxyz, struct CUSTOM_TYPE const * const abc123)"
1182
+ expected = [{:var_arg=>nil,
1183
+ :return=>{ :type => "void",
1184
+ :name => 'cmock_to_return',
1185
+ :ptr? => false,
1186
+ :const? => false,
1187
+ :const_ptr? => false,
1188
+ :str => "void cmock_to_return",
1189
+ :void? => true
1190
+ },
1191
+ :name=>"CardOperated",
1192
+ :modifier=>"",
1193
+ :contains_ptr? => true,
1194
+ :args=>[ {:type=>"CUSTOM_TYPE", :name=>"abc", :ptr? => false, :const? => false, :const_ptr? => false},
1195
+ {:type=>"CUSTOM_TYPE*", :name=>"xyz_123", :ptr? => true, :const? => false, :const_ptr? => false},
1196
+ {:type=>"CUSTOM_TYPE", :name=>"abcxyz", :ptr? => false, :const? => true, :const_ptr? => false},
1197
+ {:type=>"struct CUSTOM_TYPE const*", :name=>"abc123", :ptr? => true, :const? => true, :const_ptr? => true}
1198
+ ],
1199
+ :args_string=>"CUSTOM_TYPE abc, CUSTOM_TYPE* xyz_123, CUSTOM_TYPE const abcxyz, struct CUSTOM_TYPE const* const abc123",
1200
+ :args_call=>"abc, xyz_123, abcxyz, abc123" }]
1201
+ result = @parser.parse("module", source)
1202
+ assert_equal(expected, result[:functions])
1203
+ end
1204
+
1205
+ it "handle arrays and treat them as pointers or strings" do
1206
+ source = "void KeyOperated(CUSTOM_TYPE thing1[], int thing2 [ ], char thing3 [][2 ][ 3], int* thing4[4])"
1207
+ expected = [{:var_arg=>nil,
1208
+ :return=>{ :type => "void",
1209
+ :name => 'cmock_to_return',
1210
+ :ptr? => false,
1211
+ :const? => false,
1212
+ :const_ptr? => false,
1213
+ :str => "void cmock_to_return",
1214
+ :void? => true
1215
+ },
1216
+ :name=>"KeyOperated",
1217
+ :modifier=>"",
1218
+ :contains_ptr? => true,
1219
+ :args=>[ {:type=>"CUSTOM_TYPE*", :name=>"thing1", :ptr? => true, :const? => false, :const_ptr? => false},
1220
+ {:type=>"int*", :name=>"thing2", :ptr? => true, :const? => false, :const_ptr? => false},
1221
+ {: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
1222
+ {: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
1223
+ ],
1224
+ :args_string=>"CUSTOM_TYPE* thing1, int* thing2, char* thing3, int** thing4",
1225
+ :args_call=>"thing1, thing2, thing3, thing4" }]
1226
+ result = @parser.parse("module", source)
1227
+ assert_equal(expected, result[:functions])
1228
+ end
1229
+
1230
+ it "give a reasonable guess when dealing with weird combinations of custom types and modifiers" do
1231
+ source = "void Cheese(unsigned CUSTOM_TYPE abc, unsigned xyz, CUSTOM_TYPE1 CUSTOM_TYPE2 pdq)"
1232
+ expected = [{:var_arg=>nil,
1233
+ :return=>{ :type => "void",
1234
+ :name => 'cmock_to_return',
1235
+ :ptr? => false,
1236
+ :const? => false,
1237
+ :const_ptr? => false,
1238
+ :str => "void cmock_to_return",
1239
+ :void? => true
1240
+ },
1241
+ :name=>"Cheese",
1242
+ :modifier=>"",
1243
+ :contains_ptr? => false,
1244
+ :args=>[ {:type=>"unsigned CUSTOM_TYPE", :name=>"abc", :ptr? => false, :const? => false, :const_ptr? => false},
1245
+ {:type=>"unsigned", :name=>"xyz", :ptr? => false, :const? => false, :const_ptr? => false},
1246
+ {:type=>"CUSTOM_TYPE1 CUSTOM_TYPE2", :name=>"pdq", :ptr? => false, :const? => false, :const_ptr? => false}
1247
+ ],
1248
+ :args_string=>"unsigned CUSTOM_TYPE abc, unsigned xyz, CUSTOM_TYPE1 CUSTOM_TYPE2 pdq",
1249
+ :args_call=>"abc, xyz, pdq" }]
1250
+ result = @parser.parse("module", source)
1251
+ assert_equal(expected, result[:functions])
1252
+ end
1253
+
1254
+ it "extract functions containing a function pointer" do
1255
+ source = "void FunkyTurkey(unsigned int (*func_ptr)(int, char))"
1256
+ expected = [{ :var_arg=>nil,
1257
+ :return=>{ :type => "void",
1258
+ :name => 'cmock_to_return',
1259
+ :ptr? => false,
1260
+ :const? => false,
1261
+ :const_ptr? => false,
1262
+ :str => "void cmock_to_return",
1263
+ :void? => true
1264
+ },
1265
+ :name=>"FunkyTurkey",
1266
+ :modifier=>"",
1267
+ :contains_ptr? => false,
1268
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1269
+ ],
1270
+ :args_string=>"cmock_module_func_ptr1 func_ptr",
1271
+ :args_call=>"func_ptr" }]
1272
+ typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char);"]
1273
+ result = @parser.parse("module", source)
1274
+ assert_equal(expected, result[:functions])
1275
+ assert_equal(typedefs, result[:typedefs])
1276
+ end
1277
+
1278
+ it "extract functions containing a function pointer with a void" do
1279
+ source = "void FunkyTurkey(void (*func_ptr)(void))"
1280
+ expected = [{ :var_arg=>nil,
1281
+ :return=>{ :type => "void",
1282
+ :name => 'cmock_to_return',
1283
+ :ptr? => false,
1284
+ :const? => false,
1285
+ :const_ptr? => false,
1286
+ :str => "void cmock_to_return",
1287
+ :void? => true
1288
+ },
1289
+ :name=>"FunkyTurkey",
1290
+ :modifier=>"",
1291
+ :contains_ptr? => false,
1292
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1293
+ ],
1294
+ :args_string=>"cmock_module_func_ptr1 func_ptr",
1295
+ :args_call=>"func_ptr" }]
1296
+ typedefs = ["typedef void(*cmock_module_func_ptr1)(void);"]
1297
+ result = @parser.parse("module", source)
1298
+ assert_equal(expected, result[:functions])
1299
+ assert_equal(typedefs, result[:typedefs])
1300
+ end
1301
+
1302
+ it "extract functions containing a function pointer with an implied void" do
1303
+ source = "void FunkyTurkey(unsigned int (*func_ptr)())"
1304
+ expected = [{ :var_arg=>nil,
1305
+ :return=>{ :type => "void",
1306
+ :name => 'cmock_to_return',
1307
+ :ptr? => false,
1308
+ :const? => false,
1309
+ :const_ptr? => false,
1310
+ :str => "void cmock_to_return",
1311
+ :void? => true
1312
+ },
1313
+ :name=>"FunkyTurkey",
1314
+ :modifier=>"",
1315
+ :contains_ptr? => false,
1316
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1317
+ ],
1318
+ :args_string=>"cmock_module_func_ptr1 func_ptr",
1319
+ :args_call=>"func_ptr" }]
1320
+ typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)();"]
1321
+ result = @parser.parse("module", source)
1322
+ assert_equal(expected, result[:functions])
1323
+ assert_equal(typedefs, result[:typedefs])
1324
+ end
1325
+
1326
+ it "extract functions containing a constant function pointer and a pointer in the nested arg list" do
1327
+ source = "void FunkyChicken(unsigned int (* const func_ptr)(unsigned long int * , char))"
1328
+ expected = [{ :var_arg=>nil,
1329
+ :return=>{ :type => "void",
1330
+ :name => 'cmock_to_return',
1331
+ :ptr? => false,
1332
+ :const? => false,
1333
+ :const_ptr? => false,
1334
+ :str => "void cmock_to_return",
1335
+ :void? => true
1336
+ },
1337
+ :name=>"FunkyChicken",
1338
+ :modifier=>"",
1339
+ :contains_ptr? => false,
1340
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => true, :const_ptr? => false}
1341
+ ],
1342
+ :args_string=>"cmock_module_func_ptr1 const func_ptr",
1343
+ :args_call=>"func_ptr" }]
1344
+ typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(unsigned long int* , char);"]
1345
+ result = @parser.parse("module", source)
1346
+ assert_equal(expected, result[:functions])
1347
+ assert_equal(typedefs, result[:typedefs])
1348
+ end
1349
+
1350
+ # it "extract functions containing a function pointer taking a vararg" do
1351
+ # source = "void FunkyParrot(unsigned int (*func_ptr)(int, char, ...))"
1352
+ # expected = [{ :var_arg=>nil,
1353
+ # :return=>{ :type => "void",
1354
+ # :name => 'cmock_to_return',
1355
+ # :ptr? => false,
1356
+ # :const? => false,
1357
+ # :const_ptr? => false,
1358
+ # :str => "void cmock_to_return",
1359
+ # :void? => true
1360
+ # },
1361
+ # :name=>"FunkyParrot",
1362
+ # :modifier=>"",
1363
+ # :contains_ptr? => false,
1364
+ # :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false, :const_ptr? => false}
1365
+ # ],
1366
+ # :args_string=>"cmock_module_func_ptr1 func_ptr",
1367
+ # :args_call=>"func_ptr" }]
1368
+ # typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char, ...);"]
1369
+ # result = @parser.parse("module", source)
1370
+ # assert_equal(expected, result[:functions])
1371
+ # assert_equal(typedefs, result[:typedefs])
1372
+ # end
1373
+
1374
+ it "extract functions containing a function pointer with extra parenthesis and two sets" do
1375
+ source = "void FunkyBudgie(int (((* func_ptr1)(int, char))), void (*func_ptr2)(void))"
1376
+ expected = [{ :var_arg=>nil,
1377
+ :return=>{ :type => "void",
1378
+ :name => 'cmock_to_return',
1379
+ :ptr? => false,
1380
+ :const? => false,
1381
+ :const_ptr? => false,
1382
+ :str => "void cmock_to_return",
1383
+ :void? => true
1384
+ },
1385
+ :name=>"FunkyBudgie",
1386
+ :modifier=>"",
1387
+ :contains_ptr? => false,
1388
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr1", :ptr? => false, :const? => false, :const_ptr? => false},
1389
+ {:type=>"cmock_module_func_ptr2", :name=>"func_ptr2", :ptr? => false, :const? => false, :const_ptr? => false}
1390
+ ],
1391
+ :args_string=>"cmock_module_func_ptr1 func_ptr1, cmock_module_func_ptr2 func_ptr2",
1392
+ :args_call=>"func_ptr1, func_ptr2" }]
1393
+ typedefs = ["typedef int(*cmock_module_func_ptr1)(int, char);", "typedef void(*cmock_module_func_ptr2)(void);"]
1394
+ result = @parser.parse("module", source)
1395
+ assert_equal(expected, result[:functions])
1396
+ assert_equal(typedefs, result[:typedefs])
1397
+ end
1398
+
1399
+ it "extract functions containing a function pointers, structs and other things" do
1400
+ source = "struct mytype *FunkyRobin(uint16_t num1, uint16_t num2, void (*func_ptr1)(uint16_t num3, struct mytype2 *s));"
1401
+ expected = [{ :var_arg=>nil,
1402
+ :return=>{ :type => "struct mytype*",
1403
+ :name => 'cmock_to_return',
1404
+ :ptr? => true,
1405
+ :const? => false,
1406
+ :const_ptr? => false,
1407
+ :str => "struct mytype* cmock_to_return",
1408
+ :void? => false
1409
+ },
1410
+ :name=>"FunkyRobin",
1411
+ :modifier=>"",
1412
+ :contains_ptr? => false,
1413
+ :args=>[ {:type=>"uint16_t", :name=>"num1", :ptr? => false, :const? => false, :const_ptr? => false},
1414
+ {:type=>"uint16_t", :name=>"num2", :ptr? => false, :const? => false, :const_ptr? => false},
1415
+ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr1", :ptr? => false, :const? => false, :const_ptr? => false}
1416
+ ],
1417
+ :args_string=>"uint16_t num1, uint16_t num2, cmock_module_func_ptr1 func_ptr1",
1418
+ :args_call=>"num1, num2, func_ptr1" }]
1419
+ typedefs = ["typedef void(*cmock_module_func_ptr1)(uint16_t num3, struct mytype2* s);"]
1420
+ result = @parser.parse("module", source)
1421
+ assert_equal(expected, result[:functions])
1422
+ assert_equal(typedefs, result[:typedefs])
1423
+ end
1424
+
1425
+ it "extract functions containing an anonymous function pointer" do
1426
+ source = "void FunkyFowl(unsigned int (* const)(int, char))"
1427
+ expected = [{ :var_arg=>nil,
1428
+ :return=>{ :type => "void",
1429
+ :name => 'cmock_to_return',
1430
+ :ptr? => false,
1431
+ :const? => false,
1432
+ :const_ptr? => false,
1433
+ :str => "void cmock_to_return",
1434
+ :void? => true
1435
+ },
1436
+ :name=>"FunkyFowl",
1437
+ :modifier=>"",
1438
+ :contains_ptr? => false,
1439
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"cmock_arg1", :ptr? => false, :const? => true, :const_ptr? => false}
1440
+ ],
1441
+ :args_string=>"cmock_module_func_ptr1 const cmock_arg1",
1442
+ :args_call=>"cmock_arg1" }]
1443
+ typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char);"]
1444
+ result = @parser.parse("module", source)
1445
+ assert_equal(expected, result[:functions])
1446
+ assert_equal(typedefs, result[:typedefs])
1447
+ end
1448
+
1449
+ it "extract functions returning a function pointer" do
1450
+ source = "unsigned short (*FunkyPidgeon( const char op_code ))( int, long int )"
1451
+ expected = [{ :var_arg=>nil,
1452
+ :return=>{ :type => "cmock_module_func_ptr1",
1453
+ :name => 'cmock_to_return',
1454
+ :ptr? => false,
1455
+ :const? => false,
1456
+ :const_ptr? => false,
1457
+ :str => "cmock_module_func_ptr1 cmock_to_return",
1458
+ :void? => false
1459
+ },
1460
+ :name=>"FunkyPidgeon",
1461
+ :modifier=>"",
1462
+ :contains_ptr? => false,
1463
+ :args=>[ {:type=>"char", :name=>"op_code", :ptr? => false, :const? => true, :const_ptr? => false}
1464
+ ],
1465
+ :args_string=>"const char op_code",
1466
+ :args_call=>"op_code" }]
1467
+ typedefs = ["typedef unsigned short(*cmock_module_func_ptr1)( int, long int );"]
1468
+ result = @parser.parse("module", source)
1469
+ assert_equal(expected, result[:functions])
1470
+ assert_equal(typedefs, result[:typedefs])
1471
+ end
1472
+
1473
+ it "extract functions returning a function pointer with implied void" do
1474
+ source = "unsigned short (*FunkyTweetie())()"
1475
+ expected = [{ :var_arg=>nil,
1476
+ :return=>{ :type => "cmock_module_func_ptr1",
1477
+ :name => 'cmock_to_return',
1478
+ :ptr? => false,
1479
+ :const? => false,
1480
+ :const_ptr? => false,
1481
+ :str => "cmock_module_func_ptr1 cmock_to_return",
1482
+ :void? => false
1483
+ },
1484
+ :name=>"FunkyTweetie",
1485
+ :modifier=>"",
1486
+ :contains_ptr? => false,
1487
+ :args=>[],
1488
+ :args_string=>"void",
1489
+ :args_call=>"" }]
1490
+ typedefs = ["typedef unsigned short(*cmock_module_func_ptr1)();"]
1491
+ result = @parser.parse("module", source)
1492
+ assert_equal(expected, result[:functions])
1493
+ assert_equal(typedefs, result[:typedefs])
1494
+ end
1495
+
1496
+ it "extract functions returning a function pointer where everything is a void" do
1497
+ source = "void (* FunkySeaGull(void))(void)"
1498
+ expected = [{ :var_arg=>nil,
1499
+ :return=>{ :type => "cmock_module_func_ptr1",
1500
+ :name => 'cmock_to_return',
1501
+ :ptr? => false,
1502
+ :const? => false,
1503
+ :const_ptr? => false,
1504
+ :str => "cmock_module_func_ptr1 cmock_to_return",
1505
+ :void? => false
1506
+ },
1507
+ :name=>"FunkySeaGull",
1508
+ :modifier=>"",
1509
+ :contains_ptr? => false,
1510
+ :args=>[],
1511
+ :args_string=>"void",
1512
+ :args_call=>"" }]
1513
+ typedefs = ["typedef void(*cmock_module_func_ptr1)(void);"]
1514
+ result = @parser.parse("module", source)
1515
+ assert_equal(expected, result[:functions])
1516
+ assert_equal(typedefs, result[:typedefs])
1517
+ end
1518
+
1519
+ it "extract functions returning a function pointer with some pointer nonsense" do
1520
+ source = "unsigned int * (* FunkyMacaw(double* foo, THING *bar))(unsigned int)"
1521
+ expected = [{ :var_arg=>nil,
1522
+ :return=>{ :type => "cmock_module_func_ptr1",
1523
+ :name => 'cmock_to_return',
1524
+ :ptr? => false,
1525
+ :const? => false,
1526
+ :const_ptr? => false,
1527
+ :str => "cmock_module_func_ptr1 cmock_to_return",
1528
+ :void? => false
1529
+ },
1530
+ :name=>"FunkyMacaw",
1531
+ :modifier=>"",
1532
+ :contains_ptr? => true,
1533
+ :args=>[ {:type=>"double*", :name=>"foo", :ptr? => true, :const? => false, :const_ptr? => false},
1534
+ {:type=>"THING*", :name=>"bar", :ptr? => true, :const? => false, :const_ptr? => false}
1535
+ ],
1536
+ :args_string=>"double* foo, THING* bar",
1537
+ :args_call=>"foo, bar" }]
1538
+ typedefs = ["typedef unsigned int *(*cmock_module_func_ptr1)(unsigned int);"]
1539
+ result = @parser.parse("module", source)
1540
+ assert_equal(expected, result[:functions])
1541
+ assert_equal(typedefs, result[:typedefs])
1542
+ end
1543
+
1544
+ it "extract this SQLite3 function with an anonymous function pointer arg (regression test)" do
1545
+ source = "SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*))"
1546
+ expected = [{ :var_arg=>nil,
1547
+ :return=>{ :type => "int",
1548
+ :name => "cmock_to_return",
1549
+ :ptr? => false,
1550
+ :const? => false,
1551
+ :const_ptr? => false,
1552
+ :str => "int cmock_to_return",
1553
+ :void? => false
1554
+ },
1555
+ :name=>"sqlite3_bind_text",
1556
+ :modifier=>"SQLITE_API",
1557
+ :contains_ptr? => true,
1558
+ :args=>[ {:type=>"sqlite3_stmt*", :name=>"cmock_arg2", :ptr? => true, :const? => false, :const_ptr? => false},
1559
+ {:type=>"int", :name=>"cmock_arg3", :ptr? => false, :const? => false, :const_ptr? => false},
1560
+ {:type=>"const char*", :name=>"cmock_arg4", :ptr? => false, :const? => true, :const_ptr? => false},
1561
+ {:type=>"int", :name=>"n", :ptr? => false, :const? => false, :const_ptr? => false},
1562
+ {:type=>"cmock_module_func_ptr1", :name=>"cmock_arg1", :ptr? => false, :const? => false, :const_ptr? => false}
1563
+ ],
1564
+ :args_string=>"sqlite3_stmt* cmock_arg2, int cmock_arg3, const char* cmock_arg4, int n, cmock_module_func_ptr1 cmock_arg1",
1565
+ :args_call=>"cmock_arg2, cmock_arg3, cmock_arg4, n, cmock_arg1" }]
1566
+ typedefs = ["typedef void(*cmock_module_func_ptr1)(void*);"]
1567
+ result = @parser.parse("module", source)
1568
+ assert_equal(expected, result[:functions])
1569
+ assert_equal(typedefs, result[:typedefs])
1570
+ end
1571
+
1572
+ it "extract functions with varargs" do
1573
+ source = "int XFiles(int Scully, int Mulder, ...);\n"
1574
+ expected = [{ :var_arg=>"...",
1575
+ :return=> { :type => "int",
1576
+ :name => 'cmock_to_return',
1577
+ :ptr? => false,
1578
+ :const? => false,
1579
+ :const_ptr? => false,
1580
+ :str => "int cmock_to_return",
1581
+ :void? => false
1582
+ },
1583
+ :name=>"XFiles",
1584
+ :modifier=>"",
1585
+ :contains_ptr? => false,
1586
+ :args=>[ {:type=>"int", :name=>"Scully", :ptr? => false, :const? => false, :const_ptr? => false},
1587
+ {:type=>"int", :name=>"Mulder", :ptr? => false, :const? => false, :const_ptr? => false}
1588
+ ],
1589
+ :args_string=>"int Scully, int Mulder",
1590
+ :args_call=>"Scully, Mulder"
1591
+ }]
1592
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1593
+ end
1594
+
1595
+ it "extract functions with void pointers" do
1596
+ source = "void* MoreSillySongs(void* stuff);\n"
1597
+ expected = [{ :var_arg=>nil,
1598
+ :return=> { :type => "void*",
1599
+ :name => 'cmock_to_return',
1600
+ :ptr? => true,
1601
+ :const? => false,
1602
+ :const_ptr? => false,
1603
+ :str => "void* cmock_to_return",
1604
+ :void? => false
1605
+ },
1606
+ :name=>"MoreSillySongs",
1607
+ :modifier=>"",
1608
+ :contains_ptr? => true,
1609
+ :args=>[ {:type=>"void*", :name=>"stuff", :ptr? => true, :const? => false, :const_ptr? => false}
1610
+ ],
1611
+ :args_string=>"void* stuff",
1612
+ :args_call=>"stuff"
1613
+ }]
1614
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1615
+ end
1616
+
1617
+ it "extract functions with strippable confusing junk like gcc attributes" do
1618
+ source = "int LaverneAndShirley(int Lenny, int Squiggy) __attribute__((weak)) __attribute__ ((deprecated));\n"
1619
+ expected = [{ :var_arg=>nil,
1620
+ :return=> { :type => "int",
1621
+ :name => 'cmock_to_return',
1622
+ :ptr? => false,
1623
+ :const? => false,
1624
+ :const_ptr? => false,
1625
+ :str => "int cmock_to_return",
1626
+ :void? => false
1627
+ },
1628
+ :name=>"LaverneAndShirley",
1629
+ :modifier=>"",
1630
+ :contains_ptr? => false,
1631
+ :args=>[ {:type=>"int", :name=>"Lenny", :ptr? => false, :const? => false, :const_ptr? => false},
1632
+ {:type=>"int", :name=>"Squiggy", :ptr? => false, :const? => false, :const_ptr? => false}
1633
+ ],
1634
+ :args_string=>"int Lenny, int Squiggy",
1635
+ :args_call=>"Lenny, Squiggy"
1636
+ }]
1637
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1638
+ end
1639
+
1640
+ it "extract functions with strippable confusing junk like gcc attributes with parenthesis" do
1641
+ source = "int TheCosbyShow(int Cliff, int Claire) __attribute__((weak, alias (\"__f\"));\n"
1642
+ expected = [{ :var_arg=>nil,
1643
+ :return=> { :type => "int",
1644
+ :name => 'cmock_to_return',
1645
+ :ptr? => false,
1646
+ :const? => false,
1647
+ :const_ptr? => false,
1648
+ :str => "int cmock_to_return",
1649
+ :void? => false
1650
+ },
1651
+ :name=>"TheCosbyShow",
1652
+ :modifier=>"",
1653
+ :contains_ptr? => false,
1654
+ :args=>[ {:type=>"int", :name=>"Cliff", :ptr? => false, :const? => false, :const_ptr? => false},
1655
+ {:type=>"int", :name=>"Claire", :ptr? => false, :const? => false, :const_ptr? => false}
1656
+ ],
1657
+ :args_string=>"int Cliff, int Claire",
1658
+ :args_call=>"Cliff, Claire"
1659
+ }]
1660
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1661
+ end
1662
+
1663
+ it "divines all permutations of ptr, const, and const_ptr correctly" do
1664
+ truth_table = [
1665
+ # argument ptr const const_ptr
1666
+ [ "constNOTconst constNOTconst", false, false, false ],
1667
+ [ "const constNOTconst constNOTconst", false, true, false ],
1668
+ [ "constNOTconst const constNOTconst", false, true, false ],
1669
+ [ "constNOTconst *constNOTconst", true, false, false ],
1670
+ [ "const constNOTconst *constNOTconst", true, true, false ],
1671
+ [ "constNOTconst const *constNOTconst", true, true, false ],
1672
+ [ "constNOTconst *const constNOTconst", true, false, true ],
1673
+ [ "const constNOTconst *const constNOTconst", true, true, true ],
1674
+ [ "constNOTconst const *const constNOTconst", true, true, true ],
1675
+ [ "constNOTconst **constNOTconst", true, false, false ],
1676
+ [ "const constNOTconst **constNOTconst", true, false, false ],
1677
+ [ "constNOTconst const **constNOTconst", true, false, false ],
1678
+ [ "constNOTconst *const *constNOTconst", true, true, false ],
1679
+ [ "const constNOTconst *const *constNOTconst", true, true, false ],
1680
+ [ "constNOTconst const *const *constNOTconst", true, true, false ],
1681
+ [ "constNOTconst **const constNOTconst", true, false, true ],
1682
+ [ "const constNOTconst **const constNOTconst", true, false, true ],
1683
+ [ "constNOTconst const **const constNOTconst", true, false, true ],
1684
+ [ "constNOTconst *const *const constNOTconst", true, true, true ],
1685
+ [ "const constNOTconst *const *const constNOTconst", true, true, true ],
1686
+ [ "constNOTconst const *const *const constNOTconst", true, true, true ]
1687
+ ]
1688
+
1689
+ truth_table.each do |entry|
1690
+ assert_equal(@parser.divine_ptr(entry[0]), entry[1])
1691
+ assert_equal(@parser.divine_const(entry[0]), entry[2])
1692
+ assert_equal(@parser.divine_ptr_and_const(entry[0]),
1693
+ { ptr?: entry[1], const?: entry[2], const_ptr?: entry[3] })
1694
+ end
1695
+ end
1696
+
1697
+ it "divines ptr correctly for string types" do
1698
+ truth_table = [
1699
+ # argument ptr
1700
+ [ "char s", false ],
1701
+ [ "const char s", false ],
1702
+ [ "char const s", false ],
1703
+ [ "char *s", false ],
1704
+ [ "const char *s", false ],
1705
+ [ "char const *s", false ],
1706
+ [ "char *const s", false ],
1707
+ [ "const char *const s", false ],
1708
+ [ "char const *const s", false ],
1709
+ [ "char **s", true ],
1710
+ [ "const char **s", true ],
1711
+ [ "char const **s", true ],
1712
+ [ "char *const *s", true ],
1713
+ [ "const char *const *s", true ],
1714
+ [ "char const *const *s", true ],
1715
+ [ "char **const s", true ],
1716
+ [ "const char **const s", true ],
1717
+ [ "char const **const s", true ],
1718
+ [ "char *const *const s", true ],
1719
+ [ "const char *const *const s", true ],
1720
+ [ "char const *const *const s", true ]
1721
+ ]
1722
+
1723
+ truth_table.each do |entry|
1724
+ assert_equal(@parser.divine_ptr(entry[0]), entry[1])
1725
+ end
1726
+ end
1727
+
1728
+ end