ceedling 0.18.0 → 0.19.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 (626) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +17 -13
  3. data/ceedling-0.18.0.gem +0 -0
  4. data/docs/CeedlingPacket.md +7 -5
  5. data/lib/ceedling/configurator_builder.rb +10 -21
  6. data/lib/ceedling/configurator_setup.rb +16 -17
  7. data/lib/ceedling/constants.rb +4 -3
  8. data/lib/ceedling/defaults.rb +9 -4
  9. data/lib/ceedling/dependinator.rb +0 -1
  10. data/lib/ceedling/file_path_utils.rb +22 -26
  11. data/lib/ceedling/flaginator.rb +5 -5
  12. data/lib/ceedling/generator.rb +8 -7
  13. data/lib/ceedling/preprocessinator_file_handler.rb +6 -6
  14. data/lib/ceedling/preprocessinator_includes_handler.rb +1 -1
  15. data/lib/ceedling/rules_release.rake +5 -3
  16. data/lib/ceedling/rules_tests.rake +2 -1
  17. data/lib/ceedling/tasks_base.rake +1 -1
  18. data/lib/ceedling/tasks_vendor.rake +9 -10
  19. data/lib/ceedling/tool_executor.rb +23 -22
  20. data/lib/ceedling/version.rb +3 -3
  21. data/plugins/module_generator/lib/module_generator.rb +3 -3
  22. data/plugins/xml_tests_report/xml_tests_report.rb +1 -1
  23. data/spec/preprocessinator_includes_handler_spec.rb +1 -1
  24. data/spec/spec_system_helper.rb +192 -192
  25. data/vendor/c_exception/vendor/unity/Gemfile +4 -0
  26. data/vendor/c_exception/vendor/unity/Gemfile.lock +12 -0
  27. data/vendor/c_exception/vendor/unity/auto/colour_prompt.rb +115 -0
  28. data/vendor/c_exception/vendor/unity/auto/colour_reporter.rb +39 -0
  29. data/vendor/c_exception/vendor/unity/auto/generate_config.yml +36 -0
  30. data/vendor/c_exception/vendor/unity/auto/generate_module.rb +202 -0
  31. data/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +320 -0
  32. data/vendor/c_exception/vendor/unity/auto/parseOutput.rb +189 -0
  33. data/vendor/c_exception/vendor/unity/auto/test_file_filter.rb +23 -0
  34. data/vendor/c_exception/vendor/unity/auto/unity_test_summary.rb +139 -0
  35. data/vendor/c_exception/vendor/unity/docs/Unity Summary.odt +0 -0
  36. data/vendor/c_exception/vendor/unity/docs/Unity Summary.pdf +0 -0
  37. data/vendor/c_exception/vendor/unity/docs/Unity Summary.txt +216 -0
  38. data/vendor/c_exception/vendor/unity/docs/license.txt +31 -0
  39. data/vendor/c_exception/vendor/unity/examples/example_1/makefile +41 -0
  40. data/vendor/c_exception/vendor/unity/examples/example_1/readme.txt +5 -0
  41. data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode.c +24 -0
  42. data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode.h +3 -0
  43. data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.c +9 -0
  44. data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.h +2 -0
  45. data/vendor/c_exception/vendor/unity/examples/example_1/test/TestProductionCode.c +62 -0
  46. data/vendor/c_exception/vendor/unity/examples/example_1/test/TestProductionCode2.c +31 -0
  47. data/vendor/{unity/examples/example_3/test/no_ruby → c_exception/vendor/unity/examples/example_1/test/test_runners}/TestProductionCode2_Runner.c +16 -3
  48. data/vendor/{unity/examples/example_3/test/no_ruby → c_exception/vendor/unity/examples/example_1/test/test_runners}/TestProductionCode_Runner.c +16 -3
  49. data/vendor/c_exception/vendor/unity/examples/example_2/makefile +45 -0
  50. data/vendor/c_exception/vendor/unity/examples/example_2/readme.txt +5 -0
  51. data/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode.c +24 -0
  52. data/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode.h +3 -0
  53. data/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode2.c +9 -0
  54. data/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode2.h +2 -0
  55. data/vendor/c_exception/vendor/unity/examples/example_2/test/TestProductionCode.c +64 -0
  56. data/vendor/c_exception/vendor/unity/examples/example_2/test/TestProductionCode2.c +33 -0
  57. data/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +9 -0
  58. data/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +11 -0
  59. data/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/all_tests.c +12 -0
  60. data/vendor/c_exception/vendor/unity/examples/example_3/helper/UnityHelper.c +10 -0
  61. data/vendor/c_exception/vendor/unity/examples/example_3/helper/UnityHelper.h +12 -0
  62. data/vendor/c_exception/vendor/unity/examples/example_3/makefile +41 -0
  63. data/vendor/c_exception/vendor/unity/examples/example_3/rakefile.rb +44 -0
  64. data/vendor/c_exception/vendor/unity/examples/example_3/rakefile_helper.rb +256 -0
  65. data/vendor/c_exception/vendor/unity/examples/example_3/readme.txt +19 -0
  66. data/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode.c +24 -0
  67. data/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode.h +3 -0
  68. data/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode2.c +9 -0
  69. data/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode2.h +2 -0
  70. data/vendor/c_exception/vendor/unity/examples/example_3/target_gcc_32.yml +46 -0
  71. data/vendor/c_exception/vendor/unity/examples/example_3/test/TestProductionCode.c +62 -0
  72. data/vendor/c_exception/vendor/unity/examples/example_3/test/TestProductionCode2.c +31 -0
  73. data/vendor/c_exception/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c +46 -0
  74. data/vendor/c_exception/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode_Runner.c +50 -0
  75. data/vendor/c_exception/vendor/unity/extras/eclipse/error_parsers.txt +26 -0
  76. data/vendor/c_exception/vendor/unity/extras/fixture/rakefile.rb +37 -0
  77. data/vendor/c_exception/vendor/unity/extras/fixture/rakefile_helper.rb +179 -0
  78. data/vendor/c_exception/vendor/unity/extras/fixture/readme.txt +9 -0
  79. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +387 -0
  80. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +82 -0
  81. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +44 -0
  82. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +16 -0
  83. data/vendor/c_exception/vendor/unity/extras/fixture/test/main/AllTests.c +21 -0
  84. data/vendor/c_exception/vendor/unity/extras/fixture/test/testunity_fixture.c +39 -0
  85. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +341 -0
  86. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +41 -0
  87. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +56 -0
  88. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +17 -0
  89. data/vendor/c_exception/vendor/unity/makefile +37 -0
  90. data/vendor/c_exception/vendor/unity/rakefile.rb +61 -0
  91. data/vendor/c_exception/vendor/unity/rakefile_helper.rb +249 -0
  92. data/vendor/c_exception/vendor/unity/release/build.info +2 -0
  93. data/vendor/c_exception/vendor/unity/release/version.info +2 -0
  94. data/vendor/c_exception/vendor/unity/src/unity.c +1145 -0
  95. data/vendor/c_exception/vendor/unity/src/unity.h +307 -0
  96. data/vendor/c_exception/vendor/unity/src/unity_internals.h +620 -0
  97. data/vendor/c_exception/vendor/unity/targets/clang_strict.yml +83 -0
  98. data/vendor/c_exception/vendor/unity/targets/gcc_32.yml +44 -0
  99. data/vendor/c_exception/vendor/unity/targets/gcc_64.yml +45 -0
  100. data/vendor/c_exception/vendor/unity/targets/hitech_picc18.yml +101 -0
  101. data/vendor/c_exception/vendor/unity/targets/iar_arm_v4.yml +89 -0
  102. data/vendor/c_exception/vendor/unity/targets/iar_arm_v5.yml +79 -0
  103. data/vendor/c_exception/vendor/unity/targets/iar_arm_v5_3.yml +79 -0
  104. data/vendor/c_exception/vendor/unity/targets/iar_armcortex_LM3S9B92_v5_4.yml +93 -0
  105. data/vendor/c_exception/vendor/unity/targets/iar_cortexm3_v5.yml +83 -0
  106. data/vendor/c_exception/vendor/unity/targets/iar_msp430.yml +94 -0
  107. data/vendor/c_exception/vendor/unity/targets/iar_sh2a_v6.yml +85 -0
  108. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_cmd.c +57 -0
  109. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_def.c +53 -0
  110. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_cmd.c +79 -0
  111. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_def.c +75 -0
  112. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new1.c +88 -0
  113. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new2.c +88 -0
  114. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_param.c +76 -0
  115. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run1.c +88 -0
  116. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run2.c +88 -0
  117. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_yaml.c +89 -0
  118. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_new1.c +63 -0
  119. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_new2.c +66 -0
  120. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_param.c +54 -0
  121. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_run1.c +63 -0
  122. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_run2.c +66 -0
  123. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_yaml.c +67 -0
  124. data/vendor/c_exception/vendor/unity/test/test_generate_test_runner.rb +88 -0
  125. data/vendor/c_exception/vendor/unity/test/testdata/mocksample.c +51 -0
  126. data/vendor/c_exception/vendor/unity/test/testdata/sample.yml +9 -0
  127. data/vendor/c_exception/vendor/unity/test/testdata/testsample.c +51 -0
  128. data/vendor/c_exception/vendor/unity/test/testparameterized.c +101 -0
  129. data/vendor/c_exception/vendor/unity/test/testunity.c +3447 -0
  130. data/vendor/cmock/README.md +1 -1
  131. data/vendor/cmock/Rakefile +106 -104
  132. data/vendor/cmock/config/production_environment.rb +14 -14
  133. data/vendor/cmock/config/test_environment.rb +16 -16
  134. data/vendor/cmock/docs/CMock_Summary.md +9 -0
  135. data/vendor/cmock/docs/license.txt +2 -2
  136. data/vendor/cmock/examples/make_example/Makefile +30 -0
  137. data/vendor/cmock/examples/make_example/src/foo.c +5 -0
  138. data/vendor/cmock/examples/make_example/src/foo.h +5 -0
  139. data/vendor/cmock/examples/make_example/src/main.c +15 -0
  140. data/vendor/cmock/examples/make_example/test/test_foo.c +17 -0
  141. data/vendor/cmock/examples/make_example/test/test_main.c +15 -0
  142. data/vendor/cmock/examples/{gcc.yml → temp_sensor/gcc.yml} +43 -43
  143. data/vendor/cmock/examples/{iar_v4.yml → temp_sensor/iar_v4.yml} +91 -91
  144. data/vendor/cmock/examples/{iar_v5.yml → temp_sensor/iar_v5.yml} +80 -80
  145. data/vendor/cmock/examples/{rakefile.rb → temp_sensor/rakefile.rb} +32 -32
  146. data/vendor/cmock/examples/{rakefile_helper.rb → temp_sensor/rakefile_helper.rb} +270 -270
  147. data/vendor/cmock/examples/{src → temp_sensor/src}/AT91SAM7X256.h +2556 -2556
  148. data/vendor/cmock/examples/{src → temp_sensor/src}/AdcConductor.c +42 -42
  149. data/vendor/cmock/examples/{src → temp_sensor/src}/AdcConductor.h +11 -11
  150. data/vendor/cmock/examples/{src → temp_sensor/src}/AdcHardware.c +27 -27
  151. data/vendor/cmock/examples/{src → temp_sensor/src}/AdcHardware.h +9 -9
  152. data/vendor/cmock/examples/{src → temp_sensor/src}/AdcHardwareConfigurator.c +18 -18
  153. data/vendor/cmock/examples/{src → temp_sensor/src}/AdcHardwareConfigurator.h +10 -10
  154. data/vendor/cmock/examples/{src → temp_sensor/src}/AdcModel.c +33 -33
  155. data/vendor/cmock/examples/{src → temp_sensor/src}/AdcModel.h +13 -13
  156. data/vendor/cmock/examples/{src → temp_sensor/src}/AdcTemperatureSensor.c +51 -51
  157. data/vendor/cmock/examples/{src → temp_sensor/src}/AdcTemperatureSensor.h +10 -10
  158. data/vendor/cmock/examples/{src → temp_sensor/src}/Executor.c +25 -25
  159. data/vendor/cmock/examples/{src → temp_sensor/src}/Executor.h +9 -9
  160. data/vendor/cmock/examples/{src → temp_sensor/src}/IntrinsicsWrapper.c +18 -18
  161. data/vendor/cmock/examples/{src → temp_sensor/src}/IntrinsicsWrapper.h +7 -7
  162. data/vendor/cmock/examples/{src → temp_sensor/src}/Main.c +46 -46
  163. data/vendor/cmock/examples/{src → temp_sensor/src}/Main.h +7 -7
  164. data/vendor/cmock/examples/{src → temp_sensor/src}/Model.c +10 -10
  165. data/vendor/cmock/examples/{src → temp_sensor/src}/Model.h +8 -8
  166. data/vendor/cmock/examples/{src → temp_sensor/src}/ModelConfig.h +7 -7
  167. data/vendor/cmock/examples/{src → temp_sensor/src}/TaskScheduler.c +72 -72
  168. data/vendor/cmock/examples/{src → temp_sensor/src}/TaskScheduler.h +11 -11
  169. data/vendor/cmock/examples/{src → temp_sensor/src}/TemperatureCalculator.c +27 -27
  170. data/vendor/cmock/examples/{src → temp_sensor/src}/TemperatureCalculator.h +6 -6
  171. data/vendor/cmock/examples/{src → temp_sensor/src}/TemperatureFilter.c +39 -39
  172. data/vendor/cmock/examples/{src → temp_sensor/src}/TemperatureFilter.h +10 -10
  173. data/vendor/cmock/examples/{src → temp_sensor/src}/TimerConductor.c +15 -15
  174. data/vendor/cmock/examples/{src → temp_sensor/src}/TimerConductor.h +9 -9
  175. data/vendor/cmock/examples/{src → temp_sensor/src}/TimerConfigurator.c +51 -51
  176. data/vendor/cmock/examples/{src → temp_sensor/src}/TimerConfigurator.h +15 -15
  177. data/vendor/cmock/examples/{src → temp_sensor/src}/TimerHardware.c +15 -15
  178. data/vendor/cmock/examples/{src → temp_sensor/src}/TimerHardware.h +8 -8
  179. data/vendor/cmock/examples/{src → temp_sensor/src}/TimerInterruptConfigurator.c +55 -55
  180. data/vendor/cmock/examples/{src → temp_sensor/src}/TimerInterruptConfigurator.h +13 -13
  181. data/vendor/cmock/examples/{src → temp_sensor/src}/TimerInterruptHandler.c +25 -25
  182. data/vendor/cmock/examples/{src → temp_sensor/src}/TimerInterruptHandler.h +10 -10
  183. data/vendor/cmock/examples/{src → temp_sensor/src}/TimerModel.c +9 -9
  184. data/vendor/cmock/examples/{src → temp_sensor/src}/TimerModel.h +8 -8
  185. data/vendor/cmock/examples/{src → temp_sensor/src}/Types.h +103 -103
  186. data/vendor/cmock/examples/{src → temp_sensor/src}/UsartBaudRateRegisterCalculator.c +18 -18
  187. data/vendor/cmock/examples/{src → temp_sensor/src}/UsartBaudRateRegisterCalculator.h +6 -6
  188. data/vendor/cmock/examples/{src → temp_sensor/src}/UsartConductor.c +21 -21
  189. data/vendor/cmock/examples/{src → temp_sensor/src}/UsartConductor.h +7 -7
  190. data/vendor/cmock/examples/{src → temp_sensor/src}/UsartConfigurator.c +39 -39
  191. data/vendor/cmock/examples/{src → temp_sensor/src}/UsartConfigurator.h +13 -13
  192. data/vendor/cmock/examples/{src → temp_sensor/src}/UsartHardware.c +22 -22
  193. data/vendor/cmock/examples/{src → temp_sensor/src}/UsartHardware.h +9 -9
  194. data/vendor/cmock/examples/{src → temp_sensor/src}/UsartModel.c +34 -34
  195. data/vendor/cmock/examples/{src → temp_sensor/src}/UsartModel.h +10 -10
  196. data/vendor/cmock/examples/{src → temp_sensor/src}/UsartPutChar.c +16 -16
  197. data/vendor/cmock/examples/{src → temp_sensor/src}/UsartPutChar.h +8 -8
  198. data/vendor/cmock/examples/{src → temp_sensor/src}/UsartTransmitBufferStatus.c +7 -7
  199. data/vendor/cmock/examples/{src → temp_sensor/src}/UsartTransmitBufferStatus.h +8 -8
  200. data/vendor/cmock/examples/{test → temp_sensor/test}/TestAdcConductor.c +121 -121
  201. data/vendor/cmock/examples/{test → temp_sensor/test}/TestAdcHardware.c +44 -44
  202. data/vendor/cmock/examples/{test → temp_sensor/test}/TestAdcHardwareConfigurator.c +43 -43
  203. data/vendor/cmock/examples/{test → temp_sensor/test}/TestAdcModel.c +33 -33
  204. data/vendor/cmock/examples/{test → temp_sensor/test}/TestAdcTemperatureSensor.c +47 -47
  205. data/vendor/cmock/examples/{test → temp_sensor/test}/TestExecutor.c +36 -36
  206. data/vendor/cmock/examples/{test → temp_sensor/test}/TestMain.c +24 -24
  207. data/vendor/cmock/examples/{test → temp_sensor/test}/TestModel.c +20 -20
  208. data/vendor/cmock/examples/{test → temp_sensor/test}/TestTaskScheduler.c +104 -104
  209. data/vendor/cmock/examples/{test → temp_sensor/test}/TestTemperatureCalculator.c +33 -33
  210. data/vendor/cmock/examples/{test → temp_sensor/test}/TestTemperatureFilter.c +69 -69
  211. data/vendor/cmock/examples/{test → temp_sensor/test}/TestTimerConductor.c +32 -32
  212. data/vendor/cmock/examples/{test → temp_sensor/test}/TestTimerConfigurator.c +112 -112
  213. data/vendor/cmock/examples/{test → temp_sensor/test}/TestTimerHardware.c +26 -26
  214. data/vendor/cmock/examples/{test → temp_sensor/test}/TestTimerInterruptConfigurator.c +78 -78
  215. data/vendor/cmock/examples/{test → temp_sensor/test}/TestTimerInterruptHandler.c +66 -66
  216. data/vendor/cmock/examples/{test → temp_sensor/test}/TestTimerModel.c +18 -18
  217. data/vendor/cmock/examples/{test → temp_sensor/test}/TestUsartBaudRateRegisterCalculator.c +21 -21
  218. data/vendor/cmock/examples/{test → temp_sensor/test}/TestUsartConductor.c +40 -40
  219. data/vendor/cmock/examples/{test → temp_sensor/test}/TestUsartConfigurator.c +77 -77
  220. data/vendor/cmock/examples/{test → temp_sensor/test}/TestUsartHardware.c +37 -37
  221. data/vendor/cmock/examples/{test → temp_sensor/test}/TestUsartModel.c +36 -36
  222. data/vendor/cmock/examples/{test → temp_sensor/test}/TestUsartPutChar.c +43 -43
  223. data/vendor/cmock/examples/{test → temp_sensor/test}/TestUsartTransmitBufferStatus.c +22 -22
  224. data/vendor/cmock/iar/iar_v4/Resource/at91SAM7X256_FLASH.xcl +185 -185
  225. data/vendor/cmock/iar/iar_v4/Resource/at91SAM7X256_RAM.xcl +185 -185
  226. data/vendor/cmock/iar/iar_v4/Resource/ioat91sam7x256.ddf +2259 -2259
  227. data/vendor/cmock/iar/iar_v4/cmock_demo.dep +3691 -3691
  228. data/vendor/cmock/iar/iar_v4/cmock_demo.ewp +2581 -2581
  229. data/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X-EK.h +61 -61
  230. data/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256.inc +2314 -2314
  231. data/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256.rdf +4704 -4704
  232. data/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256.tcl +3407 -3407
  233. data/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256_inc.h +2268 -2268
  234. data/vendor/cmock/iar/iar_v4/incIAR/ioat91sam7x256.h +4380 -4380
  235. data/vendor/cmock/iar/iar_v4/incIAR/lib_AT91SAM7X256.h +4211 -4211
  236. data/vendor/cmock/iar/iar_v4/settings/cmock_demo.cspy.bat +32 -32
  237. data/vendor/cmock/iar/iar_v4/srcIAR/Cstartup.s79 +265 -265
  238. data/vendor/cmock/iar/iar_v4/srcIAR/Cstartup_SAM7.c +98 -98
  239. data/vendor/cmock/iar/iar_v5/Resource/at91SAM7X256_FLASH.icf +43 -43
  240. data/vendor/cmock/iar/iar_v5/Resource/at91SAM7X256_RAM.icf +42 -42
  241. data/vendor/cmock/iar/iar_v5/cmock_demo.dep +4204 -4204
  242. data/vendor/cmock/iar/iar_v5/cmock_demo.ewp +2426 -2426
  243. data/vendor/cmock/iar/iar_v5/incIAR/AT91SAM7X-EK.h +61 -61
  244. data/vendor/cmock/iar/iar_v5/incIAR/AT91SAM7X256_inc.h +2268 -2268
  245. data/vendor/cmock/iar/iar_v5/incIAR/lib_AT91SAM7X256.h +4211 -4211
  246. data/vendor/cmock/iar/iar_v5/incIAR/project.h +30 -30
  247. data/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X.cspy.bat +33 -33
  248. data/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X_FLASH_Debug.jlink +12 -12
  249. data/vendor/cmock/iar/iar_v5/settings/cmock_demo.cspy.bat +33 -33
  250. data/vendor/cmock/iar/iar_v5/settings/cmock_demo_Binary.jlink +12 -12
  251. data/vendor/cmock/iar/iar_v5/settings/cmock_demo_FLASH_Debug.jlink +12 -12
  252. data/vendor/cmock/iar/iar_v5/settings/cmock_demo_RAM_Debug.jlink +12 -12
  253. data/vendor/cmock/iar/iar_v5/srcIAR/Cstartup.s +299 -299
  254. data/vendor/cmock/iar/iar_v5/srcIAR/Cstartup_SAM7.c +98 -98
  255. data/vendor/cmock/lib/cmock.rb +89 -89
  256. data/vendor/cmock/lib/cmock_config.rb +134 -133
  257. data/vendor/cmock/lib/cmock_file_writer.rb +40 -33
  258. data/vendor/cmock/lib/cmock_generator.rb +234 -215
  259. data/vendor/cmock/lib/cmock_generator_plugin_array.rb +63 -63
  260. data/vendor/cmock/lib/cmock_generator_plugin_callback.rb +96 -78
  261. data/vendor/cmock/lib/cmock_generator_plugin_cexception.rb +52 -51
  262. data/vendor/cmock/lib/cmock_generator_plugin_expect.rb +104 -86
  263. data/vendor/cmock/lib/cmock_generator_plugin_expect_any_args.rb +68 -68
  264. data/vendor/cmock/lib/cmock_generator_plugin_ignore.rb +72 -71
  265. data/vendor/cmock/lib/cmock_generator_plugin_ignore_arg.rb +1 -1
  266. data/vendor/cmock/lib/cmock_generator_plugin_return_thru_ptr.rb +2 -2
  267. data/vendor/cmock/lib/cmock_generator_utils.rb +228 -213
  268. data/vendor/cmock/lib/cmock_header_parser.rb +1 -1
  269. data/vendor/cmock/lib/cmock_plugin_manager.rb +40 -40
  270. data/vendor/cmock/lib/cmock_unityhelper_parser.rb +75 -75
  271. data/vendor/cmock/rakefile_helper.rb +381 -381
  272. data/vendor/cmock/release/build.info +1 -1
  273. data/vendor/cmock/release/version.info +1 -1
  274. data/vendor/cmock/scripts/create_makefile.rb +161 -0
  275. data/vendor/cmock/scripts/create_mock.rb +8 -0
  276. data/vendor/cmock/scripts/create_runner.rb +20 -0
  277. data/vendor/cmock/scripts/test_summary.rb +11 -0
  278. data/vendor/cmock/src/cmock.c +203 -192
  279. data/vendor/cmock/src/cmock.h +38 -36
  280. data/vendor/cmock/src/cmock_internals.h +11 -1
  281. data/vendor/cmock/targets/clang_strict.yml +90 -85
  282. data/vendor/cmock/targets/gcc.yml +58 -55
  283. data/vendor/cmock/targets/gcc_64.yml +58 -55
  284. data/vendor/cmock/targets/gcc_tiny.yml +80 -0
  285. data/vendor/cmock/targets/iar_arm_v4.yml +110 -108
  286. data/vendor/cmock/targets/iar_arm_v5.yml +95 -93
  287. data/vendor/cmock/test/c/TestCMockC.c +323 -323
  288. data/vendor/cmock/test/c/TestCMockC.yml +1 -0
  289. data/vendor/cmock/test/c/TestCMockCDynamic.c +186 -186
  290. data/vendor/cmock/test/c/TestCMockCDynamic_Runner.c +36 -36
  291. data/vendor/cmock/test/c/TestCMockC_Runner.c +39 -39
  292. data/vendor/cmock/test/system/systest_generator.rb +194 -194
  293. data/vendor/cmock/test/system/test_compilation/callingconv.h +11 -11
  294. data/vendor/cmock/test/system/test_compilation/osek.h +275 -275
  295. data/vendor/cmock/test/system/test_compilation/parsing.h +2 -0
  296. data/vendor/cmock/test/system/test_interactions/all_plugins_but_other_limits.yml +375 -375
  297. data/vendor/cmock/test/system/test_interactions/all_plugins_coexist.yml +459 -389
  298. data/vendor/cmock/test/system/test_interactions/array_and_pointer_handling.yml +62 -0
  299. data/vendor/cmock/test/system/test_interactions/doesnt_leave_details_behind.yml +308 -0
  300. data/vendor/cmock/test/system/test_interactions/enforce_strict_ordering.yml +23 -23
  301. data/vendor/cmock/test/system/test_interactions/out_of_memory.yml +65 -0
  302. data/vendor/cmock/test/system/test_interactions/parsing_challenges.yml +38 -20
  303. data/vendor/cmock/test/system/test_interactions/struct_union_enum_expect_and_return_with_plugins.yml +280 -0
  304. data/vendor/cmock/test/test_helper.rb +47 -47
  305. data/vendor/cmock/test/unit/cmock_config_test.rb +118 -118
  306. data/vendor/cmock/test/unit/cmock_config_test.yml +5 -5
  307. data/vendor/cmock/test/unit/cmock_file_writer_test.rb +27 -27
  308. data/vendor/cmock/test/unit/cmock_generator_main_test.rb +507 -489
  309. data/vendor/cmock/test/unit/cmock_generator_plugin_array_test.rb +133 -133
  310. data/vendor/cmock/test/unit/cmock_generator_plugin_callback_test.rb +257 -189
  311. data/vendor/cmock/test/unit/cmock_generator_plugin_cexception_test.rb +96 -93
  312. data/vendor/cmock/test/unit/cmock_generator_plugin_expect_a_test.rb +186 -0
  313. data/vendor/cmock/test/unit/cmock_generator_plugin_expect_any_args_test.rb +60 -81
  314. data/vendor/cmock/test/unit/{cmock_generator_plugin_expect_test.rb → cmock_generator_plugin_expect_b_test.rb} +202 -205
  315. data/vendor/cmock/test/unit/cmock_generator_plugin_ignore_arg_test.rb +116 -116
  316. data/vendor/cmock/test/unit/cmock_generator_plugin_ignore_test.rb +105 -103
  317. data/vendor/cmock/test/unit/cmock_generator_plugin_return_thru_ptr_test.rb +134 -134
  318. data/vendor/cmock/test/unit/cmock_generator_utils_test.rb +377 -334
  319. data/vendor/cmock/test/unit/cmock_header_parser_test.rb +1381 -1337
  320. data/vendor/cmock/test/unit/cmock_plugin_manager_test.rb +95 -95
  321. data/vendor/cmock/test/unit/cmock_unityhelper_parser_test.rb +223 -223
  322. data/vendor/cmock/vendor/c_exception/Gemfile +4 -0
  323. data/vendor/cmock/vendor/c_exception/Gemfile.lock +12 -0
  324. data/vendor/cmock/vendor/c_exception/LICENSE.txt +30 -0
  325. data/vendor/cmock/vendor/c_exception/README.md +146 -0
  326. data/vendor/cmock/vendor/c_exception/Rakefile +42 -0
  327. data/vendor/cmock/vendor/c_exception/docs/CExceptionSummary.odt +0 -0
  328. data/vendor/cmock/vendor/c_exception/docs/CExceptionSummary.pdf +0 -0
  329. data/vendor/cmock/vendor/c_exception/docs/readme.txt +242 -0
  330. data/vendor/cmock/vendor/c_exception/lib/CException.c +46 -0
  331. data/vendor/cmock/vendor/c_exception/lib/CException.h +86 -0
  332. data/vendor/cmock/vendor/c_exception/makefile +24 -0
  333. data/vendor/cmock/vendor/c_exception/release/build.info +2 -0
  334. data/vendor/cmock/vendor/c_exception/release/version.info +2 -0
  335. data/vendor/cmock/vendor/c_exception/test/CExceptionConfig.h +46 -0
  336. data/vendor/cmock/vendor/c_exception/test/TestException.c +342 -0
  337. data/vendor/cmock/vendor/c_exception/test/TestException_Runner.c +74 -0
  338. data/vendor/cmock/vendor/c_exception/vendor/unity/Gemfile +4 -0
  339. data/vendor/cmock/vendor/c_exception/vendor/unity/Gemfile.lock +12 -0
  340. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/colour_prompt.rb +115 -0
  341. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/colour_reporter.rb +39 -0
  342. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_config.yml +36 -0
  343. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_module.rb +202 -0
  344. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +320 -0
  345. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/parseOutput.rb +189 -0
  346. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/test_file_filter.rb +23 -0
  347. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/unity_test_summary.rb +139 -0
  348. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/Unity Summary.odt +0 -0
  349. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/Unity Summary.pdf +0 -0
  350. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/Unity Summary.txt +216 -0
  351. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/license.txt +31 -0
  352. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/makefile +41 -0
  353. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/readme.txt +5 -0
  354. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode.c +24 -0
  355. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode.h +3 -0
  356. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.c +9 -0
  357. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.h +2 -0
  358. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/TestProductionCode.c +62 -0
  359. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/TestProductionCode2.c +31 -0
  360. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +46 -0
  361. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +50 -0
  362. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/makefile +45 -0
  363. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/readme.txt +5 -0
  364. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode.c +24 -0
  365. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode.h +3 -0
  366. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode2.c +9 -0
  367. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode2.h +2 -0
  368. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/test/TestProductionCode.c +64 -0
  369. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/test/TestProductionCode2.c +33 -0
  370. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +9 -0
  371. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +11 -0
  372. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/all_tests.c +12 -0
  373. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/helper/UnityHelper.c +10 -0
  374. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/helper/UnityHelper.h +12 -0
  375. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/makefile +41 -0
  376. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/rakefile.rb +44 -0
  377. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/rakefile_helper.rb +256 -0
  378. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/readme.txt +19 -0
  379. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode.c +24 -0
  380. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode.h +3 -0
  381. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode2.c +9 -0
  382. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode2.h +2 -0
  383. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/target_gcc_32.yml +46 -0
  384. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/test/TestProductionCode.c +62 -0
  385. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/test/TestProductionCode2.c +31 -0
  386. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c +46 -0
  387. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode_Runner.c +50 -0
  388. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/eclipse/error_parsers.txt +26 -0
  389. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/rakefile.rb +37 -0
  390. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/rakefile_helper.rb +179 -0
  391. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/readme.txt +9 -0
  392. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +387 -0
  393. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +82 -0
  394. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +44 -0
  395. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +16 -0
  396. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/main/AllTests.c +21 -0
  397. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/testunity_fixture.c +39 -0
  398. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +341 -0
  399. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +41 -0
  400. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +56 -0
  401. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +17 -0
  402. data/vendor/cmock/vendor/c_exception/vendor/unity/makefile +37 -0
  403. data/vendor/cmock/vendor/c_exception/vendor/unity/rakefile.rb +61 -0
  404. data/vendor/cmock/vendor/c_exception/vendor/unity/rakefile_helper.rb +249 -0
  405. data/vendor/cmock/vendor/c_exception/vendor/unity/release/build.info +2 -0
  406. data/vendor/cmock/vendor/c_exception/vendor/unity/release/version.info +2 -0
  407. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.c +1145 -0
  408. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.h +307 -0
  409. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity_internals.h +620 -0
  410. data/vendor/cmock/vendor/c_exception/vendor/unity/targets/clang_strict.yml +83 -0
  411. data/vendor/cmock/vendor/c_exception/vendor/unity/targets/gcc_32.yml +44 -0
  412. data/vendor/cmock/vendor/c_exception/vendor/unity/targets/gcc_64.yml +45 -0
  413. data/vendor/cmock/vendor/c_exception/vendor/unity/targets/hitech_picc18.yml +101 -0
  414. data/vendor/cmock/vendor/c_exception/vendor/unity/targets/iar_arm_v4.yml +89 -0
  415. data/vendor/cmock/vendor/c_exception/vendor/unity/targets/iar_arm_v5.yml +79 -0
  416. data/vendor/cmock/vendor/c_exception/vendor/unity/targets/iar_arm_v5_3.yml +79 -0
  417. data/vendor/cmock/vendor/c_exception/vendor/unity/targets/iar_armcortex_LM3S9B92_v5_4.yml +93 -0
  418. data/vendor/cmock/vendor/c_exception/vendor/unity/targets/iar_cortexm3_v5.yml +83 -0
  419. data/vendor/cmock/vendor/c_exception/vendor/unity/targets/iar_msp430.yml +94 -0
  420. data/vendor/cmock/vendor/c_exception/vendor/unity/targets/iar_sh2a_v6.yml +85 -0
  421. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_cmd.c +57 -0
  422. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_def.c +53 -0
  423. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_cmd.c +79 -0
  424. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_def.c +75 -0
  425. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new1.c +88 -0
  426. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new2.c +88 -0
  427. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_param.c +76 -0
  428. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run1.c +88 -0
  429. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run2.c +88 -0
  430. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_yaml.c +89 -0
  431. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_new1.c +63 -0
  432. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_new2.c +66 -0
  433. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_param.c +54 -0
  434. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_run1.c +63 -0
  435. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_run2.c +66 -0
  436. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_yaml.c +67 -0
  437. data/vendor/cmock/vendor/c_exception/vendor/unity/test/test_generate_test_runner.rb +88 -0
  438. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/mocksample.c +51 -0
  439. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/sample.yml +9 -0
  440. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/testsample.c +51 -0
  441. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testparameterized.c +101 -0
  442. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testunity.c +3447 -0
  443. data/vendor/cmock/vendor/unity/README.md +211 -0
  444. data/vendor/cmock/vendor/unity/auto/colour_prompt.rb +115 -0
  445. data/vendor/cmock/vendor/unity/auto/colour_reporter.rb +39 -0
  446. data/vendor/cmock/vendor/unity/auto/generate_config.yml +36 -0
  447. data/vendor/cmock/vendor/unity/auto/generate_module.rb +202 -0
  448. data/vendor/cmock/vendor/unity/auto/generate_test_runner.rb +374 -0
  449. data/vendor/cmock/vendor/unity/auto/parseOutput.rb +191 -0
  450. data/vendor/cmock/vendor/unity/auto/test_file_filter.rb +23 -0
  451. data/vendor/cmock/vendor/unity/auto/type_sanitizer.rb +8 -0
  452. data/vendor/cmock/vendor/unity/auto/unity_test_summary.py +135 -0
  453. data/vendor/cmock/vendor/unity/auto/unity_test_summary.rb +148 -0
  454. data/vendor/cmock/vendor/unity/docs/Unity Summary.odt +0 -0
  455. data/vendor/cmock/vendor/unity/docs/Unity Summary.pdf +0 -0
  456. data/vendor/cmock/vendor/unity/docs/Unity Summary.txt +224 -0
  457. data/vendor/cmock/vendor/unity/docs/license.txt +21 -0
  458. data/vendor/{unity/examples/example_3 → cmock/vendor/unity/examples/example_1}/makefile +9 -5
  459. data/vendor/cmock/vendor/unity/examples/example_1/readme.txt +5 -0
  460. data/vendor/cmock/vendor/unity/examples/example_1/src/ProductionCode.c +24 -0
  461. data/vendor/cmock/vendor/unity/examples/example_1/src/ProductionCode.h +3 -0
  462. data/vendor/cmock/vendor/unity/examples/example_1/src/ProductionCode2.c +11 -0
  463. data/vendor/cmock/vendor/unity/examples/example_1/src/ProductionCode2.h +2 -0
  464. data/vendor/cmock/vendor/unity/examples/example_1/test/TestProductionCode.c +62 -0
  465. data/vendor/cmock/vendor/unity/examples/example_1/test/TestProductionCode2.c +31 -0
  466. data/vendor/cmock/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -0
  467. data/vendor/cmock/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -0
  468. data/vendor/cmock/vendor/unity/examples/example_2/makefile +71 -0
  469. data/vendor/cmock/vendor/unity/examples/example_2/readme.txt +5 -0
  470. data/vendor/cmock/vendor/unity/examples/example_2/src/ProductionCode.c +24 -0
  471. data/vendor/cmock/vendor/unity/examples/example_2/src/ProductionCode.h +3 -0
  472. data/vendor/cmock/vendor/unity/examples/example_2/src/ProductionCode2.c +11 -0
  473. data/vendor/cmock/vendor/unity/examples/example_2/src/ProductionCode2.h +2 -0
  474. data/vendor/cmock/vendor/unity/examples/example_2/test/TestProductionCode.c +64 -0
  475. data/vendor/cmock/vendor/unity/examples/example_2/test/TestProductionCode2.c +33 -0
  476. data/vendor/cmock/vendor/unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +9 -0
  477. data/vendor/cmock/vendor/unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +11 -0
  478. data/vendor/cmock/vendor/unity/examples/example_2/test/test_runners/all_tests.c +12 -0
  479. data/vendor/cmock/vendor/unity/examples/example_3/helper/UnityHelper.c +10 -0
  480. data/vendor/cmock/vendor/unity/examples/example_3/helper/UnityHelper.h +12 -0
  481. data/vendor/cmock/vendor/unity/examples/example_3/rakefile.rb +43 -0
  482. data/vendor/cmock/vendor/unity/examples/example_3/rakefile_helper.rb +256 -0
  483. data/vendor/cmock/vendor/unity/examples/example_3/readme.txt +19 -0
  484. data/vendor/cmock/vendor/unity/examples/example_3/src/ProductionCode.c +24 -0
  485. data/vendor/cmock/vendor/unity/examples/example_3/src/ProductionCode.h +3 -0
  486. data/vendor/cmock/vendor/unity/examples/example_3/src/ProductionCode2.c +11 -0
  487. data/vendor/cmock/vendor/unity/examples/example_3/src/ProductionCode2.h +2 -0
  488. data/vendor/cmock/vendor/unity/examples/example_3/target_gcc_32.yml +46 -0
  489. data/vendor/cmock/vendor/unity/examples/example_3/test/TestProductionCode.c +62 -0
  490. data/vendor/cmock/vendor/unity/examples/example_3/test/TestProductionCode2.c +31 -0
  491. data/vendor/cmock/vendor/unity/extras/eclipse/error_parsers.txt +26 -0
  492. data/vendor/cmock/vendor/unity/extras/fixture/rakefile.rb +48 -0
  493. data/vendor/cmock/vendor/unity/extras/fixture/rakefile_helper.rb +179 -0
  494. data/vendor/cmock/vendor/unity/extras/fixture/readme.txt +9 -0
  495. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.c +423 -0
  496. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.h +78 -0
  497. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_internals.h +46 -0
  498. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +45 -0
  499. data/vendor/cmock/vendor/unity/extras/fixture/test/Makefile +19 -0
  500. data/vendor/cmock/vendor/unity/extras/fixture/test/main/AllTests.c +21 -0
  501. data/vendor/cmock/vendor/unity/extras/fixture/test/testunity_fixture.c +39 -0
  502. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_Test.c +373 -0
  503. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +43 -0
  504. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_output_Spy.c +57 -0
  505. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_output_Spy.h +17 -0
  506. data/vendor/cmock/vendor/unity/release/build.info +2 -0
  507. data/vendor/cmock/vendor/unity/release/version.info +2 -0
  508. data/vendor/cmock/vendor/unity/src/unity.c +1324 -0
  509. data/vendor/cmock/vendor/unity/src/unity.h +285 -0
  510. data/vendor/cmock/vendor/unity/src/unity_internals.h +758 -0
  511. data/vendor/cmock/vendor/unity/test/expectdata/testsample_cmd.c +57 -0
  512. data/vendor/cmock/vendor/unity/test/expectdata/testsample_def.c +53 -0
  513. data/vendor/cmock/vendor/unity/test/expectdata/testsample_head1.c +51 -0
  514. data/vendor/cmock/vendor/unity/test/expectdata/testsample_head1.h +12 -0
  515. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_cmd.c +80 -0
  516. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_def.c +76 -0
  517. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_head1.c +75 -0
  518. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_head1.h +11 -0
  519. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_new1.c +89 -0
  520. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_new2.c +89 -0
  521. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_param.c +77 -0
  522. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_run1.c +89 -0
  523. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_run2.c +89 -0
  524. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_yaml.c +90 -0
  525. data/vendor/cmock/vendor/unity/test/expectdata/testsample_new1.c +63 -0
  526. data/vendor/cmock/vendor/unity/test/expectdata/testsample_new2.c +66 -0
  527. data/vendor/cmock/vendor/unity/test/expectdata/testsample_param.c +54 -0
  528. data/vendor/cmock/vendor/unity/test/expectdata/testsample_run1.c +63 -0
  529. data/vendor/cmock/vendor/unity/test/expectdata/testsample_run2.c +66 -0
  530. data/vendor/cmock/vendor/unity/test/expectdata/testsample_yaml.c +67 -0
  531. data/vendor/cmock/vendor/unity/test/rakefile +60 -0
  532. data/vendor/cmock/vendor/unity/test/rakefile_helper.rb +255 -0
  533. data/vendor/cmock/vendor/unity/test/targets/clang_file.yml +84 -0
  534. data/vendor/cmock/vendor/unity/test/targets/clang_strict.yml +84 -0
  535. data/vendor/cmock/vendor/unity/test/targets/gcc_32.yml +50 -0
  536. data/vendor/cmock/vendor/unity/test/targets/gcc_64.yml +51 -0
  537. data/vendor/cmock/vendor/unity/test/targets/gcc_auto_limits.yml +47 -0
  538. data/vendor/cmock/vendor/unity/test/targets/gcc_auto_sizeof.yml +48 -0
  539. data/vendor/cmock/vendor/unity/test/targets/gcc_auto_stdint.yml +59 -0
  540. data/vendor/cmock/vendor/unity/test/targets/gcc_manual_math.yml +47 -0
  541. data/vendor/cmock/vendor/unity/test/targets/hitech_picc18.yml +101 -0
  542. data/vendor/cmock/vendor/unity/test/targets/iar_arm_v4.yml +89 -0
  543. data/vendor/cmock/vendor/unity/test/targets/iar_arm_v5.yml +79 -0
  544. data/vendor/cmock/vendor/unity/test/targets/iar_arm_v5_3.yml +79 -0
  545. data/vendor/cmock/vendor/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +93 -0
  546. data/vendor/cmock/vendor/unity/test/targets/iar_cortexm3_v5.yml +83 -0
  547. data/vendor/cmock/vendor/unity/test/targets/iar_msp430.yml +94 -0
  548. data/vendor/cmock/vendor/unity/test/targets/iar_sh2a_v6.yml +85 -0
  549. data/vendor/cmock/vendor/unity/test/testdata/mocksample.c +51 -0
  550. data/vendor/cmock/vendor/unity/test/testdata/sample.yml +9 -0
  551. data/vendor/cmock/vendor/unity/test/testdata/testsample.c +51 -0
  552. data/vendor/cmock/vendor/unity/test/tests/test_generate_test_runner.rb +102 -0
  553. data/vendor/cmock/vendor/unity/test/tests/testparameterized.c +104 -0
  554. data/vendor/cmock/vendor/unity/test/tests/testunity.c +3656 -0
  555. data/vendor/unity/README.md +211 -203
  556. data/vendor/unity/auto/colour_reporter.rb +38 -38
  557. data/vendor/unity/auto/generate_config.yml +36 -36
  558. data/vendor/unity/auto/generate_module.rb +202 -202
  559. data/vendor/unity/auto/generate_test_runner.rb +389 -347
  560. data/vendor/unity/auto/parseOutput.rb +2 -0
  561. data/vendor/unity/auto/unity_test_summary.py +135 -135
  562. data/vendor/unity/auto/unity_test_summary.rb +148 -139
  563. data/vendor/unity/docs/Unity Summary.odt +0 -0
  564. data/vendor/unity/docs/Unity Summary.pdf +0 -0
  565. data/vendor/unity/docs/Unity Summary.txt +224 -216
  566. data/vendor/unity/docs/license.txt +21 -21
  567. data/vendor/unity/examples/example_1/makefile +7 -3
  568. data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +29 -9
  569. data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +26 -6
  570. data/vendor/unity/examples/example_2/makefile +7 -4
  571. data/vendor/unity/extras/fixture/rakefile.rb +48 -48
  572. data/vendor/unity/extras/fixture/rakefile_helper.rb +179 -179
  573. data/vendor/unity/extras/fixture/src/unity_fixture.c +123 -78
  574. data/vendor/unity/extras/fixture/src/unity_fixture.h +6 -14
  575. data/vendor/unity/extras/fixture/src/unity_fixture_internals.h +12 -15
  576. data/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +25 -0
  577. data/vendor/unity/extras/fixture/test/Makefile +35 -0
  578. data/vendor/unity/extras/fixture/test/main/AllTests.c +2 -1
  579. data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +99 -4
  580. data/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +10 -0
  581. data/vendor/unity/extras/fixture/test/unity_output_Spy.c +3 -1
  582. data/vendor/unity/release/build.info +1 -1
  583. data/vendor/unity/release/version.info +1 -1
  584. data/vendor/unity/src/unity.c +1324 -1177
  585. data/vendor/unity/src/unity.h +285 -272
  586. data/vendor/unity/src/unity_internals.h +758 -692
  587. data/vendor/unity/test/expectdata/testsample_head1.c +51 -0
  588. data/vendor/unity/test/expectdata/testsample_head1.h +12 -0
  589. data/vendor/unity/test/expectdata/testsample_mock_cmd.c +1 -0
  590. data/vendor/unity/test/expectdata/testsample_mock_def.c +1 -0
  591. data/vendor/unity/test/expectdata/testsample_mock_head1.c +75 -0
  592. data/vendor/unity/test/expectdata/testsample_mock_head1.h +11 -0
  593. data/vendor/unity/test/expectdata/testsample_mock_new1.c +3 -2
  594. data/vendor/unity/test/expectdata/testsample_mock_new2.c +1 -0
  595. data/vendor/unity/test/expectdata/testsample_mock_param.c +1 -0
  596. data/vendor/unity/test/expectdata/testsample_mock_run1.c +3 -2
  597. data/vendor/unity/test/expectdata/testsample_mock_run2.c +1 -0
  598. data/vendor/unity/test/expectdata/testsample_mock_yaml.c +4 -3
  599. data/vendor/unity/test/expectdata/testsample_new1.c +2 -2
  600. data/vendor/unity/test/expectdata/testsample_run1.c +2 -2
  601. data/vendor/unity/test/expectdata/testsample_yaml.c +3 -3
  602. data/vendor/unity/test/rakefile +60 -60
  603. data/vendor/unity/test/rakefile_helper.rb +255 -249
  604. data/vendor/unity/test/targets/clang_file.yml +83 -0
  605. data/vendor/unity/test/targets/clang_strict.yml +83 -83
  606. data/vendor/unity/test/targets/gcc_32.yml +49 -49
  607. data/vendor/unity/test/targets/gcc_64.yml +50 -50
  608. data/vendor/unity/test/targets/gcc_auto_limits.yml +46 -46
  609. data/vendor/unity/test/targets/gcc_auto_sizeof.yml +47 -47
  610. data/vendor/unity/test/targets/gcc_auto_stdint.yml +58 -58
  611. data/vendor/unity/test/targets/gcc_manual_math.yml +46 -0
  612. data/vendor/unity/test/targets/hitech_picc18.yml +101 -101
  613. data/vendor/unity/test/targets/iar_arm_v4.yml +89 -89
  614. data/vendor/unity/test/targets/iar_arm_v5.yml +79 -79
  615. data/vendor/unity/test/targets/iar_arm_v5_3.yml +79 -79
  616. data/vendor/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +93 -93
  617. data/vendor/unity/test/targets/iar_cortexm3_v5.yml +83 -83
  618. data/vendor/unity/test/targets/iar_msp430.yml +94 -94
  619. data/vendor/unity/test/targets/iar_sh2a_v6.yml +85 -85
  620. data/vendor/unity/test/testdata/mocksample.c +51 -51
  621. data/vendor/unity/test/testdata/sample.yml +8 -8
  622. data/vendor/unity/test/testdata/testsample.c +51 -51
  623. data/vendor/unity/test/tests/test_generate_test_runner.rb +102 -88
  624. data/vendor/unity/test/tests/testparameterized.c +104 -101
  625. data/vendor/unity/test/tests/testunity.c +3676 -3447
  626. metadata +549 -191
@@ -1,1337 +1,1381 @@
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
- $QUICK_RUBY_VERSION = RUBY_VERSION.split('.').inject(0){|vv,v| vv * 100 + v.to_i }
9
-
10
- require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
11
- require 'cmock_header_parser'
12
-
13
- describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
14
-
15
- before do
16
- create_mocks :config
17
- @test_name = 'test_file.h'
18
- @config.expect :strippables, ["STRIPPABLE"]
19
- @config.expect :attributes, ['__ramfunc', 'funky_attrib', 'SQLITE_API']
20
- @config.expect :c_calling_conventions, ['__stdcall']
21
- @config.expect :treat_as_void, ['MY_FUNKY_VOID']
22
- @config.expect :treat_as, { "BANJOS" => "INT", "TUBAS" => "HEX16"}
23
- @config.expect :when_no_prototypes, :error
24
- @config.expect :verbosity, 1
25
- @config.expect :treat_externs, :exclude
26
-
27
- @parser = CMockHeaderParser.new(@config)
28
- end
29
-
30
- after do
31
- end
32
-
33
- it "create and initialize variables to defaults appropriately" do
34
- assert_equal([], @parser.funcs)
35
- assert_equal(['const', '__ramfunc', 'funky_attrib', 'SQLITE_API'], @parser.c_attributes)
36
- assert_equal(['void','MY_FUNKY_VOID'], @parser.treat_as_void)
37
- end
38
-
39
- it "strip out line comments" do
40
- source =
41
- " abcd;\n" +
42
- "// hello;\n" +
43
- "who // is you\n"
44
-
45
- expected =
46
- [
47
- "abcd",
48
- "who"
49
- ]
50
-
51
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
52
- end
53
-
54
- it "remove block comments" do
55
- source =
56
- " no_comments;\n" +
57
- "// basic_line_comment;\n" +
58
- "/* basic_block_comment;*/\n" +
59
- "pre_block; /* start_of_block_comment;\n" +
60
- "// embedded_line_comment_in_block_comment; */\n" +
61
- "// /* commented_out_block_comment_line\n" +
62
- "shown_because_block_comment_invalid_from_line_comment;\n" +
63
- "// */\n" +
64
- "//* shorter_commented_out_block_comment_line; \n" +
65
- "shown_because_block_comment_invalid_from_shorter_line_comment;\n" +
66
- "/*/\n" +
67
- "not_shown_because_line_above_started_comment;\n" +
68
- "//*/\n" +
69
- "/* \n" +
70
- "not_shown_because_block_comment_started_this_time;\n" +
71
- "/*/\n" +
72
- "shown_because_line_above_ended_comment_this_time;\n" +
73
- "//*/\n"
74
-
75
- expected =
76
- [
77
- "no_comments",
78
- "pre_block",
79
- "shown_because_block_comment_invalid_from_line_comment",
80
- "shown_because_block_comment_invalid_from_shorter_line_comment",
81
- "shown_because_line_above_ended_comment_this_time"
82
- ]
83
-
84
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
85
- end
86
-
87
- it "remove strippables from the beginning or end of function declarations" do
88
- source =
89
- "void* my_calloc(size_t, size_t) STRIPPABLE;\n" +
90
- "void\n" +
91
- " my_realloc(void*, size_t) STRIPPABLE;\n" +
92
- "extern int\n" +
93
- " my_printf (void *my_object, const char *my_format, ...)\n" +
94
- " STRIPPABLE;\n" +
95
- " void STRIPPABLE universal_handler ();\n"
96
-
97
- expected =
98
- [
99
- "void* my_calloc(size_t, size_t)",
100
- "void my_realloc(void*, size_t)",
101
- "void universal_handler()"
102
- ]
103
-
104
- assert_equal(expected, @parser.import_source(source))
105
- end
106
-
107
- it "remove gcc's function __attribute__'s" do
108
- source =
109
- "void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)));\n" +
110
- "void\n" +
111
- " my_realloc(void*, size_t) __attribute__((alloc_size(2)));\n" +
112
- "extern int\n" +
113
- " my_printf (void *my_object, const char *my_format, ...)\n" +
114
- " __attribute__ ((format (printf, 2, 3)));\n" +
115
- " void __attribute__ ((interrupt)) universal_handler ();\n"
116
-
117
- expected =
118
- [
119
- "void* my_calloc(size_t, size_t)",
120
- "void my_realloc(void*, size_t)",
121
- "void universal_handler()"
122
- ]
123
-
124
- assert_equal(expected, @parser.import_source(source))
125
- end
126
-
127
- it "remove preprocessor directives" do
128
- source =
129
- "#when stuff_happens\n" +
130
- "#ifdef _TEST\n" +
131
- "#pragma stack_switch"
132
-
133
- expected = []
134
-
135
- assert_equal(expected, @parser.import_source(source))
136
- end
137
-
138
-
139
- it "remove assembler pragma sections" do
140
- source =
141
- " #pragma\tasm\n" +
142
- " .foo\n" +
143
- " lda %m\n" +
144
- " nop\n" +
145
- "# pragma endasm \n" +
146
- "foo"
147
-
148
- expected = ["foo"]
149
-
150
- assert_equal(expected, @parser.import_source(source))
151
- end
152
-
153
-
154
- it "smush lines together that contain continuation characters" do
155
- source =
156
- "hoo hah \\\n" +
157
- "when \\ \n"
158
-
159
- expected =
160
- [
161
- "hoo hah when"
162
- ]
163
-
164
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
165
- end
166
-
167
-
168
- it "remove C macro definitions" do
169
- source =
170
- "#define this is the first line\\\n" +
171
- "and the second\\\n" +
172
- "and the third that should be removed\n" +
173
- "but I'm here\n"
174
-
175
- expected = ["but I'm here"]
176
-
177
- assert_equal(expected, @parser.import_source(source))
178
- end
179
-
180
-
181
- it "remove typedef statements" do
182
- source =
183
- "typedef uint32 (unsigned int);\n" +
184
- "const typedef int INT;\n" +
185
- "int notatypedef;\n" +
186
- "int typedef_isnt_me;\n" +
187
- " typedef who cares what really comes here \n" + # exercise multiline typedef
188
- " continuation;\n" +
189
- "this should remain!;\n" +
190
- "typedef blah bleh;\n" +
191
- "typedef struct shell_command_struct {\n" +
192
- " char_ptr COMMAND;\n" +
193
- " int_32 (*SHELL_FUNC)(int_32 argc);\n" +
194
- "} SHELL_COMMAND_STRUCT, * SHELL_COMMAND_PTR;\n" +
195
- "typedef struct shell_command_struct {\n" +
196
- " char_ptr COMMAND;\n" +
197
- " int_32 (*SHELL_FUNC)(int_32 argc, char_ptr argv[]);\n" +
198
- "} SHELL_COMMAND_STRUCT, * SHELL_COMMAND_PTR;\n" +
199
- "typedef struct shell_command_struct {\n" +
200
- " char_ptr COMMAND;\n" +
201
- " int_32 (*SHELL_FUNC)(int_32 argc);\n" +
202
- "};\n"
203
-
204
- expected =
205
- [
206
- "int notatypedef",
207
- "int typedef_isnt_me",
208
- "this should remain!"
209
- ]
210
-
211
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
212
- end
213
-
214
-
215
- it "remove enum statements" do
216
- source =
217
- "enum _NamedEnum {\n" +
218
- " THING1 = (0x0001),\n" +
219
- " THING2 = (0x0001 << 5),\n" +
220
- "}ListOValues;\n\n" +
221
- "don't delete me!!\n" +
222
- " modifier_str enum _NamedEnum {THING1 = (0x0001), THING2 = (0x0001 << 5)} ListOValues;\n\n" +
223
- "typedef enum {\n" +
224
- " THING1,\n" +
225
- " THING2,\n" +
226
- "} Thinger;\n" +
227
- "or me!!\n"
228
-
229
- assert_equal(["don't delete me!! or me!!"], @parser.import_source(source).map!{|s|s.strip})
230
- end
231
-
232
-
233
- it "remove union statements" do
234
- source =
235
- "union _NamedDoohicky {\n" +
236
- " unsigned int a;\n" +
237
- " char b;\n" +
238
- "} Doohicky;\n\n" +
239
- "I want to live!!\n" +
240
- "some_modifier union { unsigned int a; char b;} Whatever;\n" +
241
- "typedef union {\n" +
242
- " unsigned int a;\n" +
243
- " char b;\n" +
244
- "} Whatever;\n" +
245
- "me too!!\n"
246
-
247
- assert_equal(["I want to live!! me too!!"], @parser.import_source(source).map!{|s|s.strip})
248
- end
249
-
250
-
251
- it "remove struct statements" do
252
- source =
253
- "struct _NamedStruct1 {\n" +
254
- " unsigned int a;\n" +
255
- " signed long int b;\n" +
256
- "} Thing ;\n\n" +
257
- "extern struct ForwardDeclared_t TestDataType1;\n" +
258
- "void foo(void);\n" +
259
- "struct\n"+
260
- " MultilineForwardDeclared_t\n" +
261
- " TestDataType2;\n" +
262
- "struct THINGER foo(void);\n" +
263
- "typedef struct {\n" +
264
- " unsigned int a;\n" +
265
- " signed char b;\n" +
266
- "}Thinger;\n" +
267
- "I want to live!!\n"
268
-
269
- assert_equal(["void foo(void)", "struct THINGER foo(void)", "I want to live!!"],
270
- @parser.import_source(source).map!{|s|s.strip})
271
- end
272
-
273
- it "remove externed and inline functions" do
274
- source =
275
- " extern uint32 foobar(unsigned int);\n" +
276
- "uint32 extern_name_func(unsigned int);\n" +
277
- "uint32 funcinline(unsigned int);\n" +
278
- "extern void bar(unsigned int);\n" +
279
- "inline void bar(unsigned int);\n" +
280
- "extern\n" +
281
- "void kinda_ugly_on_the_next_line(unsigned int);\n"
282
-
283
- expected =
284
- [
285
- "uint32 extern_name_func(unsigned int)",
286
- "uint32 funcinline(unsigned int)"
287
- ]
288
-
289
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
290
- end
291
-
292
- it "remove function definitions but keep function declarations" do
293
- source =
294
- "uint32 func_with_decl_a(unsigned int);\n" +
295
- "uint32 func_with_decl_a(unsigned int a) { return a; }\n" +
296
- "uint32 func_with_decl_b(unsigned int);\n" +
297
- "uint32 func_with_decl_b(unsigned int a)\n" +
298
- "{\n" +
299
- " bar((unsigned int) a);\n" +
300
- " stripme(a);\n" +
301
- "}\n"
302
-
303
- expected =
304
- [
305
- "uint32 func_with_decl_a(unsigned int)",
306
- "uint32 func_with_decl_a", #okay. it's not going to be interpretted as another function
307
- "uint32 func_with_decl_b(unsigned int)",
308
- "uint32 func_with_decl_b", #okay. it's not going to be interpretted as another function
309
- ]
310
-
311
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
312
- end
313
-
314
- it "remove a fully defined inline function" do
315
- source =
316
- "inline void foo(unsigned int a) { oranges = a; }\n" +
317
- "inline void bar(unsigned int a) { apples = a; };\n" +
318
- "inline void bar(unsigned int a)\n" +
319
- "{" +
320
- " bananas = a;\n" +
321
- "}"
322
-
323
- # ensure it's expected type of exception
324
- assert_raises RuntimeError do
325
- @parser.parse("module", source)
326
- end
327
-
328
- assert_equal([], @parser.funcs)
329
-
330
- # verify exception message
331
- begin
332
- @parser.parse("module", source)
333
- rescue RuntimeError => e
334
- assert_equal("ERROR: No function prototypes found!", e.message)
335
- end
336
- end
337
-
338
- it "remove a fully defined inline function that is multiple lines" do
339
- source =
340
- "inline void bar(unsigned int a)\n" +
341
- "{" +
342
- " bananas = a;\n" +
343
- " grapes = a;\n" +
344
- " apples(bananas, grapes);\n" +
345
- "}"
346
-
347
- # ensure it's expected type of exception
348
- assert_raises RuntimeError do
349
- @parser.parse("module", source)
350
- end
351
-
352
- assert_equal([], @parser.funcs)
353
-
354
- # verify exception message
355
- begin
356
- @parser.parse("module", source)
357
- rescue RuntimeError => e
358
- assert_equal("ERROR: No function prototypes found!", e.message)
359
- end
360
- end
361
-
362
- it "remove just inline functions if externs to be included" do
363
- source =
364
- " extern uint32 foobar(unsigned int);\n" +
365
- "uint32 extern_name_func(unsigned int);\n" +
366
- "uint32 funcinline(unsigned int);\n" +
367
- "extern void bar(unsigned int);\n" +
368
- "inline void bar(unsigned int);\n" +
369
- "extern\n" +
370
- "void kinda_ugly_on_the_next_line(unsigned int);\n"
371
-
372
- expected =
373
- [ "extern uint32 foobar(unsigned int)",
374
- "uint32 extern_name_func(unsigned int)",
375
- "uint32 funcinline(unsigned int)",
376
- "extern void bar(unsigned int)",
377
- "extern void kinda_ugly_on_the_next_line(unsigned int)"
378
- ]
379
-
380
- @parser.treat_externs = :include
381
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
382
- end
383
-
384
-
385
- it "remove defines" do
386
- source =
387
- "#define whatever you feel like defining\n" +
388
- "void hello(void);\n" +
389
- "#DEFINE I JUST DON'T CARE\n" +
390
- "#deFINE\n" +
391
- "#define get_foo() \\\n ((Thing)foo.bar)" # exercise multiline define
392
-
393
- expected =
394
- [
395
- "void hello(void)",
396
- ]
397
-
398
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
399
- end
400
-
401
-
402
- it "remove keywords that would keep things from going smoothly in the future" do
403
- source =
404
- "const int TheMatrix(register int Trinity, unsigned int *restrict Neo)"
405
-
406
- expected =
407
- [
408
- "const int TheMatrix(int Trinity, unsigned int * Neo)",
409
- ]
410
-
411
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
412
- end
413
-
414
-
415
- # some code actually typedef's void even though it's not ANSI C and is, frankly, weird
416
- # since cmock treats void specially, we can't let void be obfuscated
417
- it "handle odd case of typedef'd void returned" do
418
- source = "MY_FUNKY_VOID FunkyVoidReturned(int a)"
419
- expected = { :var_arg=>nil,
420
- :name=>"FunkyVoidReturned",
421
- :return=>{ :type => "void",
422
- :name => 'cmock_to_return',
423
- :ptr? => false,
424
- :const? => false,
425
- :str => "void cmock_to_return",
426
- :void? => true
427
- },
428
- :modifier=>"",
429
- :contains_ptr? => false,
430
- :args=>[{:type=>"int", :name=>"a", :ptr? => false, :const? => false}],
431
- :args_string=>"int a",
432
- :args_call=>"a"}
433
- assert_equal(expected, @parser.parse_declaration(source))
434
- end
435
-
436
- it "handle odd case of typedef'd void as arg" do
437
- source = "int FunkyVoidAsArg(MY_FUNKY_VOID)"
438
- expected = { :var_arg=>nil,
439
- :name=>"FunkyVoidAsArg",
440
- :return=>{ :type => "int",
441
- :name => 'cmock_to_return',
442
- :ptr? => false,
443
- :const? => false,
444
- :str => "int cmock_to_return",
445
- :void? => false
446
- },
447
- :modifier=>"",
448
- :contains_ptr? => false,
449
- :args=>[],
450
- :args_string=>"void",
451
- :args_call=>"" }
452
- assert_equal(expected, @parser.parse_declaration(source))
453
- end
454
-
455
- it "handle odd case of typedef'd void as arg pointer" do
456
- source = "char FunkyVoidPointer(MY_FUNKY_VOID* bluh)"
457
- expected = { :var_arg=>nil,
458
- :name=>"FunkyVoidPointer",
459
- :return=>{ :type => "char",
460
- :name => 'cmock_to_return',
461
- :ptr? => false,
462
- :const? => false,
463
- :str => "char cmock_to_return",
464
- :void? => false
465
- },
466
- :modifier=>"",
467
- :contains_ptr? => true,
468
- :args=>[{:type=>"MY_FUNKY_VOID*", :name=>"bluh", :ptr? => true, :const? => false}],
469
- :args_string=>"MY_FUNKY_VOID* bluh",
470
- :args_call=>"bluh" }
471
- assert_equal(expected, @parser.parse_declaration(source))
472
- end
473
-
474
-
475
- it "strip default values from function parameter lists" do
476
- source =
477
- "void Foo(int a = 57, float b=37.52, char c= 'd', char* e=\"junk\");\n"
478
-
479
- expected =
480
- [
481
- "void Foo(int a, float b, char c, char* e)"
482
- ]
483
-
484
- assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
485
- end
486
-
487
-
488
- it "raise upon empty file" do
489
- source = ''
490
-
491
- # ensure it's expected type of exception
492
- assert_raises RuntimeError do
493
- @parser.parse("module", source)
494
- end
495
-
496
- assert_equal([], @parser.funcs)
497
-
498
- # verify exception message
499
- begin
500
- @parser.parse("module", source)
501
- rescue RuntimeError => e
502
- assert_equal("ERROR: No function prototypes found!", e.message)
503
- end
504
- end
505
-
506
- it "clean up module names that contain spaces, dashes, and such" do
507
- source = 'void meh(int (*func)(int));'
508
-
509
- retval = @parser.parse("C:\Ugly Module-Name", source)
510
- assert (retval[:typedefs][0] =~ /CUglyModuleName/)
511
- end
512
-
513
- it "raise upon no function prototypes found in file" do
514
- source =
515
- "typedef void SILLY_VOID_TYPE1;\n" +
516
- "typedef (void) SILLY_VOID_TYPE2 ;\n" +
517
- "typedef ( void ) (*FUNCPTR)(void);\n\n" +
518
- "#define get_foo() \\\n ((Thing)foo.bar)"
519
-
520
- # ensure it's expected type of exception
521
- assert_raises(RuntimeError) do
522
- @parser.parse("module", source)
523
- end
524
-
525
- assert_equal([], @parser.funcs)
526
-
527
- # verify exception message
528
- begin
529
- @parser.parse("module", source)
530
- rescue RuntimeError => e
531
- assert_equal("ERROR: No function prototypes found!", e.message)
532
- end
533
- end
534
-
535
-
536
- it "raise upon prototype parsing failure" do
537
- source = "void (int, )"
538
-
539
- # ensure it's expected type of exception
540
- assert_raises(RuntimeError) do
541
- @parser.parse("module", source)
542
- end
543
-
544
- # verify exception message
545
- begin
546
- @parser.parse("module", source)
547
- rescue RuntimeError => e
548
- assert(e.message.include?("Failed Parsing Declaration Prototype!"))
549
- end
550
- end
551
-
552
- it "extract and return function declarations with retval and args" do
553
-
554
- source = "int Foo(int a, unsigned int b)"
555
- expected = { :var_arg=>nil,
556
- :name=>"Foo",
557
- :return=>{ :type => "int",
558
- :name => 'cmock_to_return',
559
- :ptr? => false,
560
- :const? => false,
561
- :str => "int cmock_to_return",
562
- :void? => false
563
- },
564
- :modifier=>"",
565
- :contains_ptr? => false,
566
- :args=>[ {:type=>"int", :name=>"a", :ptr? => false, :const? => false},
567
- {:type=>"unsigned int", :name=>"b", :ptr? => false, :const? => false}
568
- ],
569
- :args_string=>"int a, unsigned int b",
570
- :args_call=>"a, b" }
571
- assert_equal(expected, @parser.parse_declaration(source))
572
- end
573
-
574
- it "extract and return function declarations with no retval" do
575
-
576
- source = "void FunkyChicken( uint la, int de, bool da)"
577
- expected = { :var_arg=>nil,
578
- :return=>{ :type => "void",
579
- :name => 'cmock_to_return',
580
- :ptr? => false,
581
- :const? => false,
582
- :str => "void cmock_to_return",
583
- :void? => true
584
- },
585
- :name=>"FunkyChicken",
586
- :modifier=>"",
587
- :contains_ptr? => false,
588
- :args=>[ {:type=>"uint", :name=>"la", :ptr? => false, :const? => false},
589
- {:type=>"int", :name=>"de", :ptr? => false, :const? => false},
590
- {:type=>"bool", :name=>"da", :ptr? => false, :const? => false}
591
- ],
592
- :args_string=>"uint la, int de, bool da",
593
- :args_call=>"la, de, da" }
594
- assert_equal(expected, @parser.parse_declaration(source))
595
- end
596
-
597
- it "extract and return function declarations with implied voids" do
598
-
599
- source = "void tat()"
600
- expected = { :var_arg=>nil,
601
- :return=>{ :type => "void",
602
- :name => 'cmock_to_return',
603
- :ptr? => false,
604
- :const? => false,
605
- :str => "void cmock_to_return",
606
- :void? => true
607
- },
608
- :name=>"tat",
609
- :modifier=>"",
610
- :contains_ptr? => false,
611
- :args=>[ ],
612
- :args_string=>"void",
613
- :args_call=>"" }
614
- assert_equal(expected, @parser.parse_declaration(source))
615
- end
616
-
617
- it "extract modifiers properly" do
618
-
619
- source = "const int TheMatrix(int Trinity, unsigned int * Neo)"
620
- expected = { :var_arg=>nil,
621
- :return=>{ :type => "int",
622
- :name => 'cmock_to_return',
623
- :ptr? => false,
624
- :const? => true,
625
- :str => "int cmock_to_return",
626
- :void? => false
627
- },
628
- :name=>"TheMatrix",
629
- :modifier=>"const",
630
- :contains_ptr? => true,
631
- :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false},
632
- {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false}
633
- ],
634
- :args_string=>"int Trinity, unsigned int* Neo",
635
- :args_call=>"Trinity, Neo" }
636
- assert_equal(expected, @parser.parse_declaration(source))
637
- end
638
-
639
- it "extract c calling conventions properly" do
640
-
641
- source = "const int __stdcall TheMatrix(int Trinity, unsigned int * Neo)"
642
- expected = { :var_arg=>nil,
643
- :return=>{ :type => "int",
644
- :name => 'cmock_to_return',
645
- :ptr? => false,
646
- :const? => true,
647
- :str => "int cmock_to_return",
648
- :void? => false
649
- },
650
- :name=>"TheMatrix",
651
- :modifier=>"const",
652
- :c_calling_convention=>"__stdcall",
653
- :contains_ptr? => true,
654
- :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false},
655
- {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false}
656
- ],
657
- :args_string=>"int Trinity, unsigned int* Neo",
658
- :args_call=>"Trinity, Neo" }
659
- assert_equal(expected, @parser.parse_declaration(source))
660
- end
661
-
662
- it "fully parse multiple prototypes" do
663
-
664
- source = "const int TheMatrix(int Trinity, unsigned int * Neo);\n" +
665
- "int Morpheus(int, unsigned int*);\n"
666
-
667
- expected = [{ :var_arg=>nil,
668
- :return=> { :type => "int",
669
- :name => 'cmock_to_return',
670
- :ptr? => false,
671
- :const? => true,
672
- :str => "int cmock_to_return",
673
- :void? => false
674
- },
675
- :name=>"TheMatrix",
676
- :modifier=>"const",
677
- :contains_ptr? => true,
678
- :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false},
679
- {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false}
680
- ],
681
- :args_string=>"int Trinity, unsigned int* Neo",
682
- :args_call=>"Trinity, Neo" },
683
- { :var_arg=>nil,
684
- :return=> { :type => "int",
685
- :name => 'cmock_to_return',
686
- :ptr? => false,
687
- :const? => false,
688
- :str => "int cmock_to_return",
689
- :void? => false
690
- },
691
- :name=>"Morpheus",
692
- :modifier=>"",
693
- :contains_ptr? => true,
694
- :args=>[ {:type=>"int", :name=>"cmock_arg1", :ptr? => false, :const? => false},
695
- {:type=>"unsigned int*", :name=>"cmock_arg2", :ptr? => true, :const? => false}
696
- ],
697
- :args_string=>"int cmock_arg1, unsigned int* cmock_arg2",
698
- :args_call=>"cmock_arg1, cmock_arg2"
699
- }]
700
- assert_equal(expected, @parser.parse("module", source)[:functions])
701
- end
702
-
703
- it "not extract for mocking multiply defined prototypes" do
704
-
705
- source = "const int TheMatrix(int Trinity, unsigned int * Neo);\n" +
706
- "const int TheMatrix(int, unsigned int*);\n"
707
-
708
- expected = [{ :var_arg=>nil,
709
- :name=>"TheMatrix",
710
- :return=> { :type => "int",
711
- :name => 'cmock_to_return',
712
- :ptr? => false,
713
- :const? => true,
714
- :str => "int cmock_to_return",
715
- :void? => false
716
- },
717
- :modifier=>"const",
718
- :contains_ptr? => true,
719
- :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false},
720
- {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false}
721
- ],
722
- :args_string=>"int Trinity, unsigned int* Neo",
723
- :args_call=>"Trinity, Neo"
724
- }]
725
- assert_equal(expected, @parser.parse("module", source)[:functions])
726
- end
727
-
728
- it "properly detect typedef'd variants of void and use those" do
729
-
730
- source = "typedef (void) FUNKY_VOID_T;\n" +
731
- "typedef void CHUNKY_VOID_T;\n" +
732
- "FUNKY_VOID_T DrHorrible(int SingAlong);\n" +
733
- "int CaptainHammer(CHUNKY_VOID_T);\n"
734
-
735
- expected = [{ :var_arg=>nil,
736
- :name=>"DrHorrible",
737
- :return => { :type => "void",
738
- :name => 'cmock_to_return',
739
- :ptr? => false,
740
- :const? => false,
741
- :str => "void cmock_to_return",
742
- :void? => true
743
- },
744
- :modifier=>"",
745
- :contains_ptr? => false,
746
- :args=>[ {:type=>"int", :name=>"SingAlong", :ptr? => false, :const? => false} ],
747
- :args_string=>"int SingAlong",
748
- :args_call=>"SingAlong"
749
- },
750
- { :var_arg=>nil,
751
- :return=> { :type => "int",
752
- :name => 'cmock_to_return',
753
- :ptr? => false,
754
- :const? => false,
755
- :str => "int cmock_to_return",
756
- :void? => false
757
- },
758
- :name=>"CaptainHammer",
759
- :modifier=>"",
760
- :contains_ptr? => false,
761
- :args=>[ ],
762
- :args_string=>"void",
763
- :args_call=>""
764
- }]
765
- assert_equal(expected, @parser.parse("module", source)[:functions])
766
- end
767
-
768
- it "be ok with structs inside of function declarations" do
769
-
770
- source = "int DrHorrible(struct SingAlong Blog);\n" +
771
- "void Penny(struct const _KeepYourHeadUp_ * const BillyBuddy);\n" +
772
- "struct TheseArentTheHammer CaptainHammer(void);\n"
773
-
774
- expected = [{ :var_arg=>nil,
775
- :return =>{ :type => "int",
776
- :name => 'cmock_to_return',
777
- :ptr? => false,
778
- :const? => false,
779
- :str => "int cmock_to_return",
780
- :void? => false
781
- },
782
- :name=>"DrHorrible",
783
- :modifier=>"",
784
- :contains_ptr? => false,
785
- :args=>[ {:type=>"struct SingAlong", :name=>"Blog", :ptr? => false, :const? => false} ],
786
- :args_string=>"struct SingAlong Blog",
787
- :args_call=>"Blog"
788
- },
789
- { :var_arg=>nil,
790
- :return=> { :type => "void",
791
- :name => 'cmock_to_return',
792
- :ptr? => false,
793
- :const? => false,
794
- :str => "void cmock_to_return",
795
- :void? => true
796
- },
797
- :name=>"Penny",
798
- :modifier=>"",
799
- :contains_ptr? => true,
800
- :args=>[ {:type=>"struct _KeepYourHeadUp_*", :name=>"BillyBuddy", :ptr? => true, :const? => true} ],
801
- :args_string=>"struct const _KeepYourHeadUp_* const BillyBuddy",
802
- :args_call=>"BillyBuddy"
803
- },
804
- { :var_arg=>nil,
805
- :return=> { :type => "struct TheseArentTheHammer",
806
- :name => 'cmock_to_return',
807
- :ptr? => false,
808
- :const? => false,
809
- :str => "struct TheseArentTheHammer cmock_to_return",
810
- :void? => false
811
- },
812
- :name=>"CaptainHammer",
813
- :modifier=>"",
814
- :contains_ptr? => false,
815
- :args=>[ ],
816
- :args_string=>"void",
817
- :args_call=>""
818
- }]
819
- assert_equal(expected, @parser.parse("module", source)[:functions])
820
- end
821
-
822
- it "extract functions containing unions with union specifier" do
823
- source = "void OrangePeel(union STARS_AND_STRIPES * a, union AFL_CIO b)"
824
- expected = [{ :var_arg=>nil,
825
- :return=>{ :type => "void",
826
- :name => 'cmock_to_return',
827
- :ptr? => false,
828
- :const? => false,
829
- :str => "void cmock_to_return",
830
- :void? => true
831
- },
832
- :name=>"OrangePeel",
833
- :modifier=>"",
834
- :contains_ptr? => true,
835
- :args=>[ {:type=>"union STARS_AND_STRIPES*", :name=>"a", :ptr? => true, :const? => false},
836
- {:type=>"union AFL_CIO", :name=>"b", :ptr? => false, :const? => false}
837
- ],
838
- :args_string=>"union STARS_AND_STRIPES* a, union AFL_CIO b",
839
- :args_call=>"a, b" }]
840
- result = @parser.parse("module", source)
841
- assert_equal(expected, result[:functions])
842
- end
843
-
844
- it "not be thwarted by variables named with primitive types as part of the name" do
845
- source = "void ApplePeel(const unsigned int const_param, int int_param, int integer, char character, int* const constant)"
846
- expected = [{ :var_arg=>nil,
847
- :return=>{ :type => "void",
848
- :name => 'cmock_to_return',
849
- :ptr? => false,
850
- :const? => false,
851
- :str => "void cmock_to_return",
852
- :void? => true
853
- },
854
- :name=>"ApplePeel",
855
- :modifier=>"",
856
- :contains_ptr? => true,
857
- :args=>[ {:type=> "unsigned int", :name=>"const_param", :ptr? => false, :const? => true},
858
- {:type=>"int", :name=>"int_param", :ptr? => false, :const? => false},
859
- {:type=>"int", :name=>"integer", :ptr? => false, :const? => false},
860
- {:type=>"char", :name=>"character", :ptr? => false, :const? => false},
861
- {:type=>"int*", :name=>"constant", :ptr? => true, :const? => true}
862
- ],
863
- :args_string=>"const unsigned int const_param, int int_param, int integer, char character, int* const constant",
864
- :args_call=>"const_param, int_param, integer, character, constant" }]
865
- result = @parser.parse("module", source)
866
- assert_equal(expected, result[:functions])
867
- end
868
-
869
- it "not be thwarted by custom types named similarly to primitive types" do
870
- source = "void LemonPeel(integer param, character thing, longint * junk, constant value, int32_t const number)"
871
- expected = [{:var_arg=>nil,
872
- :return=>{ :type => "void",
873
- :name => 'cmock_to_return',
874
- :ptr? => false,
875
- :const? => false,
876
- :str => "void cmock_to_return",
877
- :void? => true
878
- },
879
- :name=>"LemonPeel",
880
- :modifier=>"",
881
- :contains_ptr? => true,
882
- :args=>[ {:type=>"integer", :name=>"param", :ptr? => false, :const? => false},
883
- {:type=>"character", :name=>"thing", :ptr? => false, :const? => false},
884
- {:type=>"longint*", :name=>"junk", :ptr? => true, :const? => false},
885
- {:type=>"constant", :name=>"value", :ptr? => false, :const? => false},
886
- {:type=>"int32_t", :name=>"number", :ptr? => false, :const? => true}
887
- ],
888
- :args_string=>"integer param, character thing, longint* junk, constant value, int32_t const number",
889
- :args_call=>"param, thing, junk, value, number" }]
890
- result = @parser.parse("module", source)
891
- assert_equal(expected, result[:functions])
892
- end
893
-
894
- it "handle some of those chains of C name specifiers naturally" do
895
- source = "void CoinOperated(signed char abc, const unsigned long int xyz_123, unsigned int const abc_123, long long arm_of_the_law)"
896
- expected = [{:var_arg=>nil,
897
- :return=>{ :type => "void",
898
- :name => 'cmock_to_return',
899
- :ptr? => false,
900
- :const? => false,
901
- :str => "void cmock_to_return",
902
- :void? => true
903
- },
904
- :name=>"CoinOperated",
905
- :modifier=>"",
906
- :contains_ptr? => false,
907
- :args=>[ {:type=>"signed char", :name=>"abc", :ptr? => false, :const? => false},
908
- {:type=>"unsigned long int", :name=>"xyz_123", :ptr? => false, :const? => true},
909
- {:type=>"unsigned int", :name=>"abc_123", :ptr? => false, :const? => true},
910
- {:type=>"long long", :name=>"arm_of_the_law", :ptr? => false, :const? => false}
911
- ],
912
- :args_string=>"signed char abc, const unsigned long int xyz_123, unsigned int const abc_123, long long arm_of_the_law",
913
- :args_call=>"abc, xyz_123, abc_123, arm_of_the_law" }]
914
- result = @parser.parse("module", source)
915
- assert_equal(expected, result[:functions])
916
- end
917
-
918
- it "handle custom types of various formats" do
919
- source = "void CardOperated(CUSTOM_TYPE abc, CUSTOM_TYPE* xyz_123, CUSTOM_TYPE const abcxyz, struct CUSTOM_TYPE const * const abc123)"
920
- expected = [{:var_arg=>nil,
921
- :return=>{ :type => "void",
922
- :name => 'cmock_to_return',
923
- :ptr? => false,
924
- :const? => false,
925
- :str => "void cmock_to_return",
926
- :void? => true
927
- },
928
- :name=>"CardOperated",
929
- :modifier=>"",
930
- :contains_ptr? => true,
931
- :args=>[ {:type=>"CUSTOM_TYPE", :name=>"abc", :ptr? => false, :const? => false},
932
- {:type=>"CUSTOM_TYPE*", :name=>"xyz_123", :ptr? => true, :const? => false},
933
- {:type=>"CUSTOM_TYPE", :name=>"abcxyz", :ptr? => false, :const? => true},
934
- {:type=>"struct CUSTOM_TYPE const*", :name=>"abc123", :ptr? => true, :const? => true}
935
- ],
936
- :args_string=>"CUSTOM_TYPE abc, CUSTOM_TYPE* xyz_123, CUSTOM_TYPE const abcxyz, struct CUSTOM_TYPE const* const abc123",
937
- :args_call=>"abc, xyz_123, abcxyz, abc123" }]
938
- result = @parser.parse("module", source)
939
- assert_equal(expected, result[:functions])
940
- end
941
-
942
- it "handle arrays and treat them as pointers" do
943
- source = "void KeyOperated(CUSTOM_TYPE thing1[], int thing2 [ ], char thing3 [][2 ][ 3], int* thing4[4])"
944
- expected = [{:var_arg=>nil,
945
- :return=>{ :type => "void",
946
- :name => 'cmock_to_return',
947
- :ptr? => false,
948
- :const? => false,
949
- :str => "void cmock_to_return",
950
- :void? => true
951
- },
952
- :name=>"KeyOperated",
953
- :modifier=>"",
954
- :contains_ptr? => true,
955
- :args=>[ {:type=>"CUSTOM_TYPE*", :name=>"thing1", :ptr? => true, :const? => false},
956
- {:type=>"int*", :name=>"thing2", :ptr? => true, :const? => false},
957
- {:type=>"char*", :name=>"thing3", :ptr? => false, :const? => false}, #THIS one will likely change in the future when we improve multidimensional array support
958
- {:type=>"int**", :name=>"thing4", :ptr? => true, :const? => false} #THIS one will likely change in the future when we improve multidimensional array support
959
- ],
960
- :args_string=>"CUSTOM_TYPE* thing1, int* thing2, char* thing3, int** thing4",
961
- :args_call=>"thing1, thing2, thing3, thing4" }]
962
- result = @parser.parse("module", source)
963
- assert_equal(expected, result[:functions])
964
- end
965
-
966
- it "give a reasonable guess when dealing with weird combinations of custom types and modifiers" do
967
- source = "void Cheese(unsigned CUSTOM_TYPE abc, unsigned xyz, CUSTOM_TYPE1 CUSTOM_TYPE2 pdq)"
968
- expected = [{:var_arg=>nil,
969
- :return=>{ :type => "void",
970
- :name => 'cmock_to_return',
971
- :ptr? => false,
972
- :const? => false,
973
- :str => "void cmock_to_return",
974
- :void? => true
975
- },
976
- :name=>"Cheese",
977
- :modifier=>"",
978
- :contains_ptr? => false,
979
- :args=>[ {:type=>"unsigned CUSTOM_TYPE", :name=>"abc", :ptr? => false, :const? => false},
980
- {:type=>"unsigned", :name=>"xyz", :ptr? => false, :const? => false},
981
- {:type=>"CUSTOM_TYPE1 CUSTOM_TYPE2", :name=>"pdq", :ptr? => false, :const? => false}
982
- ],
983
- :args_string=>"unsigned CUSTOM_TYPE abc, unsigned xyz, CUSTOM_TYPE1 CUSTOM_TYPE2 pdq",
984
- :args_call=>"abc, xyz, pdq" }]
985
- result = @parser.parse("module", source)
986
- assert_equal(expected, result[:functions])
987
- end
988
-
989
- it "extract functions containing a function pointer" do
990
- source = "void FunkyTurkey(unsigned int (*func_ptr)(int, char))"
991
- expected = [{ :var_arg=>nil,
992
- :return=>{ :type => "void",
993
- :name => 'cmock_to_return',
994
- :ptr? => false,
995
- :const? => false,
996
- :str => "void cmock_to_return",
997
- :void? => true
998
- },
999
- :name=>"FunkyTurkey",
1000
- :modifier=>"",
1001
- :contains_ptr? => false,
1002
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false}
1003
- ],
1004
- :args_string=>"cmock_module_func_ptr1 func_ptr",
1005
- :args_call=>"func_ptr" }]
1006
- typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char);"]
1007
- result = @parser.parse("module", source)
1008
- assert_equal(expected, result[:functions])
1009
- assert_equal(typedefs, result[:typedefs])
1010
- end
1011
-
1012
- it "extract functions containing a function pointer with an implied void" do
1013
- source = "void FunkyTurkey(unsigned int (*func_ptr)())"
1014
- expected = [{ :var_arg=>nil,
1015
- :return=>{ :type => "void",
1016
- :name => 'cmock_to_return',
1017
- :ptr? => false,
1018
- :const? => false,
1019
- :str => "void cmock_to_return",
1020
- :void? => true
1021
- },
1022
- :name=>"FunkyTurkey",
1023
- :modifier=>"",
1024
- :contains_ptr? => false,
1025
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false}
1026
- ],
1027
- :args_string=>"cmock_module_func_ptr1 func_ptr",
1028
- :args_call=>"func_ptr" }]
1029
- typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)();"]
1030
- result = @parser.parse("module", source)
1031
- assert_equal(expected, result[:functions])
1032
- assert_equal(typedefs, result[:typedefs])
1033
- end
1034
-
1035
- it "extract functions containing a constant function pointer and a pointer in the nested arg list" do
1036
- source = "void FunkyChicken(unsigned int (* const func_ptr)(unsigned long int * , char))"
1037
- expected = [{ :var_arg=>nil,
1038
- :return=>{ :type => "void",
1039
- :name => 'cmock_to_return',
1040
- :ptr? => false,
1041
- :const? => false,
1042
- :str => "void cmock_to_return",
1043
- :void? => true
1044
- },
1045
- :name=>"FunkyChicken",
1046
- :modifier=>"",
1047
- :contains_ptr? => false,
1048
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => true}
1049
- ],
1050
- :args_string=>"cmock_module_func_ptr1 const func_ptr",
1051
- :args_call=>"func_ptr" }]
1052
- typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(unsigned long int* , char);"]
1053
- result = @parser.parse("module", source)
1054
- assert_equal(expected, result[:functions])
1055
- assert_equal(typedefs, result[:typedefs])
1056
- end
1057
-
1058
- # it "extract functions containing a function pointer taking a vararg" do
1059
- # source = "void FunkyParrot(unsigned int (*func_ptr)(int, char, ...))"
1060
- # expected = [{ :var_arg=>nil,
1061
- # :return=>{ :type => "void",
1062
- # :name => 'cmock_to_return',
1063
- # :ptr? => false,
1064
- # :const? => false,
1065
- # :str => "void cmock_to_return",
1066
- # :void? => true
1067
- # },
1068
- # :name=>"FunkyParrot",
1069
- # :modifier=>"",
1070
- # :contains_ptr? => false,
1071
- # :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false}
1072
- # ],
1073
- # :args_string=>"cmock_module_func_ptr1 func_ptr",
1074
- # :args_call=>"func_ptr" }]
1075
- # typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char, ...);"]
1076
- # result = @parser.parse("module", source)
1077
- # assert_equal(expected, result[:functions])
1078
- # assert_equal(typedefs, result[:typedefs])
1079
- # end
1080
-
1081
- it "extract functions containing a function pointer with extra parenthesis and two sets" do
1082
- source = "void FunkyBudgie(int (((* func_ptr1)(int, char))), void (*func_ptr2)(void))"
1083
- expected = [{ :var_arg=>nil,
1084
- :return=>{ :type => "void",
1085
- :name => 'cmock_to_return',
1086
- :ptr? => false,
1087
- :const? => false,
1088
- :str => "void cmock_to_return",
1089
- :void? => true
1090
- },
1091
- :name=>"FunkyBudgie",
1092
- :modifier=>"",
1093
- :contains_ptr? => false,
1094
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr1", :ptr? => false, :const? => false},
1095
- {:type=>"cmock_module_func_ptr2", :name=>"func_ptr2", :ptr? => false, :const? => false}
1096
- ],
1097
- :args_string=>"cmock_module_func_ptr1 func_ptr1, cmock_module_func_ptr2 func_ptr2",
1098
- :args_call=>"func_ptr1, func_ptr2" }]
1099
- typedefs = ["typedef int(*cmock_module_func_ptr1)(int, char);", "typedef void(*cmock_module_func_ptr2)(void);"]
1100
- result = @parser.parse("module", source)
1101
- assert_equal(expected, result[:functions])
1102
- assert_equal(typedefs, result[:typedefs])
1103
- end
1104
-
1105
- it "extract functions containing a function pointers, structs and other things" do
1106
- source = "struct mytype *FunkyRobin(uint16_t num1, uint16_t num2, void (*func_ptr1)(uint16_t num3, struct mytype2 *s));"
1107
- expected = [{ :var_arg=>nil,
1108
- :return=>{ :type => "struct mytype*",
1109
- :name => 'cmock_to_return',
1110
- :ptr? => true,
1111
- :const? => false,
1112
- :str => "struct mytype* cmock_to_return",
1113
- :void? => false
1114
- },
1115
- :name=>"FunkyRobin",
1116
- :modifier=>"",
1117
- :contains_ptr? => false,
1118
- :args=>[ {:type=>"uint16_t", :name=>"num1", :ptr? => false, :const? => false},
1119
- {:type=>"uint16_t", :name=>"num2", :ptr? => false, :const? => false},
1120
- {:type=>"cmock_module_func_ptr1", :name=>"func_ptr1", :ptr? => false, :const? => false}
1121
- ],
1122
- :args_string=>"uint16_t num1, uint16_t num2, cmock_module_func_ptr1 func_ptr1",
1123
- :args_call=>"num1, num2, func_ptr1" }]
1124
- typedefs = ["typedef void(*cmock_module_func_ptr1)(uint16_t num3, struct mytype2* s);"]
1125
- result = @parser.parse("module", source)
1126
- assert_equal(expected, result[:functions])
1127
- assert_equal(typedefs, result[:typedefs])
1128
- end
1129
-
1130
- it "extract functions containing an anonymous function pointer" do
1131
- source = "void FunkyFowl(unsigned int (* const)(int, char))"
1132
- expected = [{ :var_arg=>nil,
1133
- :return=>{ :type => "void",
1134
- :name => 'cmock_to_return',
1135
- :ptr? => false,
1136
- :const? => false,
1137
- :str => "void cmock_to_return",
1138
- :void? => true
1139
- },
1140
- :name=>"FunkyFowl",
1141
- :modifier=>"",
1142
- :contains_ptr? => false,
1143
- :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"cmock_arg1", :ptr? => false, :const? => true}
1144
- ],
1145
- :args_string=>"cmock_module_func_ptr1 const cmock_arg1",
1146
- :args_call=>"cmock_arg1" }]
1147
- typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char);"]
1148
- result = @parser.parse("module", source)
1149
- assert_equal(expected, result[:functions])
1150
- assert_equal(typedefs, result[:typedefs])
1151
- end
1152
-
1153
- it "extract functions returning a function pointer" do
1154
- source = "unsigned short (*FunkyPidgeon( const char op_code ))( int, long int )"
1155
- expected = [{ :var_arg=>nil,
1156
- :return=>{ :type => "cmock_module_func_ptr1",
1157
- :name => 'cmock_to_return',
1158
- :ptr? => false,
1159
- :const? => false,
1160
- :str => "cmock_module_func_ptr1 cmock_to_return",
1161
- :void? => false
1162
- },
1163
- :name=>"FunkyPidgeon",
1164
- :modifier=>"",
1165
- :contains_ptr? => false,
1166
- :args=>[ {:type=>"char", :name=>"op_code", :ptr? => false, :const? => true}
1167
- ],
1168
- :args_string=>"const char op_code",
1169
- :args_call=>"op_code" }]
1170
- typedefs = ["typedef unsigned short(*cmock_module_func_ptr1)( int, long int );"]
1171
- result = @parser.parse("module", source)
1172
- assert_equal(expected, result[:functions])
1173
- assert_equal(typedefs, result[:typedefs])
1174
- end
1175
-
1176
- it "extract functions returning a function pointer with implied void" do
1177
- source = "unsigned short (*FunkyTweetie())()"
1178
- expected = [{ :var_arg=>nil,
1179
- :return=>{ :type => "cmock_module_func_ptr1",
1180
- :name => 'cmock_to_return',
1181
- :ptr? => false,
1182
- :const? => false,
1183
- :str => "cmock_module_func_ptr1 cmock_to_return",
1184
- :void? => false
1185
- },
1186
- :name=>"FunkyTweetie",
1187
- :modifier=>"",
1188
- :contains_ptr? => false,
1189
- :args=>[],
1190
- :args_string=>"void",
1191
- :args_call=>"" }]
1192
- typedefs = ["typedef unsigned short(*cmock_module_func_ptr1)();"]
1193
- result = @parser.parse("module", source)
1194
- assert_equal(expected, result[:functions])
1195
- assert_equal(typedefs, result[:typedefs])
1196
- end
1197
-
1198
- it "extract functions returning a function pointer where everything is a void" do
1199
- source = "void (* FunkySeaGull(void))(void)"
1200
- expected = [{ :var_arg=>nil,
1201
- :return=>{ :type => "cmock_module_func_ptr1",
1202
- :name => 'cmock_to_return',
1203
- :ptr? => false,
1204
- :const? => false,
1205
- :str => "cmock_module_func_ptr1 cmock_to_return",
1206
- :void? => false
1207
- },
1208
- :name=>"FunkySeaGull",
1209
- :modifier=>"",
1210
- :contains_ptr? => false,
1211
- :args=>[],
1212
- :args_string=>"void",
1213
- :args_call=>"" }]
1214
- typedefs = ["typedef void(*cmock_module_func_ptr1)(void);"]
1215
- result = @parser.parse("module", source)
1216
- assert_equal(expected, result[:functions])
1217
- assert_equal(typedefs, result[:typedefs])
1218
- end
1219
-
1220
- it "extract functions returning a function pointer with some pointer nonsense" do
1221
- source = "unsigned int * (* FunkyMacaw(double* foo, THING *bar))(unsigned int)"
1222
- expected = [{ :var_arg=>nil,
1223
- :return=>{ :type => "cmock_module_func_ptr1",
1224
- :name => 'cmock_to_return',
1225
- :ptr? => false,
1226
- :const? => false,
1227
- :str => "cmock_module_func_ptr1 cmock_to_return",
1228
- :void? => false
1229
- },
1230
- :name=>"FunkyMacaw",
1231
- :modifier=>"",
1232
- :contains_ptr? => true,
1233
- :args=>[ {:type=>"double*", :name=>"foo", :ptr? => true, :const? => false},
1234
- {:type=>"THING*", :name=>"bar", :ptr? => true, :const? => false}
1235
- ],
1236
- :args_string=>"double* foo, THING* bar",
1237
- :args_call=>"foo, bar" }]
1238
- typedefs = ["typedef unsigned int *(*cmock_module_func_ptr1)(unsigned int);"]
1239
- result = @parser.parse("module", source)
1240
- assert_equal(expected, result[:functions])
1241
- assert_equal(typedefs, result[:typedefs])
1242
- end
1243
-
1244
- it "extract this SQLite3 function with an anonymous function pointer arg (regression test)" do
1245
- source = "SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*))"
1246
- expected = [{ :var_arg=>nil,
1247
- :return=>{ :type => "int",
1248
- :name => "cmock_to_return",
1249
- :ptr? => false,
1250
- :const? => false,
1251
- :str => "int cmock_to_return",
1252
- :void? => false
1253
- },
1254
- :name=>"sqlite3_bind_text",
1255
- :modifier=>"SQLITE_API",
1256
- :contains_ptr? => true,
1257
- :args=>[ {:type=>"sqlite3_stmt*", :name=>"cmock_arg2", :ptr? => true, :const? => false},
1258
- {:type=>"int", :name=>"cmock_arg3", :ptr? => false, :const? => false},
1259
- {:type=>"char*", :name=>"cmock_arg4", :ptr? => false, :const? => true},
1260
- {:type=>"int", :name=>"n", :ptr? => false, :const? => false},
1261
- {:type=>"cmock_module_func_ptr1", :name=>"cmock_arg1", :ptr? => false, :const? => false}
1262
- ],
1263
- :args_string=>"sqlite3_stmt* cmock_arg2, int cmock_arg3, const char* cmock_arg4, int n, cmock_module_func_ptr1 cmock_arg1",
1264
- :args_call=>"cmock_arg2, cmock_arg3, cmock_arg4, n, cmock_arg1" }]
1265
- typedefs = ["typedef void(*cmock_module_func_ptr1)(void*);"]
1266
- result = @parser.parse("module", source)
1267
- assert_equal(expected, result[:functions])
1268
- assert_equal(typedefs, result[:typedefs])
1269
- end
1270
-
1271
- it "extract functions with varargs" do
1272
- source = "int XFiles(int Scully, int Mulder, ...);\n"
1273
- expected = [{ :var_arg=>"...",
1274
- :return=> { :type => "int",
1275
- :name => 'cmock_to_return',
1276
- :ptr? => false,
1277
- :const? => false,
1278
- :str => "int cmock_to_return",
1279
- :void? => false
1280
- },
1281
- :name=>"XFiles",
1282
- :modifier=>"",
1283
- :contains_ptr? => false,
1284
- :args=>[ {:type=>"int", :name=>"Scully", :ptr? => false, :const? => false},
1285
- {:type=>"int", :name=>"Mulder", :ptr? => false, :const? => false}
1286
- ],
1287
- :args_string=>"int Scully, int Mulder",
1288
- :args_call=>"Scully, Mulder"
1289
- }]
1290
- assert_equal(expected, @parser.parse("module", source)[:functions])
1291
- end
1292
-
1293
- it "extract functions with strippable confusing junk like gcc attributes" do
1294
- source = "int LaverneAndShirley(int Lenny, int Squiggy) __attribute__((weak)) __attribute__ ((deprecated));\n"
1295
- expected = [{ :var_arg=>nil,
1296
- :return=> { :type => "int",
1297
- :name => 'cmock_to_return',
1298
- :ptr? => false,
1299
- :const? => false,
1300
- :str => "int cmock_to_return",
1301
- :void? => false
1302
- },
1303
- :name=>"LaverneAndShirley",
1304
- :modifier=>"",
1305
- :contains_ptr? => false,
1306
- :args=>[ {:type=>"int", :name=>"Lenny", :ptr? => false, :const? => false},
1307
- {:type=>"int", :name=>"Squiggy", :ptr? => false, :const? => false}
1308
- ],
1309
- :args_string=>"int Lenny, int Squiggy",
1310
- :args_call=>"Lenny, Squiggy"
1311
- }]
1312
- assert_equal(expected, @parser.parse("module", source)[:functions])
1313
- end
1314
-
1315
- it "extract functions with strippable confusing junk like gcc attributes with parenthesis" do
1316
- source = "int TheCosbyShow(int Cliff, int Claire) __attribute__((weak, alias (\"__f\"));\n"
1317
- expected = [{ :var_arg=>nil,
1318
- :return=> { :type => "int",
1319
- :name => 'cmock_to_return',
1320
- :ptr? => false,
1321
- :const? => false,
1322
- :str => "int cmock_to_return",
1323
- :void? => false
1324
- },
1325
- :name=>"TheCosbyShow",
1326
- :modifier=>"",
1327
- :contains_ptr? => false,
1328
- :args=>[ {:type=>"int", :name=>"Cliff", :ptr? => false, :const? => false},
1329
- {:type=>"int", :name=>"Claire", :ptr? => false, :const? => false}
1330
- ],
1331
- :args_string=>"int Cliff, int Claire",
1332
- :args_call=>"Cliff, Claire"
1333
- }]
1334
- assert_equal(expected, @parser.parse("module", source)[:functions])
1335
- end
1336
-
1337
- 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
+ $QUICK_RUBY_VERSION = RUBY_VERSION.split('.').inject(0){|vv,v| vv * 100 + v.to_i }
9
+
10
+ require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
11
+ require 'cmock_header_parser'
12
+
13
+ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
14
+
15
+ before do
16
+ create_mocks :config
17
+ @test_name = 'test_file.h'
18
+ @config.expect :strippables, ["STRIPPABLE"]
19
+ @config.expect :attributes, ['__ramfunc', 'funky_attrib', 'SQLITE_API']
20
+ @config.expect :c_calling_conventions, ['__stdcall']
21
+ @config.expect :treat_as_void, ['MY_FUNKY_VOID']
22
+ @config.expect :treat_as, { "BANJOS" => "INT", "TUBAS" => "HEX16"}
23
+ @config.expect :when_no_prototypes, :error
24
+ @config.expect :verbosity, 1
25
+ @config.expect :treat_externs, :exclude
26
+
27
+ @parser = CMockHeaderParser.new(@config)
28
+ end
29
+
30
+ after do
31
+ end
32
+
33
+ it "create and initialize variables to defaults appropriately" do
34
+ assert_equal([], @parser.funcs)
35
+ assert_equal(['const', '__ramfunc', 'funky_attrib', 'SQLITE_API'], @parser.c_attributes)
36
+ assert_equal(['void','MY_FUNKY_VOID'], @parser.treat_as_void)
37
+ end
38
+
39
+ it "strip out line comments" do
40
+ source =
41
+ " abcd;\n" +
42
+ "// hello;\n" +
43
+ "who // is you\n"
44
+
45
+ expected =
46
+ [
47
+ "abcd",
48
+ "who"
49
+ ]
50
+
51
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
52
+ end
53
+
54
+ it "remove block comments" do
55
+ source =
56
+ " no_comments;\n" +
57
+ "// basic_line_comment;\n" +
58
+ "/* basic_block_comment;*/\n" +
59
+ "pre_block; /* start_of_block_comment;\n" +
60
+ "// embedded_line_comment_in_block_comment; */\n" +
61
+ "// /* commented_out_block_comment_line\n" +
62
+ "shown_because_block_comment_invalid_from_line_comment;\n" +
63
+ "// */\n" +
64
+ "//* shorter_commented_out_block_comment_line; \n" +
65
+ "shown_because_block_comment_invalid_from_shorter_line_comment;\n" +
66
+ "/*/\n" +
67
+ "not_shown_because_line_above_started_comment;\n" +
68
+ "//*/\n" +
69
+ "/* \n" +
70
+ "not_shown_because_block_comment_started_this_time;\n" +
71
+ "/*/\n" +
72
+ "shown_because_line_above_ended_comment_this_time;\n" +
73
+ "//*/\n"
74
+
75
+ expected =
76
+ [
77
+ "no_comments",
78
+ "pre_block",
79
+ "shown_because_block_comment_invalid_from_line_comment",
80
+ "shown_because_block_comment_invalid_from_shorter_line_comment",
81
+ "shown_because_line_above_ended_comment_this_time"
82
+ ]
83
+
84
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
85
+ end
86
+
87
+ it "remove strippables from the beginning or end of function declarations" do
88
+ source =
89
+ "void* my_calloc(size_t, size_t) STRIPPABLE;\n" +
90
+ "void\n" +
91
+ " my_realloc(void*, size_t) STRIPPABLE;\n" +
92
+ "extern int\n" +
93
+ " my_printf (void *my_object, const char *my_format, ...)\n" +
94
+ " STRIPPABLE;\n" +
95
+ " void STRIPPABLE universal_handler ();\n"
96
+
97
+ expected =
98
+ [
99
+ "void* my_calloc(size_t, size_t)",
100
+ "void my_realloc(void*, size_t)",
101
+ "void universal_handler()"
102
+ ]
103
+
104
+ assert_equal(expected, @parser.import_source(source))
105
+ end
106
+
107
+ it "remove gcc's function __attribute__'s" do
108
+ source =
109
+ "void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)));\n" +
110
+ "void\n" +
111
+ " my_realloc(void*, size_t) __attribute__((alloc_size(2)));\n" +
112
+ "extern int\n" +
113
+ " my_printf (void *my_object, const char *my_format, ...)\n" +
114
+ " __attribute__ ((format (printf, 2, 3)));\n" +
115
+ " void __attribute__ ((interrupt)) universal_handler ();\n"
116
+
117
+ expected =
118
+ [
119
+ "void* my_calloc(size_t, size_t)",
120
+ "void my_realloc(void*, size_t)",
121
+ "void universal_handler()"
122
+ ]
123
+
124
+ assert_equal(expected, @parser.import_source(source))
125
+ end
126
+
127
+ it "remove preprocessor directives" do
128
+ source =
129
+ "#when stuff_happens\n" +
130
+ "#ifdef _TEST\n" +
131
+ "#pragma stack_switch"
132
+
133
+ expected = []
134
+
135
+ assert_equal(expected, @parser.import_source(source))
136
+ end
137
+
138
+
139
+ it "remove assembler pragma sections" do
140
+ source =
141
+ " #pragma\tasm\n" +
142
+ " .foo\n" +
143
+ " lda %m\n" +
144
+ " nop\n" +
145
+ "# pragma endasm \n" +
146
+ "foo"
147
+
148
+ expected = ["foo"]
149
+
150
+ assert_equal(expected, @parser.import_source(source))
151
+ end
152
+
153
+
154
+ it "smush lines together that contain continuation characters" do
155
+ source =
156
+ "hoo hah \\\n" +
157
+ "when \\ \n"
158
+
159
+ expected =
160
+ [
161
+ "hoo hah when"
162
+ ]
163
+
164
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
165
+ end
166
+
167
+
168
+ it "remove C macro definitions" do
169
+ source =
170
+ "#define this is the first line\\\n" +
171
+ "and the second\\\n" +
172
+ "and the third that should be removed\n" +
173
+ "but I'm here\n"
174
+
175
+ expected = ["but I'm here"]
176
+
177
+ assert_equal(expected, @parser.import_source(source))
178
+ end
179
+
180
+
181
+ it "remove typedef statements" do
182
+ source =
183
+ "typedef uint32 (unsigned int);\n" +
184
+ "const typedef int INT;\n" +
185
+ "int notatypedef;\n" +
186
+ "int typedef_isnt_me;\n" +
187
+ " typedef who cares what really comes here \n" + # exercise multiline typedef
188
+ " continuation;\n" +
189
+ "this should remain!;\n" +
190
+ "typedef blah bleh;\n" +
191
+ "typedef struct shell_command_struct {\n" +
192
+ " char_ptr COMMAND;\n" +
193
+ " int_32 (*SHELL_FUNC)(int_32 argc);\n" +
194
+ "} SHELL_COMMAND_STRUCT, * SHELL_COMMAND_PTR;\n" +
195
+ "typedef struct shell_command_struct {\n" +
196
+ " char_ptr COMMAND;\n" +
197
+ " int_32 (*SHELL_FUNC)(int_32 argc, char_ptr argv[]);\n" +
198
+ "} SHELL_COMMAND_STRUCT, * SHELL_COMMAND_PTR;\n" +
199
+ "typedef struct shell_command_struct {\n" +
200
+ " char_ptr COMMAND;\n" +
201
+ " int_32 (*SHELL_FUNC)(int_32 argc);\n" +
202
+ "};\n"
203
+
204
+ expected =
205
+ [
206
+ "int notatypedef",
207
+ "int typedef_isnt_me",
208
+ "this should remain!"
209
+ ]
210
+
211
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
212
+ end
213
+
214
+
215
+ it "remove enum statements" do
216
+ source =
217
+ "enum _NamedEnum {\n" +
218
+ " THING1 = (0x0001),\n" +
219
+ " THING2 = (0x0001 << 5),\n" +
220
+ "}ListOValues;\n\n" +
221
+ "don't delete me!!\n" +
222
+ " modifier_str enum _NamedEnum {THING1 = (0x0001), THING2 = (0x0001 << 5)} ListOValues;\n\n" +
223
+ "typedef enum {\n" +
224
+ " THING1,\n" +
225
+ " THING2,\n" +
226
+ "} Thinger;\n" +
227
+ "or me!!\n"
228
+
229
+ assert_equal(["don't delete me!! or me!!"], @parser.import_source(source).map!{|s|s.strip})
230
+ end
231
+
232
+
233
+ it "remove union statements" do
234
+ source =
235
+ "union _NamedDoohicky {\n" +
236
+ " unsigned int a;\n" +
237
+ " char b;\n" +
238
+ "} Doohicky;\n\n" +
239
+ "I want to live!!\n" +
240
+ "some_modifier union { unsigned int a; char b;} Whatever;\n" +
241
+ "typedef union {\n" +
242
+ " unsigned int a;\n" +
243
+ " char b;\n" +
244
+ "} Whatever;\n" +
245
+ "me too!!\n"
246
+
247
+ assert_equal(["I want to live!! me too!!"], @parser.import_source(source).map!{|s|s.strip})
248
+ end
249
+
250
+
251
+ it "remove struct statements" do
252
+ source =
253
+ "struct _NamedStruct1 {\n" +
254
+ " unsigned int a;\n" +
255
+ " signed long int b;\n" +
256
+ "} Thing ;\n\n" +
257
+ "extern struct ForwardDeclared_t TestDataType1;\n" +
258
+ "void foo(void);\n" +
259
+ "struct\n"+
260
+ " MultilineForwardDeclared_t\n" +
261
+ " TestDataType2;\n" +
262
+ "struct THINGER foo(void);\n" +
263
+ "typedef struct {\n" +
264
+ " unsigned int a;\n" +
265
+ " signed char b;\n" +
266
+ "}Thinger;\n" +
267
+ "I want to live!!\n"
268
+
269
+ assert_equal(["void foo(void)", "struct THINGER foo(void)", "I want to live!!"],
270
+ @parser.import_source(source).map!{|s|s.strip})
271
+ end
272
+
273
+ it "remove externed and inline functions" do
274
+ source =
275
+ " extern uint32 foobar(unsigned int);\n" +
276
+ "uint32 extern_name_func(unsigned int);\n" +
277
+ "uint32 funcinline(unsigned int);\n" +
278
+ "extern void bar(unsigned int);\n" +
279
+ "inline void bar(unsigned int);\n" +
280
+ "extern\n" +
281
+ "void kinda_ugly_on_the_next_line(unsigned int);\n"
282
+
283
+ expected =
284
+ [
285
+ "uint32 extern_name_func(unsigned int)",
286
+ "uint32 funcinline(unsigned int)"
287
+ ]
288
+
289
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
290
+ end
291
+
292
+ it "remove function definitions but keep function declarations" do
293
+ source =
294
+ "uint32 func_with_decl_a(unsigned int);\n" +
295
+ "uint32 func_with_decl_a(unsigned int a) { return a; }\n" +
296
+ "uint32 func_with_decl_b(unsigned int);\n" +
297
+ "uint32 func_with_decl_b(unsigned int a)\n" +
298
+ "{\n" +
299
+ " bar((unsigned int) a);\n" +
300
+ " stripme(a);\n" +
301
+ "}\n"
302
+
303
+ expected =
304
+ [
305
+ "uint32 func_with_decl_a(unsigned int)",
306
+ "uint32 func_with_decl_a", #okay. it's not going to be interpretted as another function
307
+ "uint32 func_with_decl_b(unsigned int)",
308
+ "uint32 func_with_decl_b", #okay. it's not going to be interpretted as another function
309
+ ]
310
+
311
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
312
+ end
313
+
314
+ it "remove a fully defined inline function" do
315
+ source =
316
+ "inline void foo(unsigned int a) { oranges = a; }\n" +
317
+ "inline void bar(unsigned int a) { apples = a; };\n" +
318
+ "inline void bar(unsigned int a)\n" +
319
+ "{" +
320
+ " bananas = a;\n" +
321
+ "}"
322
+
323
+ # ensure it's expected type of exception
324
+ assert_raises RuntimeError do
325
+ @parser.parse("module", source)
326
+ end
327
+
328
+ assert_equal([], @parser.funcs)
329
+
330
+ # verify exception message
331
+ begin
332
+ @parser.parse("module", source)
333
+ rescue RuntimeError => e
334
+ assert_equal("ERROR: No function prototypes found!", e.message)
335
+ end
336
+ end
337
+
338
+ it "remove a fully defined inline function that is multiple lines" do
339
+ source =
340
+ "inline void bar(unsigned int a)\n" +
341
+ "{" +
342
+ " bananas = a;\n" +
343
+ " grapes = a;\n" +
344
+ " apples(bananas, grapes);\n" +
345
+ "}"
346
+
347
+ # ensure it's expected type of exception
348
+ assert_raises RuntimeError do
349
+ @parser.parse("module", source)
350
+ end
351
+
352
+ assert_equal([], @parser.funcs)
353
+
354
+ # verify exception message
355
+ begin
356
+ @parser.parse("module", source)
357
+ rescue RuntimeError => e
358
+ assert_equal("ERROR: No function prototypes found!", e.message)
359
+ end
360
+ end
361
+
362
+ it "remove just inline functions if externs to be included" do
363
+ source =
364
+ " extern uint32 foobar(unsigned int);\n" +
365
+ "uint32 extern_name_func(unsigned int);\n" +
366
+ "uint32 funcinline(unsigned int);\n" +
367
+ "extern void bar(unsigned int);\n" +
368
+ "inline void bar(unsigned int);\n" +
369
+ "extern\n" +
370
+ "void kinda_ugly_on_the_next_line(unsigned int);\n"
371
+
372
+ expected =
373
+ [ "extern uint32 foobar(unsigned int)",
374
+ "uint32 extern_name_func(unsigned int)",
375
+ "uint32 funcinline(unsigned int)",
376
+ "extern void bar(unsigned int)",
377
+ "extern void kinda_ugly_on_the_next_line(unsigned int)"
378
+ ]
379
+
380
+ @parser.treat_externs = :include
381
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
382
+ end
383
+
384
+
385
+ it "remove defines" do
386
+ source =
387
+ "#define whatever you feel like defining\n" +
388
+ "void hello(void);\n" +
389
+ "#DEFINE I JUST DON'T CARE\n" +
390
+ "#deFINE\n" +
391
+ "#define get_foo() \\\n ((Thing)foo.bar)" # exercise multiline define
392
+
393
+ expected =
394
+ [
395
+ "void hello(void)",
396
+ ]
397
+
398
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
399
+ end
400
+
401
+
402
+ it "remove keywords that would keep things from going smoothly in the future" do
403
+ source =
404
+ "const int TheMatrix(register int Trinity, unsigned int *restrict Neo)"
405
+
406
+ expected =
407
+ [
408
+ "const int TheMatrix(int Trinity, unsigned int * Neo)",
409
+ ]
410
+
411
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
412
+ end
413
+
414
+
415
+ # some code actually typedef's void even though it's not ANSI C and is, frankly, weird
416
+ # since cmock treats void specially, we can't let void be obfuscated
417
+ it "handle odd case of typedef'd void returned" do
418
+ source = "MY_FUNKY_VOID FunkyVoidReturned(int a)"
419
+ expected = { :var_arg=>nil,
420
+ :name=>"FunkyVoidReturned",
421
+ :return=>{ :type => "void",
422
+ :name => 'cmock_to_return',
423
+ :ptr? => false,
424
+ :const? => false,
425
+ :str => "void cmock_to_return",
426
+ :void? => true
427
+ },
428
+ :modifier=>"",
429
+ :contains_ptr? => false,
430
+ :args=>[{:type=>"int", :name=>"a", :ptr? => false, :const? => false}],
431
+ :args_string=>"int a",
432
+ :args_call=>"a"}
433
+ assert_equal(expected, @parser.parse_declaration(source))
434
+ end
435
+
436
+ it "handle odd case of typedef'd void as arg" do
437
+ source = "int FunkyVoidAsArg(MY_FUNKY_VOID)"
438
+ expected = { :var_arg=>nil,
439
+ :name=>"FunkyVoidAsArg",
440
+ :return=>{ :type => "int",
441
+ :name => 'cmock_to_return',
442
+ :ptr? => false,
443
+ :const? => false,
444
+ :str => "int cmock_to_return",
445
+ :void? => false
446
+ },
447
+ :modifier=>"",
448
+ :contains_ptr? => false,
449
+ :args=>[],
450
+ :args_string=>"void",
451
+ :args_call=>"" }
452
+ assert_equal(expected, @parser.parse_declaration(source))
453
+ end
454
+
455
+ it "handle odd case of typedef'd void as arg pointer" do
456
+ source = "char FunkyVoidPointer(MY_FUNKY_VOID* bluh)"
457
+ expected = { :var_arg=>nil,
458
+ :name=>"FunkyVoidPointer",
459
+ :return=>{ :type => "char",
460
+ :name => 'cmock_to_return',
461
+ :ptr? => false,
462
+ :const? => false,
463
+ :str => "char cmock_to_return",
464
+ :void? => false
465
+ },
466
+ :modifier=>"",
467
+ :contains_ptr? => true,
468
+ :args=>[{:type=>"MY_FUNKY_VOID*", :name=>"bluh", :ptr? => true, :const? => false}],
469
+ :args_string=>"MY_FUNKY_VOID* bluh",
470
+ :args_call=>"bluh" }
471
+ assert_equal(expected, @parser.parse_declaration(source))
472
+ end
473
+
474
+
475
+ it "strip default values from function parameter lists" do
476
+ source =
477
+ "void Foo(int a = 57, float b=37.52, char c= 'd', char* e=\"junk\");\n"
478
+
479
+ expected =
480
+ [
481
+ "void Foo(int a, float b, char c, char* e)"
482
+ ]
483
+
484
+ assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
485
+ end
486
+
487
+
488
+ it "raise upon empty file" do
489
+ source = ''
490
+
491
+ # ensure it's expected type of exception
492
+ assert_raises RuntimeError do
493
+ @parser.parse("module", source)
494
+ end
495
+
496
+ assert_equal([], @parser.funcs)
497
+
498
+ # verify exception message
499
+ begin
500
+ @parser.parse("module", source)
501
+ rescue RuntimeError => e
502
+ assert_equal("ERROR: No function prototypes found!", e.message)
503
+ end
504
+ end
505
+
506
+ it "clean up module names that contain spaces, dashes, and such" do
507
+ source = 'void meh(int (*func)(int));'
508
+
509
+ retval = @parser.parse("C:\Ugly Module-Name", source)
510
+ assert (retval[:typedefs][0] =~ /CUglyModuleName/)
511
+ end
512
+
513
+ it "raise upon no function prototypes found in file" do
514
+ source =
515
+ "typedef void SILLY_VOID_TYPE1;\n" +
516
+ "typedef (void) SILLY_VOID_TYPE2 ;\n" +
517
+ "typedef ( void ) (*FUNCPTR)(void);\n\n" +
518
+ "#define get_foo() \\\n ((Thing)foo.bar)"
519
+
520
+ # ensure it's expected type of exception
521
+ assert_raises(RuntimeError) do
522
+ @parser.parse("module", source)
523
+ end
524
+
525
+ assert_equal([], @parser.funcs)
526
+
527
+ # verify exception message
528
+ begin
529
+ @parser.parse("module", source)
530
+ rescue RuntimeError => e
531
+ assert_equal("ERROR: No function prototypes found!", e.message)
532
+ end
533
+ end
534
+
535
+
536
+ it "raise upon prototype parsing failure" do
537
+ source = "void (int, )"
538
+
539
+ # ensure it's expected type of exception
540
+ assert_raises(RuntimeError) do
541
+ @parser.parse("module", source)
542
+ end
543
+
544
+ # verify exception message
545
+ begin
546
+ @parser.parse("module", source)
547
+ rescue RuntimeError => e
548
+ assert(e.message.include?("Failed Parsing Declaration Prototype!"))
549
+ end
550
+ end
551
+
552
+ it "extract and return function declarations with retval and args" do
553
+
554
+ source = "int Foo(int a, unsigned int b)"
555
+ expected = { :var_arg=>nil,
556
+ :name=>"Foo",
557
+ :return=>{ :type => "int",
558
+ :name => 'cmock_to_return',
559
+ :ptr? => false,
560
+ :const? => false,
561
+ :str => "int cmock_to_return",
562
+ :void? => false
563
+ },
564
+ :modifier=>"",
565
+ :contains_ptr? => false,
566
+ :args=>[ {:type=>"int", :name=>"a", :ptr? => false, :const? => false},
567
+ {:type=>"unsigned int", :name=>"b", :ptr? => false, :const? => false}
568
+ ],
569
+ :args_string=>"int a, unsigned int b",
570
+ :args_call=>"a, b" }
571
+ assert_equal(expected, @parser.parse_declaration(source))
572
+ end
573
+
574
+ it "extract and return function declarations with no retval" do
575
+
576
+ source = "void FunkyChicken( uint la, int de, bool da)"
577
+ expected = { :var_arg=>nil,
578
+ :return=>{ :type => "void",
579
+ :name => 'cmock_to_return',
580
+ :ptr? => false,
581
+ :const? => false,
582
+ :str => "void cmock_to_return",
583
+ :void? => true
584
+ },
585
+ :name=>"FunkyChicken",
586
+ :modifier=>"",
587
+ :contains_ptr? => false,
588
+ :args=>[ {:type=>"uint", :name=>"la", :ptr? => false, :const? => false},
589
+ {:type=>"int", :name=>"de", :ptr? => false, :const? => false},
590
+ {:type=>"bool", :name=>"da", :ptr? => false, :const? => false}
591
+ ],
592
+ :args_string=>"uint la, int de, bool da",
593
+ :args_call=>"la, de, da" }
594
+ assert_equal(expected, @parser.parse_declaration(source))
595
+ end
596
+
597
+ it "extract and return function declarations with implied voids" do
598
+
599
+ source = "void tat()"
600
+ expected = { :var_arg=>nil,
601
+ :return=>{ :type => "void",
602
+ :name => 'cmock_to_return',
603
+ :ptr? => false,
604
+ :const? => false,
605
+ :str => "void cmock_to_return",
606
+ :void? => true
607
+ },
608
+ :name=>"tat",
609
+ :modifier=>"",
610
+ :contains_ptr? => false,
611
+ :args=>[ ],
612
+ :args_string=>"void",
613
+ :args_call=>"" }
614
+ assert_equal(expected, @parser.parse_declaration(source))
615
+ end
616
+
617
+ it "extract modifiers properly" do
618
+
619
+ source = "const int TheMatrix(int Trinity, unsigned int * Neo)"
620
+ expected = { :var_arg=>nil,
621
+ :return=>{ :type => "int",
622
+ :name => 'cmock_to_return',
623
+ :ptr? => false,
624
+ :const? => true,
625
+ :str => "int cmock_to_return",
626
+ :void? => false
627
+ },
628
+ :name=>"TheMatrix",
629
+ :modifier=>"const",
630
+ :contains_ptr? => true,
631
+ :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false},
632
+ {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false}
633
+ ],
634
+ :args_string=>"int Trinity, unsigned int* Neo",
635
+ :args_call=>"Trinity, Neo" }
636
+ assert_equal(expected, @parser.parse_declaration(source))
637
+ end
638
+
639
+ it "extract c calling conventions properly" do
640
+
641
+ source = "const int __stdcall TheMatrix(int Trinity, unsigned int * Neo)"
642
+ expected = { :var_arg=>nil,
643
+ :return=>{ :type => "int",
644
+ :name => 'cmock_to_return',
645
+ :ptr? => false,
646
+ :const? => true,
647
+ :str => "int cmock_to_return",
648
+ :void? => false
649
+ },
650
+ :name=>"TheMatrix",
651
+ :modifier=>"const",
652
+ :c_calling_convention=>"__stdcall",
653
+ :contains_ptr? => true,
654
+ :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false},
655
+ {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false}
656
+ ],
657
+ :args_string=>"int Trinity, unsigned int* Neo",
658
+ :args_call=>"Trinity, Neo" }
659
+ assert_equal(expected, @parser.parse_declaration(source))
660
+ end
661
+
662
+ it "fully parse multiple prototypes" do
663
+
664
+ source = "const int TheMatrix(int Trinity, unsigned int * Neo);\n" +
665
+ "int Morpheus(int, unsigned int*);\n"
666
+
667
+ expected = [{ :var_arg=>nil,
668
+ :return=> { :type => "int",
669
+ :name => 'cmock_to_return',
670
+ :ptr? => false,
671
+ :const? => true,
672
+ :str => "int cmock_to_return",
673
+ :void? => false
674
+ },
675
+ :name=>"TheMatrix",
676
+ :modifier=>"const",
677
+ :contains_ptr? => true,
678
+ :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false},
679
+ {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false}
680
+ ],
681
+ :args_string=>"int Trinity, unsigned int* Neo",
682
+ :args_call=>"Trinity, Neo" },
683
+ { :var_arg=>nil,
684
+ :return=> { :type => "int",
685
+ :name => 'cmock_to_return',
686
+ :ptr? => false,
687
+ :const? => false,
688
+ :str => "int cmock_to_return",
689
+ :void? => false
690
+ },
691
+ :name=>"Morpheus",
692
+ :modifier=>"",
693
+ :contains_ptr? => true,
694
+ :args=>[ {:type=>"int", :name=>"cmock_arg1", :ptr? => false, :const? => false},
695
+ {:type=>"unsigned int*", :name=>"cmock_arg2", :ptr? => true, :const? => false}
696
+ ],
697
+ :args_string=>"int cmock_arg1, unsigned int* cmock_arg2",
698
+ :args_call=>"cmock_arg1, cmock_arg2"
699
+ }]
700
+ assert_equal(expected, @parser.parse("module", source)[:functions])
701
+ end
702
+
703
+ it "not extract for mocking multiply defined prototypes" do
704
+
705
+ source = "const int TheMatrix(int Trinity, unsigned int * Neo);\n" +
706
+ "const int TheMatrix(int, unsigned int*);\n"
707
+
708
+ expected = [{ :var_arg=>nil,
709
+ :name=>"TheMatrix",
710
+ :return=> { :type => "int",
711
+ :name => 'cmock_to_return',
712
+ :ptr? => false,
713
+ :const? => true,
714
+ :str => "int cmock_to_return",
715
+ :void? => false
716
+ },
717
+ :modifier=>"const",
718
+ :contains_ptr? => true,
719
+ :args=>[ {:type=>"int", :name=>"Trinity", :ptr? => false, :const? => false},
720
+ {:type=>"unsigned int*", :name=>"Neo", :ptr? => true, :const? => false}
721
+ ],
722
+ :args_string=>"int Trinity, unsigned int* Neo",
723
+ :args_call=>"Trinity, Neo"
724
+ }]
725
+ assert_equal(expected, @parser.parse("module", source)[:functions])
726
+ end
727
+
728
+ it "properly detect typedef'd variants of void and use those" do
729
+
730
+ source = "typedef (void) FUNKY_VOID_T;\n" +
731
+ "typedef void CHUNKY_VOID_T;\n" +
732
+ "FUNKY_VOID_T DrHorrible(int SingAlong);\n" +
733
+ "int CaptainHammer(CHUNKY_VOID_T);\n"
734
+
735
+ expected = [{ :var_arg=>nil,
736
+ :name=>"DrHorrible",
737
+ :return => { :type => "void",
738
+ :name => 'cmock_to_return',
739
+ :ptr? => false,
740
+ :const? => false,
741
+ :str => "void cmock_to_return",
742
+ :void? => true
743
+ },
744
+ :modifier=>"",
745
+ :contains_ptr? => false,
746
+ :args=>[ {:type=>"int", :name=>"SingAlong", :ptr? => false, :const? => false} ],
747
+ :args_string=>"int SingAlong",
748
+ :args_call=>"SingAlong"
749
+ },
750
+ { :var_arg=>nil,
751
+ :return=> { :type => "int",
752
+ :name => 'cmock_to_return',
753
+ :ptr? => false,
754
+ :const? => false,
755
+ :str => "int cmock_to_return",
756
+ :void? => false
757
+ },
758
+ :name=>"CaptainHammer",
759
+ :modifier=>"",
760
+ :contains_ptr? => false,
761
+ :args=>[ ],
762
+ :args_string=>"void",
763
+ :args_call=>""
764
+ }]
765
+ assert_equal(expected, @parser.parse("module", source)[:functions])
766
+ end
767
+
768
+ it "be ok with structs inside of function declarations" do
769
+
770
+ source = "int DrHorrible(struct SingAlong Blog);\n" +
771
+ "void Penny(struct const _KeepYourHeadUp_ * const BillyBuddy);\n" +
772
+ "struct TheseArentTheHammer CaptainHammer(void);\n"
773
+
774
+ expected = [{ :var_arg=>nil,
775
+ :return =>{ :type => "int",
776
+ :name => 'cmock_to_return',
777
+ :ptr? => false,
778
+ :const? => false,
779
+ :str => "int cmock_to_return",
780
+ :void? => false
781
+ },
782
+ :name=>"DrHorrible",
783
+ :modifier=>"",
784
+ :contains_ptr? => false,
785
+ :args=>[ {:type=>"struct SingAlong", :name=>"Blog", :ptr? => false, :const? => false} ],
786
+ :args_string=>"struct SingAlong Blog",
787
+ :args_call=>"Blog"
788
+ },
789
+ { :var_arg=>nil,
790
+ :return=> { :type => "void",
791
+ :name => 'cmock_to_return',
792
+ :ptr? => false,
793
+ :const? => false,
794
+ :str => "void cmock_to_return",
795
+ :void? => true
796
+ },
797
+ :name=>"Penny",
798
+ :modifier=>"",
799
+ :contains_ptr? => true,
800
+ :args=>[ {:type=>"struct _KeepYourHeadUp_*", :name=>"BillyBuddy", :ptr? => true, :const? => true} ],
801
+ :args_string=>"struct const _KeepYourHeadUp_* const BillyBuddy",
802
+ :args_call=>"BillyBuddy"
803
+ },
804
+ { :var_arg=>nil,
805
+ :return=> { :type => "struct TheseArentTheHammer",
806
+ :name => 'cmock_to_return',
807
+ :ptr? => false,
808
+ :const? => false,
809
+ :str => "struct TheseArentTheHammer cmock_to_return",
810
+ :void? => false
811
+ },
812
+ :name=>"CaptainHammer",
813
+ :modifier=>"",
814
+ :contains_ptr? => false,
815
+ :args=>[ ],
816
+ :args_string=>"void",
817
+ :args_call=>""
818
+ }]
819
+ assert_equal(expected, @parser.parse("module", source)[:functions])
820
+ end
821
+
822
+ it "extract functions containing unions with union specifier" do
823
+ source = "void OrangePeel(union STARS_AND_STRIPES * a, union AFL_CIO b)"
824
+ expected = [{ :var_arg=>nil,
825
+ :return=>{ :type => "void",
826
+ :name => 'cmock_to_return',
827
+ :ptr? => false,
828
+ :const? => false,
829
+ :str => "void cmock_to_return",
830
+ :void? => true
831
+ },
832
+ :name=>"OrangePeel",
833
+ :modifier=>"",
834
+ :contains_ptr? => true,
835
+ :args=>[ {:type=>"union STARS_AND_STRIPES*", :name=>"a", :ptr? => true, :const? => false},
836
+ {:type=>"union AFL_CIO", :name=>"b", :ptr? => false, :const? => false}
837
+ ],
838
+ :args_string=>"union STARS_AND_STRIPES* a, union AFL_CIO b",
839
+ :args_call=>"a, b" }]
840
+ result = @parser.parse("module", source)
841
+ assert_equal(expected, result[:functions])
842
+ end
843
+
844
+ it "not be thwarted by variables named with primitive types as part of the name" do
845
+ source = "void ApplePeel(const unsigned int const_param, int int_param, int integer, char character, int* const constant)"
846
+ expected = [{ :var_arg=>nil,
847
+ :return=>{ :type => "void",
848
+ :name => 'cmock_to_return',
849
+ :ptr? => false,
850
+ :const? => false,
851
+ :str => "void cmock_to_return",
852
+ :void? => true
853
+ },
854
+ :name=>"ApplePeel",
855
+ :modifier=>"",
856
+ :contains_ptr? => true,
857
+ :args=>[ {:type=> "unsigned int", :name=>"const_param", :ptr? => false, :const? => true},
858
+ {:type=>"int", :name=>"int_param", :ptr? => false, :const? => false},
859
+ {:type=>"int", :name=>"integer", :ptr? => false, :const? => false},
860
+ {:type=>"char", :name=>"character", :ptr? => false, :const? => false},
861
+ {:type=>"int*", :name=>"constant", :ptr? => true, :const? => true}
862
+ ],
863
+ :args_string=>"const unsigned int const_param, int int_param, int integer, char character, int* const constant",
864
+ :args_call=>"const_param, int_param, integer, character, constant" }]
865
+ result = @parser.parse("module", source)
866
+ assert_equal(expected, result[:functions])
867
+ end
868
+
869
+ it "not be thwarted by custom types named similarly to primitive types" do
870
+ source = "void LemonPeel(integer param, character thing, longint * junk, constant value, int32_t const number)"
871
+ expected = [{:var_arg=>nil,
872
+ :return=>{ :type => "void",
873
+ :name => 'cmock_to_return',
874
+ :ptr? => false,
875
+ :const? => false,
876
+ :str => "void cmock_to_return",
877
+ :void? => true
878
+ },
879
+ :name=>"LemonPeel",
880
+ :modifier=>"",
881
+ :contains_ptr? => true,
882
+ :args=>[ {:type=>"integer", :name=>"param", :ptr? => false, :const? => false},
883
+ {:type=>"character", :name=>"thing", :ptr? => false, :const? => false},
884
+ {:type=>"longint*", :name=>"junk", :ptr? => true, :const? => false},
885
+ {:type=>"constant", :name=>"value", :ptr? => false, :const? => false},
886
+ {:type=>"int32_t", :name=>"number", :ptr? => false, :const? => true}
887
+ ],
888
+ :args_string=>"integer param, character thing, longint* junk, constant value, int32_t const number",
889
+ :args_call=>"param, thing, junk, value, number" }]
890
+ result = @parser.parse("module", source)
891
+ assert_equal(expected, result[:functions])
892
+ end
893
+
894
+ it "handle some of those chains of C name specifiers naturally" do
895
+ source = "void CoinOperated(signed char abc, const unsigned long int xyz_123, unsigned int const abc_123, long long arm_of_the_law)"
896
+ expected = [{:var_arg=>nil,
897
+ :return=>{ :type => "void",
898
+ :name => 'cmock_to_return',
899
+ :ptr? => false,
900
+ :const? => false,
901
+ :str => "void cmock_to_return",
902
+ :void? => true
903
+ },
904
+ :name=>"CoinOperated",
905
+ :modifier=>"",
906
+ :contains_ptr? => false,
907
+ :args=>[ {:type=>"signed char", :name=>"abc", :ptr? => false, :const? => false},
908
+ {:type=>"unsigned long int", :name=>"xyz_123", :ptr? => false, :const? => true},
909
+ {:type=>"unsigned int", :name=>"abc_123", :ptr? => false, :const? => true},
910
+ {:type=>"long long", :name=>"arm_of_the_law", :ptr? => false, :const? => false}
911
+ ],
912
+ :args_string=>"signed char abc, const unsigned long int xyz_123, unsigned int const abc_123, long long arm_of_the_law",
913
+ :args_call=>"abc, xyz_123, abc_123, arm_of_the_law" }]
914
+ result = @parser.parse("module", source)
915
+ assert_equal(expected, result[:functions])
916
+ end
917
+
918
+ it "handle custom types of various formats" do
919
+ source = "void CardOperated(CUSTOM_TYPE abc, CUSTOM_TYPE* xyz_123, CUSTOM_TYPE const abcxyz, struct CUSTOM_TYPE const * const abc123)"
920
+ expected = [{:var_arg=>nil,
921
+ :return=>{ :type => "void",
922
+ :name => 'cmock_to_return',
923
+ :ptr? => false,
924
+ :const? => false,
925
+ :str => "void cmock_to_return",
926
+ :void? => true
927
+ },
928
+ :name=>"CardOperated",
929
+ :modifier=>"",
930
+ :contains_ptr? => true,
931
+ :args=>[ {:type=>"CUSTOM_TYPE", :name=>"abc", :ptr? => false, :const? => false},
932
+ {:type=>"CUSTOM_TYPE*", :name=>"xyz_123", :ptr? => true, :const? => false},
933
+ {:type=>"CUSTOM_TYPE", :name=>"abcxyz", :ptr? => false, :const? => true},
934
+ {:type=>"struct CUSTOM_TYPE const*", :name=>"abc123", :ptr? => true, :const? => true}
935
+ ],
936
+ :args_string=>"CUSTOM_TYPE abc, CUSTOM_TYPE* xyz_123, CUSTOM_TYPE const abcxyz, struct CUSTOM_TYPE const* const abc123",
937
+ :args_call=>"abc, xyz_123, abcxyz, abc123" }]
938
+ result = @parser.parse("module", source)
939
+ assert_equal(expected, result[:functions])
940
+ end
941
+
942
+ it "handle arrays and treat them as pointers" do
943
+ source = "void KeyOperated(CUSTOM_TYPE thing1[], int thing2 [ ], char thing3 [][2 ][ 3], int* thing4[4])"
944
+ expected = [{:var_arg=>nil,
945
+ :return=>{ :type => "void",
946
+ :name => 'cmock_to_return',
947
+ :ptr? => false,
948
+ :const? => false,
949
+ :str => "void cmock_to_return",
950
+ :void? => true
951
+ },
952
+ :name=>"KeyOperated",
953
+ :modifier=>"",
954
+ :contains_ptr? => true,
955
+ :args=>[ {:type=>"CUSTOM_TYPE*", :name=>"thing1", :ptr? => true, :const? => false},
956
+ {:type=>"int*", :name=>"thing2", :ptr? => true, :const? => false},
957
+ {:type=>"char*", :name=>"thing3", :ptr? => false, :const? => false}, #THIS one will likely change in the future when we improve multidimensional array support
958
+ {:type=>"int**", :name=>"thing4", :ptr? => true, :const? => false} #THIS one will likely change in the future when we improve multidimensional array support
959
+ ],
960
+ :args_string=>"CUSTOM_TYPE* thing1, int* thing2, char* thing3, int** thing4",
961
+ :args_call=>"thing1, thing2, thing3, thing4" }]
962
+ result = @parser.parse("module", source)
963
+ assert_equal(expected, result[:functions])
964
+ end
965
+
966
+ it "give a reasonable guess when dealing with weird combinations of custom types and modifiers" do
967
+ source = "void Cheese(unsigned CUSTOM_TYPE abc, unsigned xyz, CUSTOM_TYPE1 CUSTOM_TYPE2 pdq)"
968
+ expected = [{:var_arg=>nil,
969
+ :return=>{ :type => "void",
970
+ :name => 'cmock_to_return',
971
+ :ptr? => false,
972
+ :const? => false,
973
+ :str => "void cmock_to_return",
974
+ :void? => true
975
+ },
976
+ :name=>"Cheese",
977
+ :modifier=>"",
978
+ :contains_ptr? => false,
979
+ :args=>[ {:type=>"unsigned CUSTOM_TYPE", :name=>"abc", :ptr? => false, :const? => false},
980
+ {:type=>"unsigned", :name=>"xyz", :ptr? => false, :const? => false},
981
+ {:type=>"CUSTOM_TYPE1 CUSTOM_TYPE2", :name=>"pdq", :ptr? => false, :const? => false}
982
+ ],
983
+ :args_string=>"unsigned CUSTOM_TYPE abc, unsigned xyz, CUSTOM_TYPE1 CUSTOM_TYPE2 pdq",
984
+ :args_call=>"abc, xyz, pdq" }]
985
+ result = @parser.parse("module", source)
986
+ assert_equal(expected, result[:functions])
987
+ end
988
+
989
+ it "extract functions containing a function pointer" do
990
+ source = "void FunkyTurkey(unsigned int (*func_ptr)(int, char))"
991
+ expected = [{ :var_arg=>nil,
992
+ :return=>{ :type => "void",
993
+ :name => 'cmock_to_return',
994
+ :ptr? => false,
995
+ :const? => false,
996
+ :str => "void cmock_to_return",
997
+ :void? => true
998
+ },
999
+ :name=>"FunkyTurkey",
1000
+ :modifier=>"",
1001
+ :contains_ptr? => false,
1002
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false}
1003
+ ],
1004
+ :args_string=>"cmock_module_func_ptr1 func_ptr",
1005
+ :args_call=>"func_ptr" }]
1006
+ typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char);"]
1007
+ result = @parser.parse("module", source)
1008
+ assert_equal(expected, result[:functions])
1009
+ assert_equal(typedefs, result[:typedefs])
1010
+ end
1011
+
1012
+ it "extract functions containing a function pointer with a void" do
1013
+ source = "void FunkyTurkey(void (*func_ptr)(void))"
1014
+ expected = [{ :var_arg=>nil,
1015
+ :return=>{ :type => "void",
1016
+ :name => 'cmock_to_return',
1017
+ :ptr? => false,
1018
+ :const? => false,
1019
+ :str => "void cmock_to_return",
1020
+ :void? => true
1021
+ },
1022
+ :name=>"FunkyTurkey",
1023
+ :modifier=>"",
1024
+ :contains_ptr? => false,
1025
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false}
1026
+ ],
1027
+ :args_string=>"cmock_module_func_ptr1 func_ptr",
1028
+ :args_call=>"func_ptr" }]
1029
+ typedefs = ["typedef void(*cmock_module_func_ptr1)(void);"]
1030
+ result = @parser.parse("module", source)
1031
+ assert_equal(expected, result[:functions])
1032
+ assert_equal(typedefs, result[:typedefs])
1033
+ end
1034
+
1035
+ it "extract functions containing a function pointer with an implied void" do
1036
+ source = "void FunkyTurkey(unsigned int (*func_ptr)())"
1037
+ expected = [{ :var_arg=>nil,
1038
+ :return=>{ :type => "void",
1039
+ :name => 'cmock_to_return',
1040
+ :ptr? => false,
1041
+ :const? => false,
1042
+ :str => "void cmock_to_return",
1043
+ :void? => true
1044
+ },
1045
+ :name=>"FunkyTurkey",
1046
+ :modifier=>"",
1047
+ :contains_ptr? => false,
1048
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false}
1049
+ ],
1050
+ :args_string=>"cmock_module_func_ptr1 func_ptr",
1051
+ :args_call=>"func_ptr" }]
1052
+ typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)();"]
1053
+ result = @parser.parse("module", source)
1054
+ assert_equal(expected, result[:functions])
1055
+ assert_equal(typedefs, result[:typedefs])
1056
+ end
1057
+
1058
+ it "extract functions containing a constant function pointer and a pointer in the nested arg list" do
1059
+ source = "void FunkyChicken(unsigned int (* const func_ptr)(unsigned long int * , char))"
1060
+ expected = [{ :var_arg=>nil,
1061
+ :return=>{ :type => "void",
1062
+ :name => 'cmock_to_return',
1063
+ :ptr? => false,
1064
+ :const? => false,
1065
+ :str => "void cmock_to_return",
1066
+ :void? => true
1067
+ },
1068
+ :name=>"FunkyChicken",
1069
+ :modifier=>"",
1070
+ :contains_ptr? => false,
1071
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => true}
1072
+ ],
1073
+ :args_string=>"cmock_module_func_ptr1 const func_ptr",
1074
+ :args_call=>"func_ptr" }]
1075
+ typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(unsigned long int* , char);"]
1076
+ result = @parser.parse("module", source)
1077
+ assert_equal(expected, result[:functions])
1078
+ assert_equal(typedefs, result[:typedefs])
1079
+ end
1080
+
1081
+ # it "extract functions containing a function pointer taking a vararg" do
1082
+ # source = "void FunkyParrot(unsigned int (*func_ptr)(int, char, ...))"
1083
+ # expected = [{ :var_arg=>nil,
1084
+ # :return=>{ :type => "void",
1085
+ # :name => 'cmock_to_return',
1086
+ # :ptr? => false,
1087
+ # :const? => false,
1088
+ # :str => "void cmock_to_return",
1089
+ # :void? => true
1090
+ # },
1091
+ # :name=>"FunkyParrot",
1092
+ # :modifier=>"",
1093
+ # :contains_ptr? => false,
1094
+ # :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr", :ptr? => false, :const? => false}
1095
+ # ],
1096
+ # :args_string=>"cmock_module_func_ptr1 func_ptr",
1097
+ # :args_call=>"func_ptr" }]
1098
+ # typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char, ...);"]
1099
+ # result = @parser.parse("module", source)
1100
+ # assert_equal(expected, result[:functions])
1101
+ # assert_equal(typedefs, result[:typedefs])
1102
+ # end
1103
+
1104
+ it "extract functions containing a function pointer with extra parenthesis and two sets" do
1105
+ source = "void FunkyBudgie(int (((* func_ptr1)(int, char))), void (*func_ptr2)(void))"
1106
+ expected = [{ :var_arg=>nil,
1107
+ :return=>{ :type => "void",
1108
+ :name => 'cmock_to_return',
1109
+ :ptr? => false,
1110
+ :const? => false,
1111
+ :str => "void cmock_to_return",
1112
+ :void? => true
1113
+ },
1114
+ :name=>"FunkyBudgie",
1115
+ :modifier=>"",
1116
+ :contains_ptr? => false,
1117
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr1", :ptr? => false, :const? => false},
1118
+ {:type=>"cmock_module_func_ptr2", :name=>"func_ptr2", :ptr? => false, :const? => false}
1119
+ ],
1120
+ :args_string=>"cmock_module_func_ptr1 func_ptr1, cmock_module_func_ptr2 func_ptr2",
1121
+ :args_call=>"func_ptr1, func_ptr2" }]
1122
+ typedefs = ["typedef int(*cmock_module_func_ptr1)(int, char);", "typedef void(*cmock_module_func_ptr2)(void);"]
1123
+ result = @parser.parse("module", source)
1124
+ assert_equal(expected, result[:functions])
1125
+ assert_equal(typedefs, result[:typedefs])
1126
+ end
1127
+
1128
+ it "extract functions containing a function pointers, structs and other things" do
1129
+ source = "struct mytype *FunkyRobin(uint16_t num1, uint16_t num2, void (*func_ptr1)(uint16_t num3, struct mytype2 *s));"
1130
+ expected = [{ :var_arg=>nil,
1131
+ :return=>{ :type => "struct mytype*",
1132
+ :name => 'cmock_to_return',
1133
+ :ptr? => true,
1134
+ :const? => false,
1135
+ :str => "struct mytype* cmock_to_return",
1136
+ :void? => false
1137
+ },
1138
+ :name=>"FunkyRobin",
1139
+ :modifier=>"",
1140
+ :contains_ptr? => false,
1141
+ :args=>[ {:type=>"uint16_t", :name=>"num1", :ptr? => false, :const? => false},
1142
+ {:type=>"uint16_t", :name=>"num2", :ptr? => false, :const? => false},
1143
+ {:type=>"cmock_module_func_ptr1", :name=>"func_ptr1", :ptr? => false, :const? => false}
1144
+ ],
1145
+ :args_string=>"uint16_t num1, uint16_t num2, cmock_module_func_ptr1 func_ptr1",
1146
+ :args_call=>"num1, num2, func_ptr1" }]
1147
+ typedefs = ["typedef void(*cmock_module_func_ptr1)(uint16_t num3, struct mytype2* s);"]
1148
+ result = @parser.parse("module", source)
1149
+ assert_equal(expected, result[:functions])
1150
+ assert_equal(typedefs, result[:typedefs])
1151
+ end
1152
+
1153
+ it "extract functions containing an anonymous function pointer" do
1154
+ source = "void FunkyFowl(unsigned int (* const)(int, char))"
1155
+ expected = [{ :var_arg=>nil,
1156
+ :return=>{ :type => "void",
1157
+ :name => 'cmock_to_return',
1158
+ :ptr? => false,
1159
+ :const? => false,
1160
+ :str => "void cmock_to_return",
1161
+ :void? => true
1162
+ },
1163
+ :name=>"FunkyFowl",
1164
+ :modifier=>"",
1165
+ :contains_ptr? => false,
1166
+ :args=>[ {:type=>"cmock_module_func_ptr1", :name=>"cmock_arg1", :ptr? => false, :const? => true}
1167
+ ],
1168
+ :args_string=>"cmock_module_func_ptr1 const cmock_arg1",
1169
+ :args_call=>"cmock_arg1" }]
1170
+ typedefs = ["typedef unsigned int(*cmock_module_func_ptr1)(int, char);"]
1171
+ result = @parser.parse("module", source)
1172
+ assert_equal(expected, result[:functions])
1173
+ assert_equal(typedefs, result[:typedefs])
1174
+ end
1175
+
1176
+ it "extract functions returning a function pointer" do
1177
+ source = "unsigned short (*FunkyPidgeon( const char op_code ))( int, long int )"
1178
+ expected = [{ :var_arg=>nil,
1179
+ :return=>{ :type => "cmock_module_func_ptr1",
1180
+ :name => 'cmock_to_return',
1181
+ :ptr? => false,
1182
+ :const? => false,
1183
+ :str => "cmock_module_func_ptr1 cmock_to_return",
1184
+ :void? => false
1185
+ },
1186
+ :name=>"FunkyPidgeon",
1187
+ :modifier=>"",
1188
+ :contains_ptr? => false,
1189
+ :args=>[ {:type=>"char", :name=>"op_code", :ptr? => false, :const? => true}
1190
+ ],
1191
+ :args_string=>"const char op_code",
1192
+ :args_call=>"op_code" }]
1193
+ typedefs = ["typedef unsigned short(*cmock_module_func_ptr1)( int, long int );"]
1194
+ result = @parser.parse("module", source)
1195
+ assert_equal(expected, result[:functions])
1196
+ assert_equal(typedefs, result[:typedefs])
1197
+ end
1198
+
1199
+ it "extract functions returning a function pointer with implied void" do
1200
+ source = "unsigned short (*FunkyTweetie())()"
1201
+ expected = [{ :var_arg=>nil,
1202
+ :return=>{ :type => "cmock_module_func_ptr1",
1203
+ :name => 'cmock_to_return',
1204
+ :ptr? => false,
1205
+ :const? => false,
1206
+ :str => "cmock_module_func_ptr1 cmock_to_return",
1207
+ :void? => false
1208
+ },
1209
+ :name=>"FunkyTweetie",
1210
+ :modifier=>"",
1211
+ :contains_ptr? => false,
1212
+ :args=>[],
1213
+ :args_string=>"void",
1214
+ :args_call=>"" }]
1215
+ typedefs = ["typedef unsigned short(*cmock_module_func_ptr1)();"]
1216
+ result = @parser.parse("module", source)
1217
+ assert_equal(expected, result[:functions])
1218
+ assert_equal(typedefs, result[:typedefs])
1219
+ end
1220
+
1221
+ it "extract functions returning a function pointer where everything is a void" do
1222
+ source = "void (* FunkySeaGull(void))(void)"
1223
+ expected = [{ :var_arg=>nil,
1224
+ :return=>{ :type => "cmock_module_func_ptr1",
1225
+ :name => 'cmock_to_return',
1226
+ :ptr? => false,
1227
+ :const? => false,
1228
+ :str => "cmock_module_func_ptr1 cmock_to_return",
1229
+ :void? => false
1230
+ },
1231
+ :name=>"FunkySeaGull",
1232
+ :modifier=>"",
1233
+ :contains_ptr? => false,
1234
+ :args=>[],
1235
+ :args_string=>"void",
1236
+ :args_call=>"" }]
1237
+ typedefs = ["typedef void(*cmock_module_func_ptr1)(void);"]
1238
+ result = @parser.parse("module", source)
1239
+ assert_equal(expected, result[:functions])
1240
+ assert_equal(typedefs, result[:typedefs])
1241
+ end
1242
+
1243
+ it "extract functions returning a function pointer with some pointer nonsense" do
1244
+ source = "unsigned int * (* FunkyMacaw(double* foo, THING *bar))(unsigned int)"
1245
+ expected = [{ :var_arg=>nil,
1246
+ :return=>{ :type => "cmock_module_func_ptr1",
1247
+ :name => 'cmock_to_return',
1248
+ :ptr? => false,
1249
+ :const? => false,
1250
+ :str => "cmock_module_func_ptr1 cmock_to_return",
1251
+ :void? => false
1252
+ },
1253
+ :name=>"FunkyMacaw",
1254
+ :modifier=>"",
1255
+ :contains_ptr? => true,
1256
+ :args=>[ {:type=>"double*", :name=>"foo", :ptr? => true, :const? => false},
1257
+ {:type=>"THING*", :name=>"bar", :ptr? => true, :const? => false}
1258
+ ],
1259
+ :args_string=>"double* foo, THING* bar",
1260
+ :args_call=>"foo, bar" }]
1261
+ typedefs = ["typedef unsigned int *(*cmock_module_func_ptr1)(unsigned int);"]
1262
+ result = @parser.parse("module", source)
1263
+ assert_equal(expected, result[:functions])
1264
+ assert_equal(typedefs, result[:typedefs])
1265
+ end
1266
+
1267
+ it "extract this SQLite3 function with an anonymous function pointer arg (regression test)" do
1268
+ source = "SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*))"
1269
+ expected = [{ :var_arg=>nil,
1270
+ :return=>{ :type => "int",
1271
+ :name => "cmock_to_return",
1272
+ :ptr? => false,
1273
+ :const? => false,
1274
+ :str => "int cmock_to_return",
1275
+ :void? => false
1276
+ },
1277
+ :name=>"sqlite3_bind_text",
1278
+ :modifier=>"SQLITE_API",
1279
+ :contains_ptr? => true,
1280
+ :args=>[ {:type=>"sqlite3_stmt*", :name=>"cmock_arg2", :ptr? => true, :const? => false},
1281
+ {:type=>"int", :name=>"cmock_arg3", :ptr? => false, :const? => false},
1282
+ {:type=>"char*", :name=>"cmock_arg4", :ptr? => false, :const? => true},
1283
+ {:type=>"int", :name=>"n", :ptr? => false, :const? => false},
1284
+ {:type=>"cmock_module_func_ptr1", :name=>"cmock_arg1", :ptr? => false, :const? => false}
1285
+ ],
1286
+ :args_string=>"sqlite3_stmt* cmock_arg2, int cmock_arg3, const char* cmock_arg4, int n, cmock_module_func_ptr1 cmock_arg1",
1287
+ :args_call=>"cmock_arg2, cmock_arg3, cmock_arg4, n, cmock_arg1" }]
1288
+ typedefs = ["typedef void(*cmock_module_func_ptr1)(void*);"]
1289
+ result = @parser.parse("module", source)
1290
+ assert_equal(expected, result[:functions])
1291
+ assert_equal(typedefs, result[:typedefs])
1292
+ end
1293
+
1294
+ it "extract functions with varargs" do
1295
+ source = "int XFiles(int Scully, int Mulder, ...);\n"
1296
+ expected = [{ :var_arg=>"...",
1297
+ :return=> { :type => "int",
1298
+ :name => 'cmock_to_return',
1299
+ :ptr? => false,
1300
+ :const? => false,
1301
+ :str => "int cmock_to_return",
1302
+ :void? => false
1303
+ },
1304
+ :name=>"XFiles",
1305
+ :modifier=>"",
1306
+ :contains_ptr? => false,
1307
+ :args=>[ {:type=>"int", :name=>"Scully", :ptr? => false, :const? => false},
1308
+ {:type=>"int", :name=>"Mulder", :ptr? => false, :const? => false}
1309
+ ],
1310
+ :args_string=>"int Scully, int Mulder",
1311
+ :args_call=>"Scully, Mulder"
1312
+ }]
1313
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1314
+ end
1315
+
1316
+ it "extract functions with void pointers" do
1317
+ source = "void* MoreSillySongs(void* stuff);\n"
1318
+ expected = [{ :var_arg=>nil,
1319
+ :return=> { :type => "void*",
1320
+ :name => 'cmock_to_return',
1321
+ :ptr? => true,
1322
+ :const? => false,
1323
+ :str => "void* cmock_to_return",
1324
+ :void? => false
1325
+ },
1326
+ :name=>"MoreSillySongs",
1327
+ :modifier=>"",
1328
+ :contains_ptr? => true,
1329
+ :args=>[ {:type=>"void*", :name=>"stuff", :ptr? => true, :const? => false}
1330
+ ],
1331
+ :args_string=>"void* stuff",
1332
+ :args_call=>"stuff"
1333
+ }]
1334
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1335
+ end
1336
+
1337
+ it "extract functions with strippable confusing junk like gcc attributes" do
1338
+ source = "int LaverneAndShirley(int Lenny, int Squiggy) __attribute__((weak)) __attribute__ ((deprecated));\n"
1339
+ expected = [{ :var_arg=>nil,
1340
+ :return=> { :type => "int",
1341
+ :name => 'cmock_to_return',
1342
+ :ptr? => false,
1343
+ :const? => false,
1344
+ :str => "int cmock_to_return",
1345
+ :void? => false
1346
+ },
1347
+ :name=>"LaverneAndShirley",
1348
+ :modifier=>"",
1349
+ :contains_ptr? => false,
1350
+ :args=>[ {:type=>"int", :name=>"Lenny", :ptr? => false, :const? => false},
1351
+ {:type=>"int", :name=>"Squiggy", :ptr? => false, :const? => false}
1352
+ ],
1353
+ :args_string=>"int Lenny, int Squiggy",
1354
+ :args_call=>"Lenny, Squiggy"
1355
+ }]
1356
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1357
+ end
1358
+
1359
+ it "extract functions with strippable confusing junk like gcc attributes with parenthesis" do
1360
+ source = "int TheCosbyShow(int Cliff, int Claire) __attribute__((weak, alias (\"__f\"));\n"
1361
+ expected = [{ :var_arg=>nil,
1362
+ :return=> { :type => "int",
1363
+ :name => 'cmock_to_return',
1364
+ :ptr? => false,
1365
+ :const? => false,
1366
+ :str => "int cmock_to_return",
1367
+ :void? => false
1368
+ },
1369
+ :name=>"TheCosbyShow",
1370
+ :modifier=>"",
1371
+ :contains_ptr? => false,
1372
+ :args=>[ {:type=>"int", :name=>"Cliff", :ptr? => false, :const? => false},
1373
+ {:type=>"int", :name=>"Claire", :ptr? => false, :const? => false}
1374
+ ],
1375
+ :args_string=>"int Cliff, int Claire",
1376
+ :args_call=>"Cliff, Claire"
1377
+ }]
1378
+ assert_equal(expected, @parser.parse("module", source)[:functions])
1379
+ end
1380
+
1381
+ end