ceedling 0.13.0.rc1 → 0.13.0

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