ceedling 0.19.0 → 0.20.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (426) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +10 -10
  3. data/bin/ceedling +205 -92
  4. data/ceedling-0.19.0.gem +0 -0
  5. data/config/test_environment.rb +12 -12
  6. data/docs/CeedlingPacket.md +866 -853
  7. data/docs/CeedlingPacket.odt +0 -0
  8. data/docs/CeedlingPacket.pdf +0 -0
  9. data/examples/temp_sensor/rakefile.rb +4 -4
  10. data/examples/temp_sensor/src/AdcConductor.c +42 -42
  11. data/examples/temp_sensor/src/AdcConductor.h +13 -13
  12. data/examples/temp_sensor/src/AdcHardware.c +27 -27
  13. data/examples/temp_sensor/src/AdcHardware.h +11 -11
  14. data/examples/temp_sensor/src/AdcHardwareConfigurator.c +18 -18
  15. data/examples/temp_sensor/src/AdcHardwareConfigurator.h +10 -10
  16. data/examples/temp_sensor/src/AdcModel.c +33 -33
  17. data/examples/temp_sensor/src/AdcModel.h +13 -13
  18. data/examples/temp_sensor/src/AdcTemperatureSensor.c +51 -51
  19. data/examples/temp_sensor/src/AdcTemperatureSensor.h +10 -10
  20. data/examples/temp_sensor/src/Executor.c +25 -25
  21. data/examples/temp_sensor/src/Executor.h +9 -9
  22. data/examples/temp_sensor/src/IntrinsicsWrapper.c +18 -18
  23. data/examples/temp_sensor/src/IntrinsicsWrapper.h +7 -7
  24. data/examples/temp_sensor/src/Main.c +46 -46
  25. data/examples/temp_sensor/src/Main.h +7 -7
  26. data/examples/temp_sensor/src/Model.c +10 -10
  27. data/examples/temp_sensor/src/Model.h +8 -8
  28. data/examples/temp_sensor/src/ModelConfig.h +7 -7
  29. data/examples/temp_sensor/src/TaskScheduler.c +72 -72
  30. data/examples/temp_sensor/src/TaskScheduler.h +11 -11
  31. data/examples/temp_sensor/src/TemperatureCalculator.c +27 -27
  32. data/examples/temp_sensor/src/TemperatureCalculator.h +8 -8
  33. data/examples/temp_sensor/src/TemperatureFilter.c +38 -38
  34. data/examples/temp_sensor/src/TemperatureFilter.h +10 -10
  35. data/examples/temp_sensor/src/TimerConductor.c +15 -15
  36. data/examples/temp_sensor/src/TimerConductor.h +9 -9
  37. data/examples/temp_sensor/src/TimerConfigurator.c +51 -51
  38. data/examples/temp_sensor/src/TimerConfigurator.h +15 -15
  39. data/examples/temp_sensor/src/TimerHardware.c +15 -15
  40. data/examples/temp_sensor/src/TimerHardware.h +8 -8
  41. data/examples/temp_sensor/src/TimerInterruptConfigurator.c +55 -55
  42. data/examples/temp_sensor/src/TimerInterruptConfigurator.h +13 -13
  43. data/examples/temp_sensor/src/TimerInterruptHandler.c +25 -25
  44. data/examples/temp_sensor/src/TimerInterruptHandler.h +10 -10
  45. data/examples/temp_sensor/src/TimerModel.c +9 -9
  46. data/examples/temp_sensor/src/TimerModel.h +8 -8
  47. data/examples/temp_sensor/src/Types.h +90 -90
  48. data/examples/temp_sensor/src/UsartBaudRateRegisterCalculator.c +18 -18
  49. data/examples/temp_sensor/src/UsartBaudRateRegisterCalculator.h +8 -8
  50. data/examples/temp_sensor/src/UsartConductor.c +21 -21
  51. data/examples/temp_sensor/src/UsartConductor.h +7 -7
  52. data/examples/temp_sensor/src/UsartConfigurator.c +39 -39
  53. data/examples/temp_sensor/src/UsartConfigurator.h +13 -13
  54. data/examples/temp_sensor/src/UsartHardware.c +22 -22
  55. data/examples/temp_sensor/src/UsartHardware.h +9 -9
  56. data/examples/temp_sensor/src/UsartModel.c +34 -34
  57. data/examples/temp_sensor/src/UsartModel.h +10 -10
  58. data/examples/temp_sensor/src/UsartPutChar.c +16 -16
  59. data/examples/temp_sensor/src/UsartPutChar.h +8 -8
  60. data/examples/temp_sensor/src/UsartTransmitBufferStatus.c +7 -7
  61. data/examples/temp_sensor/src/UsartTransmitBufferStatus.h +8 -8
  62. data/examples/temp_sensor/test/TestAdcConductor.c +121 -121
  63. data/examples/temp_sensor/test/TestAdcHardware.c +44 -44
  64. data/examples/temp_sensor/test/TestAdcModel.c +33 -33
  65. data/examples/temp_sensor/test/TestExecutor.c +36 -36
  66. data/examples/temp_sensor/test/TestMain.c +24 -24
  67. data/examples/temp_sensor/test/TestModel.c +20 -20
  68. data/examples/temp_sensor/test/TestTaskScheduler.c +104 -104
  69. data/examples/temp_sensor/test/TestTemperatureCalculator.c +33 -33
  70. data/examples/temp_sensor/test/TestTemperatureFilter.c +79 -79
  71. data/examples/temp_sensor/test/TestTimerConductor.c +32 -32
  72. data/examples/temp_sensor/test/TestTimerHardware.c +26 -26
  73. data/examples/temp_sensor/test/TestTimerModel.c +18 -18
  74. data/examples/temp_sensor/test/TestUsartBaudRateRegisterCalculator.c +21 -21
  75. data/examples/temp_sensor/test/TestUsartConductor.c +40 -40
  76. data/examples/temp_sensor/test/TestUsartHardware.c +36 -36
  77. data/examples/temp_sensor/test/TestUsartModel.c +36 -36
  78. data/examples/temp_sensor/test/support/UnityHelper.c +12 -12
  79. data/examples/temp_sensor/test/support/UnityHelper.h +12 -12
  80. data/lib/ceedling/configurator_builder.rb +1 -1
  81. data/lib/ceedling/tasks_base.rake +10 -2
  82. data/lib/ceedling/tool_executor.rb +3 -0
  83. data/lib/ceedling/version.rb +3 -3
  84. data/license.txt +1 -1
  85. data/plugins/bullseye/bullseye.rake +162 -162
  86. data/plugins/gcov/gcov.rake +152 -152
  87. data/plugins/module_generator/lib/module_generator.rb +145 -145
  88. data/plugins/module_generator/module_generator.rake +14 -14
  89. data/plugins/stdout_gtestlike_tests_report/assets/template.erb +84 -0
  90. data/plugins/stdout_gtestlike_tests_report/assets/template.erb copy +59 -0
  91. data/plugins/stdout_gtestlike_tests_report/config/stdout_gtestlike_tests_report.yml +4 -0
  92. data/plugins/stdout_gtestlike_tests_report/lib/stdout_gtestlike_tests_report.rb +43 -0
  93. data/spec/system/deployment_spec.rb +0 -1
  94. data/test_graveyard/integration/paths_test.rb +80 -80
  95. data/test_graveyard/integration/rake_rules_aux_dependencies_test.rb +75 -75
  96. data/test_graveyard/integration/rake_rules_cmock_test.rb +74 -74
  97. data/test_graveyard/integration/rake_rules_preprocess_test.rb +178 -178
  98. data/test_graveyard/integration/rake_rules_test.rb +268 -268
  99. data/test_graveyard/integration/rake_tasks_test.rb +103 -103
  100. data/test_graveyard/integration_test_helper.rb +34 -34
  101. data/test_graveyard/rakefile_rules.rb +10 -10
  102. data/test_graveyard/rakefile_rules_aux_dependencies.rb +10 -10
  103. data/test_graveyard/rakefile_rules_cmock.rb +10 -10
  104. data/test_graveyard/rakefile_rules_preprocess.rb +10 -10
  105. data/test_graveyard/rakefile_tasks.rb +10 -10
  106. data/test_graveyard/system/file_system_test.rb +78 -78
  107. data/test_graveyard/system/project_mocks_test.rb +38 -38
  108. data/test_graveyard/system/project_simple_test.rb +39 -39
  109. data/test_graveyard/system/rule_mocks_test.rb +44 -44
  110. data/test_graveyard/system/rule_runners_test.rb +44 -44
  111. data/test_graveyard/system_test_helper.rb +73 -73
  112. data/test_graveyard/test_helper.rb +93 -93
  113. data/test_graveyard/unit/busted/configurator_builder_test.rb +569 -569
  114. data/test_graveyard/unit/busted/configurator_helper_test.rb +234 -234
  115. data/test_graveyard/unit/busted/configurator_test.rb +232 -232
  116. data/test_graveyard/unit/busted/configurator_validator_test.rb +169 -169
  117. data/test_graveyard/unit/busted/deep_merge_fix_test.rb +55 -55
  118. data/test_graveyard/unit/busted/dependinator_test.rb +129 -129
  119. data/test_graveyard/unit/busted/file_finder_helper_test.rb +45 -45
  120. data/test_graveyard/unit/busted/file_finder_test.rb +114 -114
  121. data/test_graveyard/unit/busted/file_path_utils_test.rb +97 -97
  122. data/test_graveyard/unit/busted/file_system_utils_test.rb +21 -21
  123. data/test_graveyard/unit/busted/generator_test.rb +187 -187
  124. data/test_graveyard/unit/busted/generator_test_results_test.rb +129 -129
  125. data/test_graveyard/unit/busted/generator_test_runner_test.rb +475 -475
  126. data/test_graveyard/unit/busted/preprocessinator_file_handler_test.rb +39 -39
  127. data/test_graveyard/unit/busted/preprocessinator_helper_test.rb +156 -156
  128. data/test_graveyard/unit/busted/preprocessinator_includes_handler_test.rb +93 -93
  129. data/test_graveyard/unit/busted/preprocessinator_test.rb +57 -57
  130. data/test_graveyard/unit/busted/project_file_loader_test.rb +142 -142
  131. data/test_graveyard/unit/busted/setupinator_test.rb +45 -45
  132. data/test_graveyard/unit/busted/streaminator_test.rb +49 -49
  133. data/test_graveyard/unit/busted/task_invoker_test.rb +69 -69
  134. data/test_graveyard/unit/busted/test_includes_extractor_test.rb +111 -111
  135. data/test_graveyard/unit/busted/test_invoker_helper_test.rb +62 -62
  136. data/test_graveyard/unit/busted/test_invoker_test.rb +47 -47
  137. data/test_graveyard/unit/busted/tool_executor_helper_test.rb +100 -100
  138. data/test_graveyard/unit/busted/tool_executor_test.rb +351 -351
  139. data/test_graveyard/unit/busted/verbosinator_test.rb +65 -65
  140. data/test_graveyard/unit/preprocessinator_extractor_test.rb +731 -731
  141. data/test_graveyard/unit_test_helper.rb +16 -16
  142. data/vendor/c_exception/LICENSE.txt +30 -30
  143. data/vendor/c_exception/README.md +11 -1
  144. data/vendor/c_exception/docs/CExceptionSummary.odt +0 -0
  145. data/vendor/c_exception/docs/CExceptionSummary.pdf +0 -0
  146. data/vendor/c_exception/docs/readme.txt +261 -242
  147. data/vendor/c_exception/lib/CException.c +46 -46
  148. data/vendor/c_exception/lib/CException.h +110 -86
  149. data/vendor/c_exception/makefile +23 -23
  150. data/vendor/c_exception/test/CExceptionConfig.h +46 -46
  151. data/vendor/c_exception/test/TestException.c +391 -342
  152. data/vendor/c_exception/test/TestException_Runner.c +5 -12
  153. data/vendor/c_exception/vendor/unity/README.md +211 -0
  154. data/vendor/c_exception/vendor/unity/auto/colour_prompt.rb +1 -1
  155. data/vendor/c_exception/vendor/unity/auto/colour_reporter.rb +38 -38
  156. data/vendor/c_exception/vendor/unity/auto/generate_config.yml +36 -36
  157. data/vendor/c_exception/vendor/unity/auto/generate_module.rb +202 -202
  158. data/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +391 -320
  159. data/vendor/c_exception/vendor/unity/auto/parseOutput.rb +2 -0
  160. data/vendor/c_exception/vendor/unity/auto/stylize_as_junit.rb +260 -0
  161. data/vendor/c_exception/vendor/unity/auto/type_sanitizer.rb +8 -0
  162. data/vendor/c_exception/vendor/unity/auto/unity_test_summary.py +135 -0
  163. data/vendor/c_exception/vendor/unity/auto/unity_test_summary.rb +148 -139
  164. data/vendor/c_exception/vendor/unity/docs/Unity Summary.odt +0 -0
  165. data/vendor/c_exception/vendor/unity/docs/Unity Summary.pdf +0 -0
  166. data/vendor/c_exception/vendor/unity/docs/Unity Summary.txt +224 -216
  167. data/vendor/c_exception/vendor/unity/docs/license.txt +21 -31
  168. data/vendor/c_exception/vendor/unity/examples/example_1/makefile +40 -15
  169. data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.c +2 -0
  170. data/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +32 -25
  171. data/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +29 -22
  172. data/vendor/c_exception/vendor/unity/examples/example_2/makefile +40 -14
  173. data/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode2.c +2 -0
  174. data/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/all_tests.c +2 -2
  175. data/vendor/c_exception/vendor/unity/examples/example_3/rakefile.rb +0 -1
  176. data/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode2.c +2 -0
  177. data/vendor/c_exception/vendor/unity/extras/fixture/rakefile.rb +48 -37
  178. data/vendor/c_exception/vendor/unity/extras/fixture/rakefile_helper.rb +179 -179
  179. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +135 -94
  180. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +13 -17
  181. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +12 -18
  182. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +30 -0
  183. data/vendor/c_exception/vendor/unity/extras/fixture/test/Makefile +60 -0
  184. data/vendor/c_exception/vendor/unity/extras/fixture/test/main/AllTests.c +4 -3
  185. data/vendor/c_exception/vendor/unity/extras/fixture/test/{testunity_fixture.c → template_fixture_tests.c} +0 -0
  186. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +182 -27
  187. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +13 -0
  188. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +8 -6
  189. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +2 -2
  190. data/vendor/c_exception/vendor/unity/release/build.info +1 -1
  191. data/vendor/c_exception/vendor/unity/release/version.info +1 -1
  192. data/vendor/c_exception/vendor/unity/src/unity.c +1333 -1145
  193. data/vendor/c_exception/vendor/unity/src/unity.h +290 -307
  194. data/vendor/c_exception/vendor/unity/src/unity_internals.h +758 -620
  195. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_cmd.c +7 -3
  196. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_def.c +7 -3
  197. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.c +55 -0
  198. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.h +15 -0
  199. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_cmd.c +4 -3
  200. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_def.c +4 -3
  201. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.c +75 -0
  202. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.h +13 -0
  203. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new1.c +6 -5
  204. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new2.c +4 -3
  205. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_param.c +4 -3
  206. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run1.c +6 -5
  207. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run2.c +4 -3
  208. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_yaml.c +7 -6
  209. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_new1.c +9 -5
  210. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_new2.c +7 -3
  211. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_param.c +7 -3
  212. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_run1.c +9 -5
  213. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_run2.c +7 -3
  214. data/vendor/c_exception/vendor/unity/test/expectdata/testsample_yaml.c +10 -6
  215. data/vendor/c_exception/vendor/unity/{rakefile.rb → test/rakefile} +60 -61
  216. data/vendor/c_exception/vendor/unity/{rakefile_helper.rb → test/rakefile_helper.rb} +255 -249
  217. data/vendor/c_exception/vendor/unity/test/targets/clang_file.yml +83 -0
  218. data/vendor/c_exception/vendor/unity/{targets → test/targets}/clang_strict.yml +83 -83
  219. data/vendor/c_exception/vendor/unity/test/targets/gcc_32.yml +49 -0
  220. data/vendor/c_exception/vendor/unity/test/targets/gcc_64.yml +50 -0
  221. data/vendor/c_exception/vendor/unity/{targets/gcc_64.yml → test/targets/gcc_auto_limits.yml} +46 -45
  222. data/vendor/c_exception/vendor/unity/test/targets/gcc_auto_sizeof.yml +47 -0
  223. data/vendor/c_exception/vendor/unity/test/targets/gcc_auto_stdint.yml +58 -0
  224. data/vendor/{cmock/vendor/c_exception/vendor/unity/targets/gcc_64.yml → c_exception/vendor/unity/test/targets/gcc_manual_math.yml} +46 -45
  225. data/vendor/{cmock/vendor/c_exception/vendor/unity → c_exception/vendor/unity/test}/targets/hitech_picc18.yml +101 -101
  226. data/vendor/{cmock/vendor/c_exception/vendor/unity → c_exception/vendor/unity/test}/targets/iar_arm_v4.yml +89 -89
  227. data/vendor/{cmock/vendor/c_exception/vendor/unity → c_exception/vendor/unity/test}/targets/iar_arm_v5.yml +79 -79
  228. data/vendor/c_exception/vendor/unity/{targets → test/targets}/iar_arm_v5_3.yml +79 -79
  229. data/vendor/{cmock/vendor/c_exception/vendor/unity → c_exception/vendor/unity/test}/targets/iar_armcortex_LM3S9B92_v5_4.yml +93 -93
  230. data/vendor/c_exception/vendor/unity/{targets → test/targets}/iar_cortexm3_v5.yml +83 -83
  231. data/vendor/{cmock/vendor/c_exception/vendor/unity → c_exception/vendor/unity/test}/targets/iar_msp430.yml +94 -94
  232. data/vendor/c_exception/vendor/unity/{targets → test/targets}/iar_sh2a_v6.yml +85 -85
  233. data/vendor/c_exception/vendor/unity/test/testdata/mocksample.c +51 -51
  234. data/vendor/c_exception/vendor/unity/test/testdata/sample.yml +8 -8
  235. data/vendor/c_exception/vendor/unity/test/testdata/testsample.c +68 -51
  236. data/vendor/{cmock/vendor/c_exception/vendor/unity/test → c_exception/vendor/unity/test/tests}/test_generate_test_runner.rb +102 -88
  237. data/vendor/{cmock/vendor/c_exception/vendor/unity/test → c_exception/vendor/unity/test/tests}/testparameterized.c +104 -101
  238. data/vendor/c_exception/vendor/unity/test/{testunity.c → tests/testunity.c} +3682 -3447
  239. data/vendor/cmock/docs/CMock_Summary.md +3 -0
  240. data/vendor/cmock/lib/cmock_config.rb +1 -0
  241. data/vendor/cmock/lib/cmock_file_writer.rb +7 -3
  242. data/vendor/cmock/lib/cmock_generator.rb +3 -2
  243. data/vendor/cmock/lib/cmock_header_parser.rb +12 -5
  244. data/vendor/cmock/release/version.info +1 -1
  245. data/vendor/cmock/test/system/test_compilation/parsing.h +3 -0
  246. data/vendor/cmock/test/unit/cmock_generator_main_test.rb +7 -0
  247. data/vendor/cmock/test/unit/cmock_header_parser_test.rb +57 -1
  248. data/vendor/cmock/vendor/c_exception/LICENSE.txt +30 -30
  249. data/vendor/cmock/vendor/c_exception/README.md +11 -1
  250. data/vendor/cmock/vendor/c_exception/docs/CExceptionSummary.odt +0 -0
  251. data/vendor/cmock/vendor/c_exception/docs/CExceptionSummary.pdf +0 -0
  252. data/vendor/cmock/vendor/c_exception/docs/readme.txt +261 -242
  253. data/vendor/cmock/vendor/c_exception/lib/CException.c +46 -46
  254. data/vendor/cmock/vendor/c_exception/lib/CException.h +110 -86
  255. data/vendor/cmock/vendor/c_exception/makefile +23 -23
  256. data/vendor/cmock/vendor/c_exception/test/CExceptionConfig.h +46 -46
  257. data/vendor/cmock/vendor/c_exception/test/TestException.c +391 -342
  258. data/vendor/cmock/vendor/c_exception/test/TestException_Runner.c +5 -12
  259. data/vendor/cmock/vendor/c_exception/vendor/unity/README.md +211 -0
  260. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/colour_prompt.rb +1 -1
  261. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/colour_reporter.rb +38 -38
  262. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_config.yml +36 -36
  263. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_module.rb +202 -202
  264. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +391 -320
  265. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/parseOutput.rb +2 -0
  266. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/stylize_as_junit.rb +260 -0
  267. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/type_sanitizer.rb +8 -0
  268. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/unity_test_summary.py +135 -0
  269. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/unity_test_summary.rb +148 -139
  270. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/Unity Summary.odt +0 -0
  271. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/Unity Summary.pdf +0 -0
  272. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/Unity Summary.txt +224 -216
  273. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/license.txt +21 -31
  274. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/makefile +40 -15
  275. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.c +2 -0
  276. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +32 -25
  277. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +29 -22
  278. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/makefile +40 -14
  279. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode2.c +2 -0
  280. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/all_tests.c +2 -2
  281. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/rakefile.rb +0 -1
  282. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode2.c +2 -0
  283. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/rakefile.rb +48 -37
  284. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/rakefile_helper.rb +179 -179
  285. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +135 -94
  286. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +13 -17
  287. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +12 -18
  288. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +30 -0
  289. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/Makefile +60 -0
  290. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/main/AllTests.c +4 -3
  291. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/{testunity_fixture.c → template_fixture_tests.c} +0 -0
  292. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +182 -27
  293. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +13 -0
  294. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +8 -6
  295. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +2 -2
  296. data/vendor/cmock/vendor/c_exception/vendor/unity/release/build.info +1 -1
  297. data/vendor/cmock/vendor/c_exception/vendor/unity/release/version.info +1 -1
  298. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.c +1333 -1145
  299. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.h +290 -307
  300. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity_internals.h +758 -620
  301. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_cmd.c +7 -3
  302. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_def.c +7 -3
  303. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.c +55 -0
  304. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.h +15 -0
  305. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_cmd.c +4 -3
  306. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_def.c +4 -3
  307. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.c +75 -0
  308. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.h +13 -0
  309. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new1.c +6 -5
  310. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new2.c +4 -3
  311. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_param.c +4 -3
  312. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run1.c +6 -5
  313. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run2.c +4 -3
  314. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_yaml.c +7 -6
  315. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_new1.c +9 -5
  316. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_new2.c +7 -3
  317. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_param.c +7 -3
  318. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_run1.c +9 -5
  319. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_run2.c +7 -3
  320. data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_yaml.c +10 -6
  321. data/vendor/cmock/vendor/c_exception/vendor/unity/{rakefile.rb → test/rakefile} +60 -61
  322. data/vendor/cmock/vendor/c_exception/vendor/unity/{rakefile_helper.rb → test/rakefile_helper.rb} +255 -249
  323. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/clang_file.yml +83 -0
  324. data/vendor/cmock/vendor/c_exception/vendor/unity/{targets → test/targets}/clang_strict.yml +83 -83
  325. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_32.yml +49 -0
  326. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_64.yml +50 -0
  327. data/vendor/cmock/vendor/c_exception/vendor/unity/{targets/gcc_32.yml → test/targets/gcc_auto_limits.yml} +46 -44
  328. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_auto_sizeof.yml +47 -0
  329. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_auto_stdint.yml +58 -0
  330. data/vendor/{c_exception/vendor/unity/targets/gcc_32.yml → cmock/vendor/c_exception/vendor/unity/test/targets/gcc_manual_math.yml} +46 -44
  331. data/vendor/{c_exception/vendor/unity → cmock/vendor/c_exception/vendor/unity/test}/targets/hitech_picc18.yml +101 -101
  332. data/vendor/{c_exception/vendor/unity → cmock/vendor/c_exception/vendor/unity/test}/targets/iar_arm_v4.yml +89 -89
  333. data/vendor/{c_exception/vendor/unity → cmock/vendor/c_exception/vendor/unity/test}/targets/iar_arm_v5.yml +79 -79
  334. data/vendor/cmock/vendor/c_exception/vendor/unity/{targets → test/targets}/iar_arm_v5_3.yml +79 -79
  335. data/vendor/{c_exception/vendor/unity → cmock/vendor/c_exception/vendor/unity/test}/targets/iar_armcortex_LM3S9B92_v5_4.yml +93 -93
  336. data/vendor/cmock/vendor/c_exception/vendor/unity/{targets → test/targets}/iar_cortexm3_v5.yml +83 -83
  337. data/vendor/{c_exception/vendor/unity → cmock/vendor/c_exception/vendor/unity/test}/targets/iar_msp430.yml +94 -94
  338. data/vendor/cmock/vendor/c_exception/vendor/unity/{targets → test/targets}/iar_sh2a_v6.yml +85 -85
  339. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/mocksample.c +51 -51
  340. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/sample.yml +8 -8
  341. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/testsample.c +68 -51
  342. data/vendor/{c_exception/vendor/unity/test → cmock/vendor/c_exception/vendor/unity/test/tests}/test_generate_test_runner.rb +102 -88
  343. data/vendor/{c_exception/vendor/unity/test → cmock/vendor/c_exception/vendor/unity/test/tests}/testparameterized.c +104 -101
  344. data/vendor/cmock/vendor/c_exception/vendor/unity/test/{testunity.c → tests/testunity.c} +3682 -3447
  345. data/vendor/cmock/vendor/unity/auto/generate_test_runner.rb +30 -13
  346. data/vendor/cmock/vendor/unity/auto/stylize_as_junit.rb +260 -0
  347. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.c +96 -93
  348. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.h +1 -1
  349. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_internals.h +12 -19
  350. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +18 -17
  351. data/vendor/cmock/vendor/unity/extras/fixture/test/Makefile +66 -5
  352. data/vendor/cmock/vendor/unity/extras/fixture/test/main/AllTests.c +2 -1
  353. data/vendor/cmock/vendor/unity/extras/fixture/test/{testunity_fixture.c → template_fixture_tests.c} +0 -0
  354. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_Test.c +187 -27
  355. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +14 -0
  356. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_output_Spy.c +6 -5
  357. data/vendor/cmock/vendor/unity/release/version.info +1 -1
  358. data/vendor/cmock/vendor/unity/src/unity.c +38 -27
  359. data/vendor/cmock/vendor/unity/src/unity.h +5 -0
  360. data/vendor/cmock/vendor/unity/src/unity_internals.h +22 -18
  361. data/vendor/cmock/vendor/unity/test/Makefile +52 -0
  362. data/vendor/cmock/vendor/unity/test/expectdata/testsample_cmd.c +4 -0
  363. data/vendor/cmock/vendor/unity/test/expectdata/testsample_def.c +4 -0
  364. data/vendor/cmock/vendor/unity/test/expectdata/testsample_head1.c +4 -0
  365. data/vendor/cmock/vendor/unity/test/expectdata/testsample_head1.h +7 -4
  366. data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_head1.h +6 -4
  367. data/vendor/cmock/vendor/unity/test/expectdata/testsample_new1.c +4 -0
  368. data/vendor/cmock/vendor/unity/test/expectdata/testsample_new2.c +4 -0
  369. data/vendor/cmock/vendor/unity/test/expectdata/testsample_param.c +4 -0
  370. data/vendor/cmock/vendor/unity/test/expectdata/testsample_run1.c +4 -0
  371. data/vendor/cmock/vendor/unity/test/expectdata/testsample_run2.c +4 -0
  372. data/vendor/cmock/vendor/unity/test/expectdata/testsample_yaml.c +4 -0
  373. data/vendor/cmock/vendor/unity/test/rakefile_helper.rb +1 -1
  374. data/vendor/cmock/vendor/unity/test/targets/clang_file.yml +0 -1
  375. data/vendor/cmock/vendor/unity/test/targets/clang_strict.yml +0 -1
  376. data/vendor/cmock/vendor/unity/test/targets/gcc_32.yml +0 -1
  377. data/vendor/cmock/vendor/unity/test/targets/gcc_64.yml +0 -1
  378. data/vendor/cmock/vendor/unity/test/targets/gcc_auto_limits.yml +0 -1
  379. data/vendor/cmock/vendor/unity/test/targets/gcc_auto_sizeof.yml +0 -1
  380. data/vendor/cmock/vendor/unity/test/targets/gcc_auto_stdint.yml +0 -1
  381. data/vendor/cmock/vendor/unity/test/targets/gcc_manual_math.yml +0 -1
  382. data/vendor/cmock/vendor/unity/test/testdata/testsample.c +19 -2
  383. data/vendor/cmock/vendor/unity/test/tests/testunity.c +55 -4
  384. data/vendor/unity/auto/generate_test_runner.rb +4 -2
  385. data/vendor/unity/auto/stylize_as_junit.rb +260 -0
  386. data/vendor/unity/extras/fixture/src/unity_fixture.c +24 -41
  387. data/vendor/unity/extras/fixture/src/unity_fixture.h +1 -1
  388. data/vendor/unity/extras/fixture/src/unity_fixture_internals.h +5 -7
  389. data/vendor/unity/extras/fixture/test/Makefile +53 -8
  390. data/vendor/unity/extras/fixture/test/{testunity_fixture.c → template_fixture_tests.c} +0 -0
  391. data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +129 -32
  392. data/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +6 -0
  393. data/vendor/unity/extras/fixture/test/unity_output_Spy.c +4 -4
  394. data/vendor/unity/release/version.info +1 -1
  395. data/vendor/unity/src/unity.c +32 -21
  396. data/vendor/unity/src/unity.h +5 -0
  397. data/vendor/unity/src/unity_internals.h +7 -3
  398. data/vendor/unity/test/Makefile +52 -0
  399. data/vendor/unity/test/expectdata/testsample_cmd.c +4 -0
  400. data/vendor/unity/test/expectdata/testsample_def.c +4 -0
  401. data/vendor/unity/test/expectdata/testsample_head1.c +4 -0
  402. data/vendor/unity/test/expectdata/testsample_head1.h +7 -4
  403. data/vendor/unity/test/expectdata/testsample_mock_head1.h +6 -4
  404. data/vendor/unity/test/expectdata/testsample_new1.c +4 -0
  405. data/vendor/unity/test/expectdata/testsample_new2.c +4 -0
  406. data/vendor/unity/test/expectdata/testsample_param.c +4 -0
  407. data/vendor/unity/test/expectdata/testsample_run1.c +4 -0
  408. data/vendor/unity/test/expectdata/testsample_run2.c +4 -0
  409. data/vendor/unity/test/expectdata/testsample_yaml.c +4 -0
  410. data/vendor/unity/test/testdata/testsample.c +19 -2
  411. data/vendor/unity/test/tests/testunity.c +35 -4
  412. metadata +75 -52
  413. data/ceedling-0.18.0.gem +0 -0
  414. data/docs/CeedlingLogo.png +0 -0
  415. data/vendor/c_exception/vendor/unity/Gemfile +0 -4
  416. data/vendor/c_exception/vendor/unity/Gemfile.lock +0 -12
  417. data/vendor/c_exception/vendor/unity/examples/example_3/makefile +0 -41
  418. data/vendor/c_exception/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c +0 -46
  419. data/vendor/c_exception/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode_Runner.c +0 -50
  420. data/vendor/c_exception/vendor/unity/makefile +0 -37
  421. data/vendor/cmock/vendor/c_exception/vendor/unity/Gemfile +0 -4
  422. data/vendor/cmock/vendor/c_exception/vendor/unity/Gemfile.lock +0 -12
  423. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/makefile +0 -41
  424. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c +0 -46
  425. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode_Runner.c +0 -50
  426. data/vendor/cmock/vendor/c_exception/vendor/unity/makefile +0 -37
@@ -18,6 +18,7 @@ TEST_GROUP_RUNNER(UnityFixture)
18
18
  RUN_TEST_CASE(UnityFixture, ReallocSizeZeroFreesMemAndReturnsNullPointer);
19
19
  RUN_TEST_CASE(UnityFixture, CallocFillsWithZero);
20
20
  RUN_TEST_CASE(UnityFixture, PointerSet);
21
+ RUN_TEST_CASE(UnityFixture, FreeNULLSafety);
21
22
  }
22
23
 
23
24
  TEST_GROUP_RUNNER(UnityCommandOptions)
@@ -31,6 +32,7 @@ TEST_GROUP_RUNNER(UnityCommandOptions)
31
32
  RUN_TEST_CASE(UnityCommandOptions, MultipleOptions);
32
33
  RUN_TEST_CASE(UnityCommandOptions, MultipleOptionsDashRNotLastAndNoValueSpecified);
33
34
  RUN_TEST_CASE(UnityCommandOptions, UnknownCommandIsIgnored);
35
+ RUN_TEST_CASE(UnityCommandOptions, TestShouldBeIgnored);
34
36
  }
35
37
 
36
38
  TEST_GROUP_RUNNER(LeakDetection)
@@ -38,4 +40,15 @@ TEST_GROUP_RUNNER(LeakDetection)
38
40
  RUN_TEST_CASE(LeakDetection, DetectsLeak);
39
41
  RUN_TEST_CASE(LeakDetection, BufferOverrunFoundDuringFree);
40
42
  RUN_TEST_CASE(LeakDetection, BufferOverrunFoundDuringRealloc);
43
+ RUN_TEST_CASE(LeakDetection, BufferGuardWriteFoundDuringFree);
44
+ RUN_TEST_CASE(LeakDetection, BufferGuardWriteFoundDuringRealloc);
45
+ RUN_TEST_CASE(LeakDetection, PointerSettingMax);
46
+ }
47
+
48
+ TEST_GROUP_RUNNER(InternalMalloc)
49
+ {
50
+ RUN_TEST_CASE(InternalMalloc, MallocPastBufferFails);
51
+ RUN_TEST_CASE(InternalMalloc, CallocPastBufferFails);
52
+ RUN_TEST_CASE(InternalMalloc, MallocThenReallocGrowsMemoryInPlace);
53
+ RUN_TEST_CASE(InternalMalloc, ReallocFailDoesNotFreeMem);
41
54
  }
@@ -7,8 +7,9 @@
7
7
 
8
8
 
9
9
  #include "unity_output_Spy.h"
10
+ #include "unity_fixture.h"
11
+
10
12
  #include <stdio.h>
11
- #include <stdlib.h>
12
13
  #include <string.h>
13
14
 
14
15
  static int size;
@@ -21,11 +22,12 @@ void UnityOutputCharSpy_Create(int s)
21
22
  size = s;
22
23
  count = 0;
23
24
  spy_enable = 0;
24
- buffer = malloc(size);
25
- memset(buffer, 0, size);
25
+ buffer = malloc((size_t)size);
26
+ TEST_ASSERT_NOT_NULL_MESSAGE(buffer, "Internal malloc failed in Spy Create():" __FILE__);
27
+ memset(buffer, 0, (size_t)size);
26
28
  }
27
29
 
28
- void UnityOutputCharSpy_Destroy()
30
+ void UnityOutputCharSpy_Destroy(void)
29
31
  {
30
32
  size = 0;
31
33
  free(buffer);
@@ -36,7 +38,7 @@ int UnityOutputCharSpy_OutputChar(int c)
36
38
  if (spy_enable)
37
39
  {
38
40
  if (count < (size-1))
39
- buffer[count++] = c;
41
+ buffer[count++] = (char)c;
40
42
  }
41
43
  else
42
44
  {
@@ -45,7 +47,7 @@ int UnityOutputCharSpy_OutputChar(int c)
45
47
  return c;
46
48
  }
47
49
 
48
- const char * UnityOutputCharSpy_Get()
50
+ const char * UnityOutputCharSpy_Get(void)
49
51
  {
50
52
  return buffer;
51
53
  }
@@ -9,9 +9,9 @@
9
9
  #define D_unity_output_Spy_H
10
10
 
11
11
  void UnityOutputCharSpy_Create(int s);
12
- void UnityOutputCharSpy_Destroy();
12
+ void UnityOutputCharSpy_Destroy(void);
13
13
  int UnityOutputCharSpy_OutputChar(int c);
14
- const char * UnityOutputCharSpy_Get();
14
+ const char * UnityOutputCharSpy_Get(void);
15
15
  void UnityOutputCharSpy_Enable(int enable);
16
16
 
17
17
  #endif
@@ -1,1145 +1,1333 @@
1
- /* =========================================================================
2
- Unity Project - A Test Framework for C
3
- Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
4
- [Released under MIT License. Please refer to license.txt for details]
5
- ============================================================================ */
6
-
7
- #include "unity.h"
8
- #include <stdio.h>
9
- #include <string.h>
10
-
11
- #define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; longjmp(Unity.AbortFrame, 1); }
12
- #define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; longjmp(Unity.AbortFrame, 1); }
13
- /// return prematurely if we are already in failure or ignore state
14
- #define UNITY_SKIP_EXECUTION { if ((Unity.CurrentTestFailed != 0) || (Unity.CurrentTestIgnored != 0)) {return;} }
15
- #define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\n'); }
16
-
17
- struct _Unity Unity;
18
-
19
- const char* UnityStrNull = "NULL";
20
- const char* UnityStrSpacer = ". ";
21
- const char* UnityStrExpected = " Expected ";
22
- const char* UnityStrWas = " Was ";
23
- const char* UnityStrTo = " To ";
24
- const char* UnityStrElement = " Element ";
25
- const char* UnityStrByte = " Byte ";
26
- const char* UnityStrMemory = " Memory Mismatch.";
27
- const char* UnityStrDelta = " Values Not Within Delta ";
28
- const char* UnityStrPointless= " You Asked Me To Compare Nothing, Which Was Pointless.";
29
- const char* UnityStrNullPointerForExpected= " Expected pointer to be NULL";
30
- const char* UnityStrNullPointerForActual = " Actual pointer was NULL";
31
- const char* UnityStrNot = "Not ";
32
- const char* UnityStrInf = "Infinity";
33
- const char* UnityStrNegInf = "Negative Infinity";
34
- const char* UnityStrNaN = "NaN";
35
- const char* UnityStrDet = "Determinate";
36
- const char* UnityStrErrFloat = "Unity Floating Point Disabled";
37
- const char* UnityStrErrDouble= "Unity Double Precision Disabled";
38
- const char* UnityStrErr64 = "Unity 64-bit Support Disabled";
39
-
40
- #ifndef UNITY_EXCLUDE_FLOAT
41
- // Dividing by these constants produces +/- infinity.
42
- // The rationale is given in UnityAssertFloatIsInf's body.
43
- static const _UF f_zero = 0.0f;
44
- #ifndef UNITY_EXCLUDE_DOUBLE
45
- static const _UD d_zero = 0.0;
46
- #endif
47
- #endif
48
-
49
- // compiler-generic print formatting masks
50
- const _U_UINT UnitySizeMask[] =
51
- {
52
- 255u, // 0xFF
53
- 65535u, // 0xFFFF
54
- 65535u,
55
- 4294967295u, // 0xFFFFFFFF
56
- 4294967295u,
57
- 4294967295u,
58
- 4294967295u
59
- #ifdef UNITY_SUPPORT_64
60
- ,0xFFFFFFFFFFFFFFFF
61
- #endif
62
- };
63
-
64
- void UnityPrintFail(void);
65
- void UnityPrintOk(void);
66
-
67
- //-----------------------------------------------
68
- // Pretty Printers & Test Result Output Handlers
69
- //-----------------------------------------------
70
-
71
- void UnityPrint(const char* string)
72
- {
73
- const char* pch = string;
74
-
75
- if (pch != NULL)
76
- {
77
- while (*pch)
78
- {
79
- // printable characters plus CR & LF are printed
80
- if ((*pch <= 126) && (*pch >= 32))
81
- {
82
- UNITY_OUTPUT_CHAR(*pch);
83
- }
84
- //write escaped carriage returns
85
- else if (*pch == 13)
86
- {
87
- UNITY_OUTPUT_CHAR('\\');
88
- UNITY_OUTPUT_CHAR('r');
89
- }
90
- //write escaped line feeds
91
- else if (*pch == 10)
92
- {
93
- UNITY_OUTPUT_CHAR('\\');
94
- UNITY_OUTPUT_CHAR('n');
95
- }
96
- // unprintable characters are shown as codes
97
- else
98
- {
99
- UNITY_OUTPUT_CHAR('\\');
100
- UnityPrintNumberHex((_U_UINT)*pch, 2);
101
- }
102
- pch++;
103
- }
104
- }
105
- }
106
-
107
- //-----------------------------------------------
108
- void UnityPrintNumberByStyle(const _U_SINT number, const UNITY_DISPLAY_STYLE_T style)
109
- {
110
- if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
111
- {
112
- UnityPrintNumber(number);
113
- }
114
- else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT)
115
- {
116
- UnityPrintNumberUnsigned( (_U_UINT)number & UnitySizeMask[((_U_UINT)style & (_U_UINT)0x0F) - 1] );
117
- }
118
- else
119
- {
120
- UnityPrintNumberHex((_U_UINT)number, (char)((style & 0x000F) << 1));
121
- }
122
- }
123
-
124
- //-----------------------------------------------
125
- /// basically do an itoa using as little ram as possible
126
- void UnityPrintNumber(const _U_SINT number_to_print)
127
- {
128
- _U_SINT divisor = 1;
129
- _U_SINT next_divisor;
130
- _U_SINT number = number_to_print;
131
-
132
- if (number < 0)
133
- {
134
- UNITY_OUTPUT_CHAR('-');
135
- number = -number;
136
- }
137
-
138
- // figure out initial divisor
139
- while (number / divisor > 9)
140
- {
141
- next_divisor = divisor * 10;
142
- if (next_divisor > divisor)
143
- divisor = next_divisor;
144
- else
145
- break;
146
- }
147
-
148
- // now mod and print, then divide divisor
149
- do
150
- {
151
- UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10)));
152
- divisor /= 10;
153
- }
154
- while (divisor > 0);
155
- }
156
-
157
- //-----------------------------------------------
158
- /// basically do an itoa using as little ram as possible
159
- void UnityPrintNumberUnsigned(const _U_UINT number)
160
- {
161
- _U_UINT divisor = 1;
162
- _U_UINT next_divisor;
163
-
164
- // figure out initial divisor
165
- while (number / divisor > 9)
166
- {
167
- next_divisor = divisor * 10;
168
- if (next_divisor > divisor)
169
- divisor = next_divisor;
170
- else
171
- break;
172
- }
173
-
174
- // now mod and print, then divide divisor
175
- do
176
- {
177
- UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10)));
178
- divisor /= 10;
179
- }
180
- while (divisor > 0);
181
- }
182
-
183
- //-----------------------------------------------
184
- void UnityPrintNumberHex(const _U_UINT number, const char nibbles_to_print)
185
- {
186
- _U_UINT nibble;
187
- char nibbles = nibbles_to_print;
188
- UNITY_OUTPUT_CHAR('0');
189
- UNITY_OUTPUT_CHAR('x');
190
-
191
- while (nibbles > 0)
192
- {
193
- nibble = (number >> (--nibbles << 2)) & 0x0000000F;
194
- if (nibble <= 9)
195
- {
196
- UNITY_OUTPUT_CHAR((char)('0' + nibble));
197
- }
198
- else
199
- {
200
- UNITY_OUTPUT_CHAR((char)('A' - 10 + nibble));
201
- }
202
- }
203
- }
204
-
205
- //-----------------------------------------------
206
- void UnityPrintMask(const _U_UINT mask, const _U_UINT number)
207
- {
208
- _U_UINT current_bit = (_U_UINT)1 << (UNITY_INT_WIDTH - 1);
209
- _US32 i;
210
-
211
- for (i = 0; i < UNITY_INT_WIDTH; i++)
212
- {
213
- if (current_bit & mask)
214
- {
215
- if (current_bit & number)
216
- {
217
- UNITY_OUTPUT_CHAR('1');
218
- }
219
- else
220
- {
221
- UNITY_OUTPUT_CHAR('0');
222
- }
223
- }
224
- else
225
- {
226
- UNITY_OUTPUT_CHAR('X');
227
- }
228
- current_bit = current_bit >> 1;
229
- }
230
- }
231
-
232
- //-----------------------------------------------
233
- #ifdef UNITY_FLOAT_VERBOSE
234
- void UnityPrintFloat(_UF number)
235
- {
236
- char TempBuffer[32];
237
- sprintf(TempBuffer, "%.6f", number);
238
- UnityPrint(TempBuffer);
239
- }
240
- #endif
241
-
242
- //-----------------------------------------------
243
-
244
- void UnityPrintFail(void)
245
- {
246
- UnityPrint("FAIL");
247
- }
248
-
249
- void UnityPrintOk(void)
250
- {
251
- UnityPrint("OK");
252
- }
253
-
254
- //-----------------------------------------------
255
- void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
256
- {
257
- UNITY_PRINT_EOL;
258
- UnityPrint(file);
259
- UNITY_OUTPUT_CHAR(':');
260
- UnityPrintNumber((_U_SINT)line);
261
- UNITY_OUTPUT_CHAR(':');
262
- UnityPrint(Unity.CurrentTestName);
263
- UNITY_OUTPUT_CHAR(':');
264
- }
265
-
266
- //-----------------------------------------------
267
- void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line)
268
- {
269
- UnityTestResultsBegin(Unity.TestFile, line);
270
- UnityPrint("FAIL:");
271
- }
272
-
273
- //-----------------------------------------------
274
- void UnityConcludeTest(void)
275
- {
276
- if (Unity.CurrentTestIgnored)
277
- {
278
- Unity.TestIgnores++;
279
- }
280
- else if (!Unity.CurrentTestFailed)
281
- {
282
- UnityTestResultsBegin(Unity.TestFile, Unity.CurrentTestLineNumber);
283
- UnityPrint("PASS");
284
- }
285
- else
286
- {
287
- Unity.TestFailures++;
288
- }
289
-
290
- Unity.CurrentTestFailed = 0;
291
- Unity.CurrentTestIgnored = 0;
292
- }
293
-
294
- //-----------------------------------------------
295
- void UnityAddMsgIfSpecified(const char* msg)
296
- {
297
- if (msg)
298
- {
299
- UnityPrint(UnityStrSpacer);
300
- UnityPrint(msg);
301
- }
302
- }
303
-
304
- //-----------------------------------------------
305
- void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual)
306
- {
307
- UnityPrint(UnityStrExpected);
308
- if (expected != NULL)
309
- {
310
- UNITY_OUTPUT_CHAR('\'');
311
- UnityPrint(expected);
312
- UNITY_OUTPUT_CHAR('\'');
313
- }
314
- else
315
- {
316
- UnityPrint(UnityStrNull);
317
- }
318
- UnityPrint(UnityStrWas);
319
- if (actual != NULL)
320
- {
321
- UNITY_OUTPUT_CHAR('\'');
322
- UnityPrint(actual);
323
- UNITY_OUTPUT_CHAR('\'');
324
- }
325
- else
326
- {
327
- UnityPrint(UnityStrNull);
328
- }
329
- }
330
-
331
- //-----------------------------------------------
332
- // Assertion & Control Helpers
333
- //-----------------------------------------------
334
-
335
- int UnityCheckArraysForNull(UNITY_PTR_ATTRIBUTE const void* expected, UNITY_PTR_ATTRIBUTE const void* actual, const UNITY_LINE_TYPE lineNumber, const char* msg)
336
- {
337
- //return true if they are both NULL
338
- if ((expected == NULL) && (actual == NULL))
339
- return 1;
340
-
341
- //throw error if just expected is NULL
342
- if (expected == NULL)
343
- {
344
- UnityTestResultsFailBegin(lineNumber);
345
- UnityPrint(UnityStrNullPointerForExpected);
346
- UnityAddMsgIfSpecified(msg);
347
- UNITY_FAIL_AND_BAIL;
348
- }
349
-
350
- //throw error if just actual is NULL
351
- if (actual == NULL)
352
- {
353
- UnityTestResultsFailBegin(lineNumber);
354
- UnityPrint(UnityStrNullPointerForActual);
355
- UnityAddMsgIfSpecified(msg);
356
- UNITY_FAIL_AND_BAIL;
357
- }
358
-
359
- //return false if neither is NULL
360
- return 0;
361
- }
362
-
363
- //-----------------------------------------------
364
- // Assertion Functions
365
- //-----------------------------------------------
366
-
367
- void UnityAssertBits(const _U_SINT mask,
368
- const _U_SINT expected,
369
- const _U_SINT actual,
370
- const char* msg,
371
- const UNITY_LINE_TYPE lineNumber)
372
- {
373
- UNITY_SKIP_EXECUTION;
374
-
375
- if ((mask & expected) != (mask & actual))
376
- {
377
- UnityTestResultsFailBegin(lineNumber);
378
- UnityPrint(UnityStrExpected);
379
- UnityPrintMask((_U_UINT)mask, (_U_UINT)expected);
380
- UnityPrint(UnityStrWas);
381
- UnityPrintMask((_U_UINT)mask, (_U_UINT)actual);
382
- UnityAddMsgIfSpecified(msg);
383
- UNITY_FAIL_AND_BAIL;
384
- }
385
- }
386
-
387
- //-----------------------------------------------
388
- void UnityAssertEqualNumber(const _U_SINT expected,
389
- const _U_SINT actual,
390
- const char* msg,
391
- const UNITY_LINE_TYPE lineNumber,
392
- const UNITY_DISPLAY_STYLE_T style)
393
- {
394
- UNITY_SKIP_EXECUTION;
395
-
396
- if (expected != actual)
397
- {
398
- UnityTestResultsFailBegin(lineNumber);
399
- UnityPrint(UnityStrExpected);
400
- UnityPrintNumberByStyle(expected, style);
401
- UnityPrint(UnityStrWas);
402
- UnityPrintNumberByStyle(actual, style);
403
- UnityAddMsgIfSpecified(msg);
404
- UNITY_FAIL_AND_BAIL;
405
- }
406
- }
407
-
408
- //-----------------------------------------------
409
- void UnityAssertEqualIntArray(UNITY_PTR_ATTRIBUTE const void* expected,
410
- UNITY_PTR_ATTRIBUTE const void* actual,
411
- const _UU32 num_elements,
412
- const char* msg,
413
- const UNITY_LINE_TYPE lineNumber,
414
- const UNITY_DISPLAY_STYLE_T style)
415
- {
416
- _UU32 elements = num_elements;
417
- UNITY_PTR_ATTRIBUTE const _US8* ptr_exp = (UNITY_PTR_ATTRIBUTE _US8*)expected;
418
- UNITY_PTR_ATTRIBUTE const _US8* ptr_act = (UNITY_PTR_ATTRIBUTE _US8*)actual;
419
-
420
- UNITY_SKIP_EXECUTION;
421
-
422
- if (elements == 0)
423
- {
424
- UnityTestResultsFailBegin(lineNumber);
425
- UnityPrint(UnityStrPointless);
426
- UnityAddMsgIfSpecified(msg);
427
- UNITY_FAIL_AND_BAIL;
428
- }
429
-
430
- if (UnityCheckArraysForNull((UNITY_PTR_ATTRIBUTE void*)expected, (UNITY_PTR_ATTRIBUTE void*)actual, lineNumber, msg) == 1)
431
- return;
432
-
433
- // If style is UNITY_DISPLAY_STYLE_INT, we'll fall into the default case rather than the INT16 or INT32 (etc) case
434
- // as UNITY_DISPLAY_STYLE_INT includes a flag for UNITY_DISPLAY_RANGE_AUTO, which the width-specific
435
- // variants do not. Therefore remove this flag.
436
- switch(style & (UNITY_DISPLAY_STYLE_T)(~UNITY_DISPLAY_RANGE_AUTO))
437
- {
438
- case UNITY_DISPLAY_STYLE_HEX8:
439
- case UNITY_DISPLAY_STYLE_INT8:
440
- case UNITY_DISPLAY_STYLE_UINT8:
441
- while (elements--)
442
- {
443
- if (*ptr_exp != *ptr_act)
444
- {
445
- UnityTestResultsFailBegin(lineNumber);
446
- UnityPrint(UnityStrElement);
447
- UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
448
- UnityPrint(UnityStrExpected);
449
- UnityPrintNumberByStyle(*ptr_exp, style);
450
- UnityPrint(UnityStrWas);
451
- UnityPrintNumberByStyle(*ptr_act, style);
452
- UnityAddMsgIfSpecified(msg);
453
- UNITY_FAIL_AND_BAIL;
454
- }
455
- ptr_exp += 1;
456
- ptr_act += 1;
457
- }
458
- break;
459
- case UNITY_DISPLAY_STYLE_HEX16:
460
- case UNITY_DISPLAY_STYLE_INT16:
461
- case UNITY_DISPLAY_STYLE_UINT16:
462
- while (elements--)
463
- {
464
- if (*(UNITY_PTR_ATTRIBUTE _US16*)ptr_exp != *(UNITY_PTR_ATTRIBUTE _US16*)ptr_act)
465
- {
466
- UnityTestResultsFailBegin(lineNumber);
467
- UnityPrint(UnityStrElement);
468
- UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
469
- UnityPrint(UnityStrExpected);
470
- UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE _US16*)ptr_exp, style);
471
- UnityPrint(UnityStrWas);
472
- UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE _US16*)ptr_act, style);
473
- UnityAddMsgIfSpecified(msg);
474
- UNITY_FAIL_AND_BAIL;
475
- }
476
- ptr_exp += 2;
477
- ptr_act += 2;
478
- }
479
- break;
480
- #ifdef UNITY_SUPPORT_64
481
- case UNITY_DISPLAY_STYLE_HEX64:
482
- case UNITY_DISPLAY_STYLE_INT64:
483
- case UNITY_DISPLAY_STYLE_UINT64:
484
- while (elements--)
485
- {
486
- if (*(UNITY_PTR_ATTRIBUTE _US64*)ptr_exp != *(UNITY_PTR_ATTRIBUTE _US64*)ptr_act)
487
- {
488
- UnityTestResultsFailBegin(lineNumber);
489
- UnityPrint(UnityStrElement);
490
- UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
491
- UnityPrint(UnityStrExpected);
492
- UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE _US64*)ptr_exp, style);
493
- UnityPrint(UnityStrWas);
494
- UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE _US64*)ptr_act, style);
495
- UnityAddMsgIfSpecified(msg);
496
- UNITY_FAIL_AND_BAIL;
497
- }
498
- ptr_exp += 8;
499
- ptr_act += 8;
500
- }
501
- break;
502
- #endif
503
- default:
504
- while (elements--)
505
- {
506
- if (*(UNITY_PTR_ATTRIBUTE _US32*)ptr_exp != *(UNITY_PTR_ATTRIBUTE _US32*)ptr_act)
507
- {
508
- UnityTestResultsFailBegin(lineNumber);
509
- UnityPrint(UnityStrElement);
510
- UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
511
- UnityPrint(UnityStrExpected);
512
- UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE _US32*)ptr_exp, style);
513
- UnityPrint(UnityStrWas);
514
- UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE _US32*)ptr_act, style);
515
- UnityAddMsgIfSpecified(msg);
516
- UNITY_FAIL_AND_BAIL;
517
- }
518
- ptr_exp += 4;
519
- ptr_act += 4;
520
- }
521
- break;
522
- }
523
- }
524
-
525
- //-----------------------------------------------
526
- #ifndef UNITY_EXCLUDE_FLOAT
527
- void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const _UF* expected,
528
- UNITY_PTR_ATTRIBUTE const _UF* actual,
529
- const _UU32 num_elements,
530
- const char* msg,
531
- const UNITY_LINE_TYPE lineNumber)
532
- {
533
- _UU32 elements = num_elements;
534
- UNITY_PTR_ATTRIBUTE const _UF* ptr_expected = expected;
535
- UNITY_PTR_ATTRIBUTE const _UF* ptr_actual = actual;
536
- _UF diff, tol;
537
-
538
- UNITY_SKIP_EXECUTION;
539
-
540
- if (elements == 0)
541
- {
542
- UnityTestResultsFailBegin(lineNumber);
543
- UnityPrint(UnityStrPointless);
544
- UnityAddMsgIfSpecified(msg);
545
- UNITY_FAIL_AND_BAIL;
546
- }
547
-
548
- if (UnityCheckArraysForNull((UNITY_PTR_ATTRIBUTE void*)expected, (UNITY_PTR_ATTRIBUTE void*)actual, lineNumber, msg) == 1)
549
- return;
550
-
551
- while (elements--)
552
- {
553
- diff = *ptr_expected - *ptr_actual;
554
- if (diff < 0.0f)
555
- diff = 0.0f - diff;
556
- tol = UNITY_FLOAT_PRECISION * *ptr_expected;
557
- if (tol < 0.0f)
558
- tol = 0.0f - tol;
559
-
560
- //This first part of this condition will catch any NaN or Infinite values
561
- if ((diff * 0.0f != 0.0f) || (diff > tol))
562
- {
563
- UnityTestResultsFailBegin(lineNumber);
564
- UnityPrint(UnityStrElement);
565
- UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
566
- #ifdef UNITY_FLOAT_VERBOSE
567
- UnityPrint(UnityStrExpected);
568
- UnityPrintFloat(*ptr_expected);
569
- UnityPrint(UnityStrWas);
570
- UnityPrintFloat(*ptr_actual);
571
- #else
572
- UnityPrint(UnityStrDelta);
573
- #endif
574
- UnityAddMsgIfSpecified(msg);
575
- UNITY_FAIL_AND_BAIL;
576
- }
577
- ptr_expected++;
578
- ptr_actual++;
579
- }
580
- }
581
-
582
- //-----------------------------------------------
583
- void UnityAssertFloatsWithin(const _UF delta,
584
- const _UF expected,
585
- const _UF actual,
586
- const char* msg,
587
- const UNITY_LINE_TYPE lineNumber)
588
- {
589
- _UF diff = actual - expected;
590
- _UF pos_delta = delta;
591
-
592
- UNITY_SKIP_EXECUTION;
593
-
594
- if (diff < 0.0f)
595
- {
596
- diff = 0.0f - diff;
597
- }
598
- if (pos_delta < 0.0f)
599
- {
600
- pos_delta = 0.0f - pos_delta;
601
- }
602
-
603
- //This first part of this condition will catch any NaN or Infinite values
604
- if ((diff * 0.0f != 0.0f) || (pos_delta < diff))
605
- {
606
- UnityTestResultsFailBegin(lineNumber);
607
- #ifdef UNITY_FLOAT_VERBOSE
608
- UnityPrint(UnityStrExpected);
609
- UnityPrintFloat(expected);
610
- UnityPrint(UnityStrWas);
611
- UnityPrintFloat(actual);
612
- #else
613
- UnityPrint(UnityStrDelta);
614
- #endif
615
- UnityAddMsgIfSpecified(msg);
616
- UNITY_FAIL_AND_BAIL;
617
- }
618
- }
619
-
620
- //-----------------------------------------------
621
- void UnityAssertFloatSpecial(const _UF actual,
622
- const char* msg,
623
- const UNITY_LINE_TYPE lineNumber,
624
- const UNITY_FLOAT_TRAIT_T style)
625
- {
626
- UNITY_SKIP_EXECUTION;
627
-
628
- const char* trait_names[] = { UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet };
629
- _U_SINT should_be_trait = ((_U_SINT)style & 1);
630
- _U_SINT is_trait = !should_be_trait;
631
- _U_SINT trait_index = style >> 1;
632
-
633
- switch(style)
634
- {
635
- //To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
636
- //We are using a variable to hold the zero value because some compilers complain about dividing by zero otherwise
637
- case UNITY_FLOAT_IS_INF:
638
- case UNITY_FLOAT_IS_NOT_INF:
639
- is_trait = ((1.0f / f_zero) == actual) ? 1 : 0;
640
- break;
641
- case UNITY_FLOAT_IS_NEG_INF:
642
- case UNITY_FLOAT_IS_NOT_NEG_INF:
643
- is_trait = ((-1.0f / f_zero) == actual) ? 1 : 0;
644
- break;
645
-
646
- //NaN is the only floating point value that does NOT equal itself. Therefore if Actual == Actual, then it is NOT NaN.
647
- case UNITY_FLOAT_IS_NAN:
648
- case UNITY_FLOAT_IS_NOT_NAN:
649
- is_trait = (actual == actual) ? 0 : 1;
650
- break;
651
-
652
- //A determinate number is non infinite and not NaN. (therefore the opposite of the two above)
653
- case UNITY_FLOAT_IS_DET:
654
- case UNITY_FLOAT_IS_NOT_DET:
655
- if ( (actual != actual) || ((1.0f / f_zero) == actual) || ((-1.0f / f_zero) == actual) )
656
- is_trait = 0;
657
- else
658
- is_trait = 1;
659
- break;
660
- }
661
-
662
- if (is_trait != should_be_trait)
663
- {
664
- UnityTestResultsFailBegin(lineNumber);
665
- UnityPrint(UnityStrExpected);
666
- if (!should_be_trait)
667
- UnityPrint(UnityStrNot);
668
- UnityPrint(trait_names[trait_index]);
669
- UnityPrint(UnityStrWas);
670
- #ifdef UNITY_FLOAT_VERBOSE
671
- UnityPrintFloat(actual);
672
- #else
673
- if (should_be_trait)
674
- UnityPrint(UnityStrNot);
675
- UnityPrint(trait_names[trait_index]);
676
- #endif
677
- UnityAddMsgIfSpecified(msg);
678
- UNITY_FAIL_AND_BAIL;
679
- }
680
- }
681
-
682
- #endif //not UNITY_EXCLUDE_FLOAT
683
-
684
- //-----------------------------------------------
685
- #ifndef UNITY_EXCLUDE_DOUBLE
686
- void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const _UD* expected,
687
- UNITY_PTR_ATTRIBUTE const _UD* actual,
688
- const _UU32 num_elements,
689
- const char* msg,
690
- const UNITY_LINE_TYPE lineNumber)
691
- {
692
- _UU32 elements = num_elements;
693
- UNITY_PTR_ATTRIBUTE const _UD* ptr_expected = expected;
694
- UNITY_PTR_ATTRIBUTE const _UD* ptr_actual = actual;
695
- _UD diff, tol;
696
-
697
- UNITY_SKIP_EXECUTION;
698
-
699
- if (elements == 0)
700
- {
701
- UnityTestResultsFailBegin(lineNumber);
702
- UnityPrint(UnityStrPointless);
703
- UnityAddMsgIfSpecified(msg);
704
- UNITY_FAIL_AND_BAIL;
705
- }
706
-
707
- if (UnityCheckArraysForNull((UNITY_PTR_ATTRIBUTE void*)expected, (UNITY_PTR_ATTRIBUTE void*)actual, lineNumber, msg) == 1)
708
- return;
709
-
710
- while (elements--)
711
- {
712
- diff = *ptr_expected - *ptr_actual;
713
- if (diff < 0.0)
714
- diff = 0.0 - diff;
715
- tol = UNITY_DOUBLE_PRECISION * *ptr_expected;
716
- if (tol < 0.0)
717
- tol = 0.0 - tol;
718
-
719
- //This first part of this condition will catch any NaN or Infinite values
720
- if ((diff * 0.0 != 0.0) || (diff > tol))
721
- {
722
- UnityTestResultsFailBegin(lineNumber);
723
- UnityPrint(UnityStrElement);
724
- UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
725
- #ifdef UNITY_DOUBLE_VERBOSE
726
- UnityPrint(UnityStrExpected);
727
- UnityPrintFloat((float)(*ptr_expected));
728
- UnityPrint(UnityStrWas);
729
- UnityPrintFloat((float)(*ptr_actual));
730
- #else
731
- UnityPrint(UnityStrDelta);
732
- #endif
733
- UnityAddMsgIfSpecified(msg);
734
- UNITY_FAIL_AND_BAIL;
735
- }
736
- ptr_expected++;
737
- ptr_actual++;
738
- }
739
- }
740
-
741
- //-----------------------------------------------
742
- void UnityAssertDoublesWithin(const _UD delta,
743
- const _UD expected,
744
- const _UD actual,
745
- const char* msg,
746
- const UNITY_LINE_TYPE lineNumber)
747
- {
748
- _UD diff = actual - expected;
749
- _UD pos_delta = delta;
750
-
751
- UNITY_SKIP_EXECUTION;
752
-
753
- if (diff < 0.0)
754
- {
755
- diff = 0.0 - diff;
756
- }
757
- if (pos_delta < 0.0)
758
- {
759
- pos_delta = 0.0 - pos_delta;
760
- }
761
-
762
- //This first part of this condition will catch any NaN or Infinite values
763
- if ((diff * 0.0 != 0.0) || (pos_delta < diff))
764
- {
765
- UnityTestResultsFailBegin(lineNumber);
766
- #ifdef UNITY_DOUBLE_VERBOSE
767
- UnityPrint(UnityStrExpected);
768
- UnityPrintFloat((float)expected);
769
- UnityPrint(UnityStrWas);
770
- UnityPrintFloat((float)actual);
771
- #else
772
- UnityPrint(UnityStrDelta);
773
- #endif
774
- UnityAddMsgIfSpecified(msg);
775
- UNITY_FAIL_AND_BAIL;
776
- }
777
- }
778
-
779
- //-----------------------------------------------
780
-
781
- void UnityAssertDoubleSpecial(const _UD actual,
782
- const char* msg,
783
- const UNITY_LINE_TYPE lineNumber,
784
- const UNITY_FLOAT_TRAIT_T style)
785
- {
786
- UNITY_SKIP_EXECUTION;
787
-
788
- const char* trait_names[] = { UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet };
789
- _U_SINT should_be_trait = ((_U_SINT)style & 1);
790
- _U_SINT is_trait = !should_be_trait;
791
- _U_SINT trait_index = style >> 1;
792
-
793
- switch(style)
794
- {
795
- //To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
796
- //We are using a variable to hold the zero value because some compilers complain about dividing by zero otherwise
797
- case UNITY_FLOAT_IS_INF:
798
- case UNITY_FLOAT_IS_NOT_INF:
799
- is_trait = ((1.0 / d_zero) == actual) ? 1 : 0;
800
- break;
801
- case UNITY_FLOAT_IS_NEG_INF:
802
- case UNITY_FLOAT_IS_NOT_NEG_INF:
803
- is_trait = ((-1.0 / d_zero) == actual) ? 1 : 0;
804
- break;
805
-
806
- //NaN is the only floating point value that does NOT equal itself. Therefore if Actual == Actual, then it is NOT NaN.
807
- case UNITY_FLOAT_IS_NAN:
808
- case UNITY_FLOAT_IS_NOT_NAN:
809
- is_trait = (actual == actual) ? 0 : 1;
810
- break;
811
-
812
- //A determinate number is non infinite and not NaN. (therefore the opposite of the two above)
813
- case UNITY_FLOAT_IS_DET:
814
- case UNITY_FLOAT_IS_NOT_DET:
815
- if ( (actual != actual) || ((1.0 / d_zero) == actual) || ((-1.0 / d_zero) == actual) )
816
- is_trait = 0;
817
- else
818
- is_trait = 1;
819
- break;
820
- }
821
-
822
- if (is_trait != should_be_trait)
823
- {
824
- UnityTestResultsFailBegin(lineNumber);
825
- UnityPrint(UnityStrExpected);
826
- if (!should_be_trait)
827
- UnityPrint(UnityStrNot);
828
- UnityPrint(trait_names[trait_index]);
829
- UnityPrint(UnityStrWas);
830
- #ifdef UNITY_DOUBLE_VERBOSE
831
- UnityPrintFloat(actual);
832
- #else
833
- if (should_be_trait)
834
- UnityPrint(UnityStrNot);
835
- UnityPrint(trait_names[trait_index]);
836
- #endif
837
- UnityAddMsgIfSpecified(msg);
838
- UNITY_FAIL_AND_BAIL;
839
- }
840
- }
841
-
842
-
843
- #endif // not UNITY_EXCLUDE_DOUBLE
844
-
845
- //-----------------------------------------------
846
- void UnityAssertNumbersWithin( const _U_SINT delta,
847
- const _U_SINT expected,
848
- const _U_SINT actual,
849
- const char* msg,
850
- const UNITY_LINE_TYPE lineNumber,
851
- const UNITY_DISPLAY_STYLE_T style)
852
- {
853
- UNITY_SKIP_EXECUTION;
854
-
855
- if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
856
- {
857
- if (actual > expected)
858
- Unity.CurrentTestFailed = ((actual - expected) > delta);
859
- else
860
- Unity.CurrentTestFailed = ((expected - actual) > delta);
861
- }
862
- else
863
- {
864
- if ((_U_UINT)actual > (_U_UINT)expected)
865
- Unity.CurrentTestFailed = ((_U_UINT)(actual - expected) > (_U_UINT)delta);
866
- else
867
- Unity.CurrentTestFailed = ((_U_UINT)(expected - actual) > (_U_UINT)delta);
868
- }
869
-
870
- if (Unity.CurrentTestFailed)
871
- {
872
- UnityTestResultsFailBegin(lineNumber);
873
- UnityPrint(UnityStrDelta);
874
- UnityPrintNumberByStyle(delta, style);
875
- UnityPrint(UnityStrExpected);
876
- UnityPrintNumberByStyle(expected, style);
877
- UnityPrint(UnityStrWas);
878
- UnityPrintNumberByStyle(actual, style);
879
- UnityAddMsgIfSpecified(msg);
880
- UNITY_FAIL_AND_BAIL;
881
- }
882
- }
883
-
884
- //-----------------------------------------------
885
- void UnityAssertEqualString(const char* expected,
886
- const char* actual,
887
- const char* msg,
888
- const UNITY_LINE_TYPE lineNumber)
889
- {
890
- _UU32 i;
891
-
892
- UNITY_SKIP_EXECUTION;
893
-
894
- // if both pointers not null compare the strings
895
- if (expected && actual)
896
- {
897
- for (i = 0; expected[i] || actual[i]; i++)
898
- {
899
- if (expected[i] != actual[i])
900
- {
901
- Unity.CurrentTestFailed = 1;
902
- break;
903
- }
904
- }
905
- }
906
- else
907
- { // handle case of one pointers being null (if both null, test should pass)
908
- if (expected != actual)
909
- {
910
- Unity.CurrentTestFailed = 1;
911
- }
912
- }
913
-
914
- if (Unity.CurrentTestFailed)
915
- {
916
- UnityTestResultsFailBegin(lineNumber);
917
- UnityPrintExpectedAndActualStrings(expected, actual);
918
- UnityAddMsgIfSpecified(msg);
919
- UNITY_FAIL_AND_BAIL;
920
- }
921
- }
922
-
923
- //-----------------------------------------------
924
- void UnityAssertEqualStringArray( const char** expected,
925
- const char** actual,
926
- const _UU32 num_elements,
927
- const char* msg,
928
- const UNITY_LINE_TYPE lineNumber)
929
- {
930
- _UU32 i, j = 0;
931
-
932
- UNITY_SKIP_EXECUTION;
933
-
934
- // if no elements, it's an error
935
- if (num_elements == 0)
936
- {
937
- UnityTestResultsFailBegin(lineNumber);
938
- UnityPrint(UnityStrPointless);
939
- UnityAddMsgIfSpecified(msg);
940
- UNITY_FAIL_AND_BAIL;
941
- }
942
-
943
- if (UnityCheckArraysForNull((UNITY_PTR_ATTRIBUTE void*)expected, (UNITY_PTR_ATTRIBUTE void*)actual, lineNumber, msg) == 1)
944
- return;
945
-
946
- do
947
- {
948
- // if both pointers not null compare the strings
949
- if (expected[j] && actual[j])
950
- {
951
- for (i = 0; expected[j][i] || actual[j][i]; i++)
952
- {
953
- if (expected[j][i] != actual[j][i])
954
- {
955
- Unity.CurrentTestFailed = 1;
956
- break;
957
- }
958
- }
959
- }
960
- else
961
- { // handle case of one pointers being null (if both null, test should pass)
962
- if (expected[j] != actual[j])
963
- {
964
- Unity.CurrentTestFailed = 1;
965
- }
966
- }
967
-
968
- if (Unity.CurrentTestFailed)
969
- {
970
- UnityTestResultsFailBegin(lineNumber);
971
- if (num_elements > 1)
972
- {
973
- UnityPrint(UnityStrElement);
974
- UnityPrintNumberByStyle((j), UNITY_DISPLAY_STYLE_UINT);
975
- }
976
- UnityPrintExpectedAndActualStrings((const char*)(expected[j]), (const char*)(actual[j]));
977
- UnityAddMsgIfSpecified(msg);
978
- UNITY_FAIL_AND_BAIL;
979
- }
980
- } while (++j < num_elements);
981
- }
982
-
983
- //-----------------------------------------------
984
- void UnityAssertEqualMemory( UNITY_PTR_ATTRIBUTE const void* expected,
985
- UNITY_PTR_ATTRIBUTE const void* actual,
986
- const _UU32 length,
987
- const _UU32 num_elements,
988
- const char* msg,
989
- const UNITY_LINE_TYPE lineNumber)
990
- {
991
- UNITY_PTR_ATTRIBUTE unsigned char* ptr_exp = (UNITY_PTR_ATTRIBUTE unsigned char*)expected;
992
- UNITY_PTR_ATTRIBUTE unsigned char* ptr_act = (UNITY_PTR_ATTRIBUTE unsigned char*)actual;
993
- _UU32 elements = num_elements;
994
- _UU32 bytes;
995
-
996
- UNITY_SKIP_EXECUTION;
997
-
998
- if ((elements == 0) || (length == 0))
999
- {
1000
- UnityTestResultsFailBegin(lineNumber);
1001
- UnityPrint(UnityStrPointless);
1002
- UnityAddMsgIfSpecified(msg);
1003
- UNITY_FAIL_AND_BAIL;
1004
- }
1005
-
1006
- if (UnityCheckArraysForNull((UNITY_PTR_ATTRIBUTE void*)expected, (UNITY_PTR_ATTRIBUTE void*)actual, lineNumber, msg) == 1)
1007
- return;
1008
-
1009
- while (elements--)
1010
- {
1011
- /////////////////////////////////////
1012
- bytes = length;
1013
- while (bytes--)
1014
- {
1015
- if (*ptr_exp != *ptr_act)
1016
- {
1017
- UnityTestResultsFailBegin(lineNumber);
1018
- UnityPrint(UnityStrMemory);
1019
- if (num_elements > 1)
1020
- {
1021
- UnityPrint(UnityStrElement);
1022
- UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
1023
- }
1024
- UnityPrint(UnityStrByte);
1025
- UnityPrintNumberByStyle((length - bytes - 1), UNITY_DISPLAY_STYLE_UINT);
1026
- UnityPrint(UnityStrExpected);
1027
- UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8);
1028
- UnityPrint(UnityStrWas);
1029
- UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8);
1030
- UnityAddMsgIfSpecified(msg);
1031
- UNITY_FAIL_AND_BAIL;
1032
- }
1033
- ptr_exp += 1;
1034
- ptr_act += 1;
1035
- }
1036
- /////////////////////////////////////
1037
-
1038
- }
1039
- }
1040
-
1041
- //-----------------------------------------------
1042
- // Control Functions
1043
- //-----------------------------------------------
1044
-
1045
- void UnityFail(const char* msg, const UNITY_LINE_TYPE line)
1046
- {
1047
- UNITY_SKIP_EXECUTION;
1048
-
1049
- UnityTestResultsBegin(Unity.TestFile, line);
1050
- UnityPrintFail();
1051
- if (msg != NULL)
1052
- {
1053
- UNITY_OUTPUT_CHAR(':');
1054
- if (msg[0] != ' ')
1055
- {
1056
- UNITY_OUTPUT_CHAR(' ');
1057
- }
1058
- UnityPrint(msg);
1059
- }
1060
- UNITY_FAIL_AND_BAIL;
1061
- }
1062
-
1063
- //-----------------------------------------------
1064
- void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
1065
- {
1066
- UNITY_SKIP_EXECUTION;
1067
-
1068
- UnityTestResultsBegin(Unity.TestFile, line);
1069
- UnityPrint("IGNORE");
1070
- if (msg != NULL)
1071
- {
1072
- UNITY_OUTPUT_CHAR(':');
1073
- UNITY_OUTPUT_CHAR(' ');
1074
- UnityPrint(msg);
1075
- }
1076
- UNITY_IGNORE_AND_BAIL;
1077
- }
1078
-
1079
- //-----------------------------------------------
1080
- #ifdef UNITY_SUPPORT_WEAK
1081
- UNITY_WEAK void setUp(void) { }
1082
- UNITY_WEAK void tearDown(void) { }
1083
- #else
1084
- void setUp(void);
1085
- void tearDown(void);
1086
- #endif
1087
- //-----------------------------------------------
1088
- void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)
1089
- {
1090
- Unity.CurrentTestName = FuncName;
1091
- Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum;
1092
- Unity.NumberOfTests++;
1093
- if (TEST_PROTECT())
1094
- {
1095
- setUp();
1096
- Func();
1097
- }
1098
- if (TEST_PROTECT() && !(Unity.CurrentTestIgnored))
1099
- {
1100
- tearDown();
1101
- }
1102
- UnityConcludeTest();
1103
- }
1104
-
1105
- //-----------------------------------------------
1106
- void UnityBegin(void)
1107
- {
1108
- Unity.TestFile = NULL;
1109
- Unity.CurrentTestName = NULL;
1110
- Unity.CurrentTestLineNumber = 0;
1111
- Unity.NumberOfTests = 0;
1112
- Unity.TestFailures = 0;
1113
- Unity.TestIgnores = 0;
1114
- Unity.CurrentTestFailed = 0;
1115
- Unity.CurrentTestIgnored = 0;
1116
- }
1117
-
1118
- //-----------------------------------------------
1119
- int UnityEnd(void)
1120
- {
1121
- UNITY_PRINT_EOL;
1122
- UnityPrint("-----------------------");
1123
- UNITY_PRINT_EOL;
1124
- UnityPrintNumber((_U_SINT)(Unity.NumberOfTests));
1125
- UnityPrint(" Tests ");
1126
- UnityPrintNumber((_U_SINT)(Unity.TestFailures));
1127
- UnityPrint(" Failures ");
1128
- UnityPrintNumber((_U_SINT)(Unity.TestIgnores));
1129
- UnityPrint(" Ignored");
1130
- UNITY_PRINT_EOL;
1131
- if (Unity.TestFailures == 0U)
1132
- {
1133
- UnityPrintOk();
1134
- }
1135
- else
1136
- {
1137
- UnityPrintFail();
1138
- }
1139
- UNITY_PRINT_EOL;
1140
- return (int)(Unity.TestFailures);
1141
- }
1142
-
1143
- //-----------------------------------------------
1144
-
1145
-
1
+ /* =========================================================================
2
+ Unity Project - A Test Framework for C
3
+ Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
4
+ [Released under MIT License. Please refer to license.txt for details]
5
+ ============================================================================ */
6
+
7
+ #include "unity.h"
8
+ #include <stddef.h>
9
+
10
+ #define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; longjmp(Unity.AbortFrame, 1); }
11
+ #define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; longjmp(Unity.AbortFrame, 1); }
12
+ /// return prematurely if we are already in failure or ignore state
13
+ #define UNITY_SKIP_EXECUTION { if ((Unity.CurrentTestFailed != 0) || (Unity.CurrentTestIgnored != 0)) {return;} }
14
+
15
+ struct _Unity Unity;
16
+
17
+ const char UnityStrOk[] = "OK";
18
+ const char UnityStrPass[] = "PASS";
19
+ const char UnityStrFail[] = "FAIL";
20
+ const char UnityStrIgnore[] = "IGNORE";
21
+ const char UnityStrNull[] = "NULL";
22
+ const char UnityStrSpacer[] = ". ";
23
+ const char UnityStrExpected[] = " Expected ";
24
+ const char UnityStrWas[] = " Was ";
25
+ const char UnityStrTo[] = " To ";
26
+ const char UnityStrElement[] = " Element ";
27
+ const char UnityStrByte[] = " Byte ";
28
+ const char UnityStrMemory[] = " Memory Mismatch.";
29
+ const char UnityStrDelta[] = " Values Not Within Delta ";
30
+ const char UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless.";
31
+ const char UnityStrNullPointerForExpected[] = " Expected pointer to be NULL";
32
+ const char UnityStrNullPointerForActual[] = " Actual pointer was NULL";
33
+ const char UnityStrNot[] = "Not ";
34
+ const char UnityStrInf[] = "Infinity";
35
+ const char UnityStrNegInf[] = "Negative Infinity";
36
+ const char UnityStrNaN[] = "NaN";
37
+ const char UnityStrDet[] = "Determinate";
38
+ const char UnityStrErrFloat[] = "Unity Floating Point Disabled";
39
+ const char UnityStrErrDouble[] = "Unity Double Precision Disabled";
40
+ const char UnityStrErr64[] = "Unity 64-bit Support Disabled";
41
+ const char UnityStrBreaker[] = "-----------------------";
42
+ const char UnityStrResultsTests[] = " Tests ";
43
+ const char UnityStrResultsFailures[] = " Failures ";
44
+ const char UnityStrResultsIgnored[] = " Ignored ";
45
+ const char UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " ";
46
+ const char UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " ";
47
+
48
+ #ifdef UNITY_FLOAT_NEEDS_ZERO
49
+ // Dividing by these constants produces +/- infinity.
50
+ // The rationale is given in UnityAssertFloatIsInf's body.
51
+ static const _UF f_zero = 0.0f;
52
+ #endif
53
+
54
+ // compiler-generic print formatting masks
55
+ const _U_UINT UnitySizeMask[] =
56
+ {
57
+ 255u, // 0xFF
58
+ 65535u, // 0xFFFF
59
+ 65535u,
60
+ 4294967295u, // 0xFFFFFFFF
61
+ 4294967295u,
62
+ 4294967295u,
63
+ 4294967295u
64
+ #ifdef UNITY_SUPPORT_64
65
+ ,0xFFFFFFFFFFFFFFFF
66
+ #endif
67
+ };
68
+
69
+ void UnityPrintFail(void);
70
+ void UnityPrintOk(void);
71
+
72
+ //-----------------------------------------------
73
+ // Pretty Printers & Test Result Output Handlers
74
+ //-----------------------------------------------
75
+
76
+ void UnityPrint(const char* string)
77
+ {
78
+ const char* pch = string;
79
+
80
+ if (pch != NULL)
81
+ {
82
+ while (*pch)
83
+ {
84
+ // printable characters plus CR & LF are printed
85
+ if ((*pch <= 126) && (*pch >= 32))
86
+ {
87
+ UNITY_OUTPUT_CHAR(*pch);
88
+ }
89
+ //write escaped carriage returns
90
+ else if (*pch == 13)
91
+ {
92
+ UNITY_OUTPUT_CHAR('\\');
93
+ UNITY_OUTPUT_CHAR('r');
94
+ }
95
+ //write escaped line feeds
96
+ else if (*pch == 10)
97
+ {
98
+ UNITY_OUTPUT_CHAR('\\');
99
+ UNITY_OUTPUT_CHAR('n');
100
+ }
101
+ // unprintable characters are shown as codes
102
+ else
103
+ {
104
+ UNITY_OUTPUT_CHAR('\\');
105
+ UnityPrintNumberHex((_U_UINT)*pch, 2);
106
+ }
107
+ pch++;
108
+ }
109
+ }
110
+ }
111
+
112
+ void UnityPrintLen(const char* string, const _UU32 length);
113
+ void UnityPrintLen(const char* string, const _UU32 length)
114
+ {
115
+ const char* pch = string;
116
+
117
+ if (pch != NULL)
118
+ {
119
+ while (*pch && (_UU32)(pch - string) < length)
120
+ {
121
+ // printable characters plus CR & LF are printed
122
+ if ((*pch <= 126) && (*pch >= 32))
123
+ {
124
+ UNITY_OUTPUT_CHAR(*pch);
125
+ }
126
+ //write escaped carriage returns
127
+ else if (*pch == 13)
128
+ {
129
+ UNITY_OUTPUT_CHAR('\\');
130
+ UNITY_OUTPUT_CHAR('r');
131
+ }
132
+ //write escaped line feeds
133
+ else if (*pch == 10)
134
+ {
135
+ UNITY_OUTPUT_CHAR('\\');
136
+ UNITY_OUTPUT_CHAR('n');
137
+ }
138
+ // unprintable characters are shown as codes
139
+ else
140
+ {
141
+ UNITY_OUTPUT_CHAR('\\');
142
+ UnityPrintNumberHex((_U_UINT)*pch, 2);
143
+ }
144
+ pch++;
145
+ }
146
+ }
147
+ }
148
+
149
+ //-----------------------------------------------
150
+ void UnityPrintNumberByStyle(const _U_SINT number, const UNITY_DISPLAY_STYLE_T style)
151
+ {
152
+ if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
153
+ {
154
+ UnityPrintNumber(number);
155
+ }
156
+ else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT)
157
+ {
158
+ UnityPrintNumberUnsigned( (_U_UINT)number & UnitySizeMask[((_U_UINT)style & (_U_UINT)0x0F) - 1] );
159
+ }
160
+ else
161
+ {
162
+ UnityPrintNumberHex((_U_UINT)number, (char)((style & 0x000F) << 1));
163
+ }
164
+ }
165
+
166
+ //-----------------------------------------------
167
+ /// basically do an itoa using as little ram as possible
168
+ void UnityPrintNumber(const _U_SINT number_to_print)
169
+ {
170
+ _U_UINT divisor = 1;
171
+ _U_UINT next_divisor;
172
+ _U_UINT number;
173
+
174
+ if (number_to_print < 0)
175
+ {
176
+ //A negative number, including MIN negative
177
+ UNITY_OUTPUT_CHAR('-');
178
+ number = (_U_UINT)(-number_to_print);
179
+ }
180
+ else
181
+ {
182
+ //Non-negative number
183
+ number = (_U_UINT)number_to_print;
184
+ }
185
+
186
+ // figure out initial divisor
187
+ while (number / divisor > 9)
188
+ {
189
+ next_divisor = divisor * 10;
190
+ if (next_divisor > divisor)
191
+ divisor = next_divisor;
192
+ else
193
+ break;
194
+ }
195
+
196
+ // now mod and print, then divide divisor
197
+ do
198
+ {
199
+ UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10)));
200
+ divisor /= 10;
201
+ }
202
+ while (divisor > 0);
203
+ }
204
+
205
+ //-----------------------------------------------
206
+ /// basically do an itoa using as little ram as possible
207
+ void UnityPrintNumberUnsigned(const _U_UINT number)
208
+ {
209
+ _U_UINT divisor = 1;
210
+ _U_UINT next_divisor;
211
+
212
+ // figure out initial divisor
213
+ while (number / divisor > 9)
214
+ {
215
+ next_divisor = divisor * 10;
216
+ if (next_divisor > divisor)
217
+ divisor = next_divisor;
218
+ else
219
+ break;
220
+ }
221
+
222
+ // now mod and print, then divide divisor
223
+ do
224
+ {
225
+ UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10)));
226
+ divisor /= 10;
227
+ }
228
+ while (divisor > 0);
229
+ }
230
+
231
+ //-----------------------------------------------
232
+ void UnityPrintNumberHex(const _U_UINT number, const char nibbles_to_print)
233
+ {
234
+ _U_UINT nibble;
235
+ char nibbles = nibbles_to_print;
236
+ UNITY_OUTPUT_CHAR('0');
237
+ UNITY_OUTPUT_CHAR('x');
238
+
239
+ while (nibbles > 0)
240
+ {
241
+ nibble = (number >> (--nibbles << 2)) & 0x0000000F;
242
+ if (nibble <= 9)
243
+ {
244
+ UNITY_OUTPUT_CHAR((char)('0' + nibble));
245
+ }
246
+ else
247
+ {
248
+ UNITY_OUTPUT_CHAR((char)('A' - 10 + nibble));
249
+ }
250
+ }
251
+ }
252
+
253
+ //-----------------------------------------------
254
+ void UnityPrintMask(const _U_UINT mask, const _U_UINT number)
255
+ {
256
+ _U_UINT current_bit = (_U_UINT)1 << (UNITY_INT_WIDTH - 1);
257
+ _US32 i;
258
+
259
+ for (i = 0; i < UNITY_INT_WIDTH; i++)
260
+ {
261
+ if (current_bit & mask)
262
+ {
263
+ if (current_bit & number)
264
+ {
265
+ UNITY_OUTPUT_CHAR('1');
266
+ }
267
+ else
268
+ {
269
+ UNITY_OUTPUT_CHAR('0');
270
+ }
271
+ }
272
+ else
273
+ {
274
+ UNITY_OUTPUT_CHAR('X');
275
+ }
276
+ current_bit = current_bit >> 1;
277
+ }
278
+ }
279
+
280
+ //-----------------------------------------------
281
+ #ifdef UNITY_FLOAT_VERBOSE
282
+ #include <stdio.h>
283
+
284
+ #ifndef UNITY_VERBOSE_NUMBER_MAX_LENGTH
285
+ # ifdef UNITY_DOUBLE_VERBOSE
286
+ # define UNITY_VERBOSE_NUMBER_MAX_LENGTH 317
287
+ # else
288
+ # define UNITY_VERBOSE_NUMBER_MAX_LENGTH 47
289
+ # endif
290
+ #endif
291
+
292
+ void UnityPrintFloat(_UF number)
293
+ {
294
+ char TempBuffer[UNITY_VERBOSE_NUMBER_MAX_LENGTH + 1];
295
+ snprintf(TempBuffer, sizeof(TempBuffer), "%.6f", number);
296
+ UnityPrint(TempBuffer);
297
+ }
298
+ #endif
299
+
300
+ //-----------------------------------------------
301
+
302
+ void UnityPrintFail(void);
303
+ void UnityPrintFail(void)
304
+ {
305
+ UnityPrint(UnityStrFail);
306
+ }
307
+
308
+ void UnityPrintOk(void);
309
+ void UnityPrintOk(void)
310
+ {
311
+ UnityPrint(UnityStrOk);
312
+ }
313
+
314
+ //-----------------------------------------------
315
+ static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line);
316
+ static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
317
+ {
318
+ #ifndef UNITY_FIXTURES
319
+ UnityPrint(file);
320
+ UNITY_OUTPUT_CHAR(':');
321
+ UnityPrintNumber((_U_SINT)line);
322
+ UNITY_OUTPUT_CHAR(':');
323
+ UnityPrint(Unity.CurrentTestName);
324
+ UNITY_OUTPUT_CHAR(':');
325
+ #else
326
+ UNITY_UNUSED(file);
327
+ UNITY_UNUSED(line);
328
+ #endif
329
+ }
330
+
331
+ //-----------------------------------------------
332
+ static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line);
333
+ static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line)
334
+ {
335
+ #ifndef UNITY_FIXTURES
336
+ UnityTestResultsBegin(Unity.TestFile, line);
337
+ #else
338
+ UNITY_UNUSED(line);
339
+ #endif
340
+ UnityPrint(UnityStrFail);
341
+ UNITY_OUTPUT_CHAR(':');
342
+ }
343
+
344
+ //-----------------------------------------------
345
+ void UnityConcludeTest(void)
346
+ {
347
+ if (Unity.CurrentTestIgnored)
348
+ {
349
+ Unity.TestIgnores++;
350
+ }
351
+ else if (!Unity.CurrentTestFailed)
352
+ {
353
+ UnityTestResultsBegin(Unity.TestFile, Unity.CurrentTestLineNumber);
354
+ UnityPrint(UnityStrPass);
355
+ }
356
+ else
357
+ {
358
+ Unity.TestFailures++;
359
+ }
360
+
361
+ Unity.CurrentTestFailed = 0;
362
+ Unity.CurrentTestIgnored = 0;
363
+ UNITY_PRINT_EOL();
364
+ }
365
+
366
+ //-----------------------------------------------
367
+ static void UnityAddMsgIfSpecified(const char* msg);
368
+ static void UnityAddMsgIfSpecified(const char* msg)
369
+ {
370
+ if (msg)
371
+ {
372
+ UnityPrint(UnityStrSpacer);
373
+ #ifndef UNITY_EXCLUDE_DETAILS
374
+ if (Unity.CurrentDetail1)
375
+ {
376
+ UnityPrint(UnityStrDetail1Name);
377
+ UnityPrint(Unity.CurrentDetail1);
378
+ if (Unity.CurrentDetail2)
379
+ {
380
+ UnityPrint(UnityStrDetail2Name);
381
+ UnityPrint(Unity.CurrentDetail2);
382
+ }
383
+ UnityPrint(UnityStrSpacer);
384
+ }
385
+ #endif
386
+ UnityPrint(msg);
387
+ }
388
+ }
389
+
390
+ //-----------------------------------------------
391
+ static void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual);
392
+ static void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual)
393
+ {
394
+ UnityPrint(UnityStrExpected);
395
+ if (expected != NULL)
396
+ {
397
+ UNITY_OUTPUT_CHAR('\'');
398
+ UnityPrint(expected);
399
+ UNITY_OUTPUT_CHAR('\'');
400
+ }
401
+ else
402
+ {
403
+ UnityPrint(UnityStrNull);
404
+ }
405
+ UnityPrint(UnityStrWas);
406
+ if (actual != NULL)
407
+ {
408
+ UNITY_OUTPUT_CHAR('\'');
409
+ UnityPrint(actual);
410
+ UNITY_OUTPUT_CHAR('\'');
411
+ }
412
+ else
413
+ {
414
+ UnityPrint(UnityStrNull);
415
+ }
416
+ }
417
+
418
+ //-----------------------------------------------
419
+ static void UnityPrintExpectedAndActualStringsLen(const char* expected, const char* actual, const _UU32 length)
420
+ {
421
+ UnityPrint(UnityStrExpected);
422
+ if (expected != NULL)
423
+ {
424
+ UNITY_OUTPUT_CHAR('\'');
425
+ UnityPrintLen(expected, length);
426
+ UNITY_OUTPUT_CHAR('\'');
427
+ }
428
+ else
429
+ {
430
+ UnityPrint(UnityStrNull);
431
+ }
432
+ UnityPrint(UnityStrWas);
433
+ if (actual != NULL)
434
+ {
435
+ UNITY_OUTPUT_CHAR('\'');
436
+ UnityPrintLen(actual, length);
437
+ UNITY_OUTPUT_CHAR('\'');
438
+ }
439
+ else
440
+ {
441
+ UnityPrint(UnityStrNull);
442
+ }
443
+ }
444
+
445
+
446
+
447
+ //-----------------------------------------------
448
+ // Assertion & Control Helpers
449
+ //-----------------------------------------------
450
+
451
+ static int UnityCheckArraysForNull(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const UNITY_LINE_TYPE lineNumber, const char* msg)
452
+ {
453
+ //return true if they are both NULL
454
+ if ((expected == NULL) && (actual == NULL))
455
+ return 1;
456
+
457
+ //throw error if just expected is NULL
458
+ if (expected == NULL)
459
+ {
460
+ UnityTestResultsFailBegin(lineNumber);
461
+ UnityPrint(UnityStrNullPointerForExpected);
462
+ UnityAddMsgIfSpecified(msg);
463
+ UNITY_FAIL_AND_BAIL;
464
+ }
465
+
466
+ //throw error if just actual is NULL
467
+ if (actual == NULL)
468
+ {
469
+ UnityTestResultsFailBegin(lineNumber);
470
+ UnityPrint(UnityStrNullPointerForActual);
471
+ UnityAddMsgIfSpecified(msg);
472
+ UNITY_FAIL_AND_BAIL;
473
+ }
474
+
475
+ //return false if neither is NULL
476
+ return 0;
477
+ }
478
+
479
+ //-----------------------------------------------
480
+ // Assertion Functions
481
+ //-----------------------------------------------
482
+
483
+ void UnityAssertBits(const _U_SINT mask,
484
+ const _U_SINT expected,
485
+ const _U_SINT actual,
486
+ const char* msg,
487
+ const UNITY_LINE_TYPE lineNumber)
488
+ {
489
+ UNITY_SKIP_EXECUTION;
490
+
491
+ if ((mask & expected) != (mask & actual))
492
+ {
493
+ UnityTestResultsFailBegin(lineNumber);
494
+ UnityPrint(UnityStrExpected);
495
+ UnityPrintMask((_U_UINT)mask, (_U_UINT)expected);
496
+ UnityPrint(UnityStrWas);
497
+ UnityPrintMask((_U_UINT)mask, (_U_UINT)actual);
498
+ UnityAddMsgIfSpecified(msg);
499
+ UNITY_FAIL_AND_BAIL;
500
+ }
501
+ }
502
+
503
+ //-----------------------------------------------
504
+ void UnityAssertEqualNumber(const _U_SINT expected,
505
+ const _U_SINT actual,
506
+ const char* msg,
507
+ const UNITY_LINE_TYPE lineNumber,
508
+ const UNITY_DISPLAY_STYLE_T style)
509
+ {
510
+ UNITY_SKIP_EXECUTION;
511
+
512
+ if (expected != actual)
513
+ {
514
+ UnityTestResultsFailBegin(lineNumber);
515
+ UnityPrint(UnityStrExpected);
516
+ UnityPrintNumberByStyle(expected, style);
517
+ UnityPrint(UnityStrWas);
518
+ UnityPrintNumberByStyle(actual, style);
519
+ UnityAddMsgIfSpecified(msg);
520
+ UNITY_FAIL_AND_BAIL;
521
+ }
522
+ }
523
+
524
+ //-----------------------------------------------
525
+ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
526
+ UNITY_INTERNAL_PTR actual,
527
+ const _UU32 num_elements,
528
+ const char* msg,
529
+ const UNITY_LINE_TYPE lineNumber,
530
+ const UNITY_DISPLAY_STYLE_T style)
531
+ {
532
+ _UU32 elements = num_elements;
533
+ UNITY_INTERNAL_PTR ptr_exp = (UNITY_INTERNAL_PTR)expected;
534
+ UNITY_INTERNAL_PTR ptr_act = (UNITY_INTERNAL_PTR)actual;
535
+
536
+ UNITY_SKIP_EXECUTION;
537
+
538
+ if (elements == 0)
539
+ {
540
+ UnityTestResultsFailBegin(lineNumber);
541
+ UnityPrint(UnityStrPointless);
542
+ UnityAddMsgIfSpecified(msg);
543
+ UNITY_FAIL_AND_BAIL;
544
+ }
545
+
546
+ if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
547
+ return;
548
+
549
+ // If style is UNITY_DISPLAY_STYLE_INT, we'll fall into the default case rather than the INT16 or INT32 (etc) case
550
+ // as UNITY_DISPLAY_STYLE_INT includes a flag for UNITY_DISPLAY_RANGE_AUTO, which the width-specific
551
+ // variants do not. Therefore remove this flag.
552
+ switch(style & (UNITY_DISPLAY_STYLE_T)(~UNITY_DISPLAY_RANGE_AUTO))
553
+ {
554
+ case UNITY_DISPLAY_STYLE_HEX8:
555
+ case UNITY_DISPLAY_STYLE_INT8:
556
+ case UNITY_DISPLAY_STYLE_UINT8:
557
+ while (elements--)
558
+ {
559
+ if (*(UNITY_PTR_ATTRIBUTE const _US8*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US8*)ptr_act)
560
+ {
561
+ UnityTestResultsFailBegin(lineNumber);
562
+ UnityPrint(UnityStrElement);
563
+ UnityPrintNumberUnsigned(num_elements - elements - 1);
564
+ UnityPrint(UnityStrExpected);
565
+ UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US8*)ptr_exp, style);
566
+ UnityPrint(UnityStrWas);
567
+ UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US8*)ptr_act, style);
568
+ UnityAddMsgIfSpecified(msg);
569
+ UNITY_FAIL_AND_BAIL;
570
+ }
571
+ ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 1);
572
+ ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 1);
573
+ }
574
+ break;
575
+ case UNITY_DISPLAY_STYLE_HEX16:
576
+ case UNITY_DISPLAY_STYLE_INT16:
577
+ case UNITY_DISPLAY_STYLE_UINT16:
578
+ while (elements--)
579
+ {
580
+ if (*(UNITY_PTR_ATTRIBUTE const _US16*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US16*)ptr_act)
581
+ {
582
+ UnityTestResultsFailBegin(lineNumber);
583
+ UnityPrint(UnityStrElement);
584
+ UnityPrintNumberUnsigned(num_elements - elements - 1);
585
+ UnityPrint(UnityStrExpected);
586
+ UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US16*)ptr_exp, style);
587
+ UnityPrint(UnityStrWas);
588
+ UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US16*)ptr_act, style);
589
+ UnityAddMsgIfSpecified(msg);
590
+ UNITY_FAIL_AND_BAIL;
591
+ }
592
+ ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 2);
593
+ ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 2);
594
+ }
595
+ break;
596
+ #ifdef UNITY_SUPPORT_64
597
+ case UNITY_DISPLAY_STYLE_HEX64:
598
+ case UNITY_DISPLAY_STYLE_INT64:
599
+ case UNITY_DISPLAY_STYLE_UINT64:
600
+ while (elements--)
601
+ {
602
+ if (*(UNITY_PTR_ATTRIBUTE const _US64*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US64*)ptr_act)
603
+ {
604
+ UnityTestResultsFailBegin(lineNumber);
605
+ UnityPrint(UnityStrElement);
606
+ UnityPrintNumberUnsigned(num_elements - elements - 1);
607
+ UnityPrint(UnityStrExpected);
608
+ UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US64*)ptr_exp, style);
609
+ UnityPrint(UnityStrWas);
610
+ UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US64*)ptr_act, style);
611
+ UnityAddMsgIfSpecified(msg);
612
+ UNITY_FAIL_AND_BAIL;
613
+ }
614
+ ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 8);
615
+ ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 8);
616
+ }
617
+ break;
618
+ #endif
619
+ default:
620
+ while (elements--)
621
+ {
622
+ if (*(UNITY_PTR_ATTRIBUTE const _US32*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US32*)ptr_act)
623
+ {
624
+ UnityTestResultsFailBegin(lineNumber);
625
+ UnityPrint(UnityStrElement);
626
+ UnityPrintNumberUnsigned(num_elements - elements - 1);
627
+ UnityPrint(UnityStrExpected);
628
+ UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US32*)ptr_exp, style);
629
+ UnityPrint(UnityStrWas);
630
+ UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US32*)ptr_act, style);
631
+ UnityAddMsgIfSpecified(msg);
632
+ UNITY_FAIL_AND_BAIL;
633
+ }
634
+ ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 4);
635
+ ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 4);
636
+ }
637
+ break;
638
+ }
639
+ }
640
+
641
+ //-----------------------------------------------
642
+ #ifndef UNITY_EXCLUDE_FLOAT
643
+ void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const _UF* expected,
644
+ UNITY_PTR_ATTRIBUTE const _UF* actual,
645
+ const _UU32 num_elements,
646
+ const char* msg,
647
+ const UNITY_LINE_TYPE lineNumber)
648
+ {
649
+ _UU32 elements = num_elements;
650
+ UNITY_PTR_ATTRIBUTE const _UF* ptr_expected = expected;
651
+ UNITY_PTR_ATTRIBUTE const _UF* ptr_actual = actual;
652
+ _UF diff, tol;
653
+
654
+ UNITY_SKIP_EXECUTION;
655
+
656
+ if (elements == 0)
657
+ {
658
+ UnityTestResultsFailBegin(lineNumber);
659
+ UnityPrint(UnityStrPointless);
660
+ UnityAddMsgIfSpecified(msg);
661
+ UNITY_FAIL_AND_BAIL;
662
+ }
663
+
664
+ if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
665
+ return;
666
+
667
+ while (elements--)
668
+ {
669
+ diff = *ptr_expected - *ptr_actual;
670
+ if (diff < 0.0f)
671
+ diff = 0.0f - diff;
672
+ tol = UNITY_FLOAT_PRECISION * *ptr_expected;
673
+ if (tol < 0.0f)
674
+ tol = 0.0f - tol;
675
+
676
+ //This first part of this condition will catch any NaN or Infinite values
677
+ if ((diff * 0.0f != 0.0f) || (diff > tol))
678
+ {
679
+ UnityTestResultsFailBegin(lineNumber);
680
+ UnityPrint(UnityStrElement);
681
+ UnityPrintNumberUnsigned(num_elements - elements - 1);
682
+ #ifdef UNITY_FLOAT_VERBOSE
683
+ UnityPrint(UnityStrExpected);
684
+ UnityPrintFloat(*ptr_expected);
685
+ UnityPrint(UnityStrWas);
686
+ UnityPrintFloat(*ptr_actual);
687
+ #else
688
+ UnityPrint(UnityStrDelta);
689
+ #endif
690
+ UnityAddMsgIfSpecified(msg);
691
+ UNITY_FAIL_AND_BAIL;
692
+ }
693
+ ptr_expected++;
694
+ ptr_actual++;
695
+ }
696
+ }
697
+
698
+ //-----------------------------------------------
699
+ void UnityAssertFloatsWithin(const _UF delta,
700
+ const _UF expected,
701
+ const _UF actual,
702
+ const char* msg,
703
+ const UNITY_LINE_TYPE lineNumber)
704
+ {
705
+ _UF diff = actual - expected;
706
+ _UF pos_delta = delta;
707
+
708
+ UNITY_SKIP_EXECUTION;
709
+
710
+ if (diff < 0.0f)
711
+ {
712
+ diff = 0.0f - diff;
713
+ }
714
+ if (pos_delta < 0.0f)
715
+ {
716
+ pos_delta = 0.0f - pos_delta;
717
+ }
718
+
719
+ //This first part of this condition will catch any NaN or Infinite values
720
+ if ((diff * 0.0f != 0.0f) || (pos_delta < diff))
721
+ {
722
+ UnityTestResultsFailBegin(lineNumber);
723
+ #ifdef UNITY_FLOAT_VERBOSE
724
+ UnityPrint(UnityStrExpected);
725
+ UnityPrintFloat(expected);
726
+ UnityPrint(UnityStrWas);
727
+ UnityPrintFloat(actual);
728
+ #else
729
+ UnityPrint(UnityStrDelta);
730
+ #endif
731
+ UnityAddMsgIfSpecified(msg);
732
+ UNITY_FAIL_AND_BAIL;
733
+ }
734
+ }
735
+
736
+ //-----------------------------------------------
737
+ void UnityAssertFloatSpecial(const _UF actual,
738
+ const char* msg,
739
+ const UNITY_LINE_TYPE lineNumber,
740
+ const UNITY_FLOAT_TRAIT_T style)
741
+ {
742
+ const char* trait_names[] = { UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet };
743
+ _U_SINT should_be_trait = ((_U_SINT)style & 1);
744
+ _U_SINT is_trait = !should_be_trait;
745
+ _U_SINT trait_index = (_U_SINT)(style >> 1);
746
+
747
+ UNITY_SKIP_EXECUTION;
748
+
749
+ switch(style)
750
+ {
751
+ //To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
752
+ //We are using a variable to hold the zero value because some compilers complain about dividing by zero otherwise
753
+ case UNITY_FLOAT_IS_INF:
754
+ case UNITY_FLOAT_IS_NOT_INF:
755
+ is_trait = isinf(actual) & ispos(actual);
756
+ break;
757
+ case UNITY_FLOAT_IS_NEG_INF:
758
+ case UNITY_FLOAT_IS_NOT_NEG_INF:
759
+ is_trait = isinf(actual) & isneg(actual);
760
+ break;
761
+
762
+ //NaN is the only floating point value that does NOT equal itself. Therefore if Actual == Actual, then it is NOT NaN.
763
+ case UNITY_FLOAT_IS_NAN:
764
+ case UNITY_FLOAT_IS_NOT_NAN:
765
+ is_trait = isnan(actual);
766
+ break;
767
+
768
+ //A determinate number is non infinite and not NaN. (therefore the opposite of the two above)
769
+ case UNITY_FLOAT_IS_DET:
770
+ case UNITY_FLOAT_IS_NOT_DET:
771
+ if (isinf(actual) | isnan(actual))
772
+ is_trait = 0;
773
+ else
774
+ is_trait = 1;
775
+ break;
776
+
777
+ default:
778
+ break;
779
+ }
780
+
781
+ if (is_trait != should_be_trait)
782
+ {
783
+ UnityTestResultsFailBegin(lineNumber);
784
+ UnityPrint(UnityStrExpected);
785
+ if (!should_be_trait)
786
+ UnityPrint(UnityStrNot);
787
+ UnityPrint(trait_names[trait_index]);
788
+ UnityPrint(UnityStrWas);
789
+ #ifdef UNITY_FLOAT_VERBOSE
790
+ UnityPrintFloat(actual);
791
+ #else
792
+ if (should_be_trait)
793
+ UnityPrint(UnityStrNot);
794
+ UnityPrint(trait_names[trait_index]);
795
+ #endif
796
+ UnityAddMsgIfSpecified(msg);
797
+ UNITY_FAIL_AND_BAIL;
798
+ }
799
+ }
800
+
801
+ #endif //not UNITY_EXCLUDE_FLOAT
802
+
803
+ //-----------------------------------------------
804
+ #ifndef UNITY_EXCLUDE_DOUBLE
805
+ void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const _UD* expected,
806
+ UNITY_PTR_ATTRIBUTE const _UD* actual,
807
+ const _UU32 num_elements,
808
+ const char* msg,
809
+ const UNITY_LINE_TYPE lineNumber)
810
+ {
811
+ _UU32 elements = num_elements;
812
+ UNITY_PTR_ATTRIBUTE const _UD* ptr_expected = expected;
813
+ UNITY_PTR_ATTRIBUTE const _UD* ptr_actual = actual;
814
+ _UD diff, tol;
815
+
816
+ UNITY_SKIP_EXECUTION;
817
+
818
+ if (elements == 0)
819
+ {
820
+ UnityTestResultsFailBegin(lineNumber);
821
+ UnityPrint(UnityStrPointless);
822
+ UnityAddMsgIfSpecified(msg);
823
+ UNITY_FAIL_AND_BAIL;
824
+ }
825
+
826
+ if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
827
+ return;
828
+
829
+ while (elements--)
830
+ {
831
+ diff = *ptr_expected - *ptr_actual;
832
+ if (diff < 0.0)
833
+ diff = 0.0 - diff;
834
+ tol = UNITY_DOUBLE_PRECISION * *ptr_expected;
835
+ if (tol < 0.0)
836
+ tol = 0.0 - tol;
837
+
838
+ //This first part of this condition will catch any NaN or Infinite values
839
+ if ((diff * 0.0 != 0.0) || (diff > tol))
840
+ {
841
+ UnityTestResultsFailBegin(lineNumber);
842
+ UnityPrint(UnityStrElement);
843
+ UnityPrintNumberUnsigned(num_elements - elements - 1);
844
+ #ifdef UNITY_DOUBLE_VERBOSE
845
+ UnityPrint(UnityStrExpected);
846
+ UnityPrintFloat((float)(*ptr_expected));
847
+ UnityPrint(UnityStrWas);
848
+ UnityPrintFloat((float)(*ptr_actual));
849
+ #else
850
+ UnityPrint(UnityStrDelta);
851
+ #endif
852
+ UnityAddMsgIfSpecified(msg);
853
+ UNITY_FAIL_AND_BAIL;
854
+ }
855
+ ptr_expected++;
856
+ ptr_actual++;
857
+ }
858
+ }
859
+
860
+ //-----------------------------------------------
861
+ void UnityAssertDoublesWithin(const _UD delta,
862
+ const _UD expected,
863
+ const _UD actual,
864
+ const char* msg,
865
+ const UNITY_LINE_TYPE lineNumber)
866
+ {
867
+ _UD diff = actual - expected;
868
+ _UD pos_delta = delta;
869
+
870
+ UNITY_SKIP_EXECUTION;
871
+
872
+ if (diff < 0.0)
873
+ {
874
+ diff = 0.0 - diff;
875
+ }
876
+ if (pos_delta < 0.0)
877
+ {
878
+ pos_delta = 0.0 - pos_delta;
879
+ }
880
+
881
+ //This first part of this condition will catch any NaN or Infinite values
882
+ if ((diff * 0.0 != 0.0) || (pos_delta < diff))
883
+ {
884
+ UnityTestResultsFailBegin(lineNumber);
885
+ #ifdef UNITY_DOUBLE_VERBOSE
886
+ UnityPrint(UnityStrExpected);
887
+ UnityPrintFloat((float)expected);
888
+ UnityPrint(UnityStrWas);
889
+ UnityPrintFloat((float)actual);
890
+ #else
891
+ UnityPrint(UnityStrDelta);
892
+ #endif
893
+ UnityAddMsgIfSpecified(msg);
894
+ UNITY_FAIL_AND_BAIL;
895
+ }
896
+ }
897
+
898
+ //-----------------------------------------------
899
+
900
+ void UnityAssertDoubleSpecial(const _UD actual,
901
+ const char* msg,
902
+ const UNITY_LINE_TYPE lineNumber,
903
+ const UNITY_FLOAT_TRAIT_T style)
904
+ {
905
+ const char* trait_names[] = { UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet };
906
+ _U_SINT should_be_trait = ((_U_SINT)style & 1);
907
+ _U_SINT is_trait = !should_be_trait;
908
+ _U_SINT trait_index = style >> 1;
909
+
910
+ UNITY_SKIP_EXECUTION;
911
+
912
+ switch(style)
913
+ {
914
+ //To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
915
+ //We are using a variable to hold the zero value because some compilers complain about dividing by zero otherwise
916
+ case UNITY_FLOAT_IS_INF:
917
+ case UNITY_FLOAT_IS_NOT_INF:
918
+ is_trait = isinf(actual) & ispos(actual);
919
+ break;
920
+ case UNITY_FLOAT_IS_NEG_INF:
921
+ case UNITY_FLOAT_IS_NOT_NEG_INF:
922
+ is_trait = isinf(actual) & isneg(actual);
923
+ break;
924
+
925
+ //NaN is the only floating point value that does NOT equal itself. Therefore if Actual == Actual, then it is NOT NaN.
926
+ case UNITY_FLOAT_IS_NAN:
927
+ case UNITY_FLOAT_IS_NOT_NAN:
928
+ is_trait = isnan(actual);
929
+ break;
930
+
931
+ //A determinate number is non infinite and not NaN. (therefore the opposite of the two above)
932
+ case UNITY_FLOAT_IS_DET:
933
+ case UNITY_FLOAT_IS_NOT_DET:
934
+ if (isinf(actual) | isnan(actual))
935
+ is_trait = 0;
936
+ else
937
+ is_trait = 1;
938
+ break;
939
+
940
+ default:
941
+ break;
942
+ }
943
+
944
+ if (is_trait != should_be_trait)
945
+ {
946
+ UnityTestResultsFailBegin(lineNumber);
947
+ UnityPrint(UnityStrExpected);
948
+ if (!should_be_trait)
949
+ UnityPrint(UnityStrNot);
950
+ UnityPrint(trait_names[trait_index]);
951
+ UnityPrint(UnityStrWas);
952
+ #ifdef UNITY_DOUBLE_VERBOSE
953
+ UnityPrintFloat(actual);
954
+ #else
955
+ if (should_be_trait)
956
+ UnityPrint(UnityStrNot);
957
+ UnityPrint(trait_names[trait_index]);
958
+ #endif
959
+ UnityAddMsgIfSpecified(msg);
960
+ UNITY_FAIL_AND_BAIL;
961
+ }
962
+ }
963
+
964
+
965
+ #endif // not UNITY_EXCLUDE_DOUBLE
966
+
967
+ //-----------------------------------------------
968
+ void UnityAssertNumbersWithin( const _U_UINT delta,
969
+ const _U_SINT expected,
970
+ const _U_SINT actual,
971
+ const char* msg,
972
+ const UNITY_LINE_TYPE lineNumber,
973
+ const UNITY_DISPLAY_STYLE_T style)
974
+ {
975
+ UNITY_SKIP_EXECUTION;
976
+
977
+ if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
978
+ {
979
+ if (actual > expected)
980
+ Unity.CurrentTestFailed = ((_U_UINT)(actual - expected) > delta);
981
+ else
982
+ Unity.CurrentTestFailed = ((_U_UINT)(expected - actual) > delta);
983
+ }
984
+ else
985
+ {
986
+ if ((_U_UINT)actual > (_U_UINT)expected)
987
+ Unity.CurrentTestFailed = ((_U_UINT)(actual - expected) > delta);
988
+ else
989
+ Unity.CurrentTestFailed = ((_U_UINT)(expected - actual) > delta);
990
+ }
991
+
992
+ if (Unity.CurrentTestFailed)
993
+ {
994
+ UnityTestResultsFailBegin(lineNumber);
995
+ UnityPrint(UnityStrDelta);
996
+ UnityPrintNumberByStyle((_U_SINT)delta, style);
997
+ UnityPrint(UnityStrExpected);
998
+ UnityPrintNumberByStyle(expected, style);
999
+ UnityPrint(UnityStrWas);
1000
+ UnityPrintNumberByStyle(actual, style);
1001
+ UnityAddMsgIfSpecified(msg);
1002
+ UNITY_FAIL_AND_BAIL;
1003
+ }
1004
+ }
1005
+
1006
+ //-----------------------------------------------
1007
+ void UnityAssertEqualString(const char* expected,
1008
+ const char* actual,
1009
+ const char* msg,
1010
+ const UNITY_LINE_TYPE lineNumber)
1011
+ {
1012
+ _UU32 i;
1013
+
1014
+ UNITY_SKIP_EXECUTION;
1015
+
1016
+ // if both pointers not null compare the strings
1017
+ if (expected && actual)
1018
+ {
1019
+ for (i = 0; expected[i] || actual[i]; i++)
1020
+ {
1021
+ if (expected[i] != actual[i])
1022
+ {
1023
+ Unity.CurrentTestFailed = 1;
1024
+ break;
1025
+ }
1026
+ }
1027
+ }
1028
+ else
1029
+ { // handle case of one pointers being null (if both null, test should pass)
1030
+ if (expected != actual)
1031
+ {
1032
+ Unity.CurrentTestFailed = 1;
1033
+ }
1034
+ }
1035
+
1036
+ if (Unity.CurrentTestFailed)
1037
+ {
1038
+ UnityTestResultsFailBegin(lineNumber);
1039
+ UnityPrintExpectedAndActualStrings(expected, actual);
1040
+ UnityAddMsgIfSpecified(msg);
1041
+ UNITY_FAIL_AND_BAIL;
1042
+ }
1043
+ }
1044
+
1045
+ //-----------------------------------------------
1046
+ void UnityAssertEqualStringLen(const char* expected,
1047
+ const char* actual,
1048
+ const _UU32 length,
1049
+ const char* msg,
1050
+ const UNITY_LINE_TYPE lineNumber)
1051
+ {
1052
+ _UU32 i;
1053
+
1054
+ UNITY_SKIP_EXECUTION;
1055
+
1056
+ // if both pointers not null compare the strings
1057
+ if (expected && actual)
1058
+ {
1059
+ for (i = 0; (expected[i] || actual[i]) && i < length; i++)
1060
+ {
1061
+ if (expected[i] != actual[i])
1062
+ {
1063
+ Unity.CurrentTestFailed = 1;
1064
+ break;
1065
+ }
1066
+ }
1067
+ }
1068
+ else
1069
+ { // handle case of one pointers being null (if both null, test should pass)
1070
+ if (expected != actual)
1071
+ {
1072
+ Unity.CurrentTestFailed = 1;
1073
+ }
1074
+ }
1075
+
1076
+ if (Unity.CurrentTestFailed)
1077
+ {
1078
+ UnityTestResultsFailBegin(lineNumber);
1079
+ UnityPrintExpectedAndActualStringsLen(expected, actual, length);
1080
+ UnityAddMsgIfSpecified(msg);
1081
+ UNITY_FAIL_AND_BAIL;
1082
+ }
1083
+ }
1084
+
1085
+
1086
+ //-----------------------------------------------
1087
+ void UnityAssertEqualStringArray( const char** expected,
1088
+ const char** actual,
1089
+ const _UU32 num_elements,
1090
+ const char* msg,
1091
+ const UNITY_LINE_TYPE lineNumber)
1092
+ {
1093
+ _UU32 i, j = 0;
1094
+
1095
+ UNITY_SKIP_EXECUTION;
1096
+
1097
+ // if no elements, it's an error
1098
+ if (num_elements == 0)
1099
+ {
1100
+ UnityTestResultsFailBegin(lineNumber);
1101
+ UnityPrint(UnityStrPointless);
1102
+ UnityAddMsgIfSpecified(msg);
1103
+ UNITY_FAIL_AND_BAIL;
1104
+ }
1105
+
1106
+ if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
1107
+ return;
1108
+
1109
+ do
1110
+ {
1111
+ // if both pointers not null compare the strings
1112
+ if (expected[j] && actual[j])
1113
+ {
1114
+ for (i = 0; expected[j][i] || actual[j][i]; i++)
1115
+ {
1116
+ if (expected[j][i] != actual[j][i])
1117
+ {
1118
+ Unity.CurrentTestFailed = 1;
1119
+ break;
1120
+ }
1121
+ }
1122
+ }
1123
+ else
1124
+ { // handle case of one pointers being null (if both null, test should pass)
1125
+ if (expected[j] != actual[j])
1126
+ {
1127
+ Unity.CurrentTestFailed = 1;
1128
+ }
1129
+ }
1130
+
1131
+ if (Unity.CurrentTestFailed)
1132
+ {
1133
+ UnityTestResultsFailBegin(lineNumber);
1134
+ if (num_elements > 1)
1135
+ {
1136
+ UnityPrint(UnityStrElement);
1137
+ UnityPrintNumberUnsigned(j);
1138
+ }
1139
+ UnityPrintExpectedAndActualStrings((const char*)(expected[j]), (const char*)(actual[j]));
1140
+ UnityAddMsgIfSpecified(msg);
1141
+ UNITY_FAIL_AND_BAIL;
1142
+ }
1143
+ } while (++j < num_elements);
1144
+ }
1145
+
1146
+ //-----------------------------------------------
1147
+ void UnityAssertEqualMemory( UNITY_INTERNAL_PTR expected,
1148
+ UNITY_INTERNAL_PTR actual,
1149
+ const _UU32 length,
1150
+ const _UU32 num_elements,
1151
+ const char* msg,
1152
+ const UNITY_LINE_TYPE lineNumber)
1153
+ {
1154
+ UNITY_PTR_ATTRIBUTE const unsigned char* ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected;
1155
+ UNITY_PTR_ATTRIBUTE const unsigned char* ptr_act = (UNITY_PTR_ATTRIBUTE const unsigned char*)actual;
1156
+ _UU32 elements = num_elements;
1157
+ _UU32 bytes;
1158
+
1159
+ UNITY_SKIP_EXECUTION;
1160
+
1161
+ if ((elements == 0) || (length == 0))
1162
+ {
1163
+ UnityTestResultsFailBegin(lineNumber);
1164
+ UnityPrint(UnityStrPointless);
1165
+ UnityAddMsgIfSpecified(msg);
1166
+ UNITY_FAIL_AND_BAIL;
1167
+ }
1168
+
1169
+ if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
1170
+ return;
1171
+
1172
+ while (elements--)
1173
+ {
1174
+ /////////////////////////////////////
1175
+ bytes = length;
1176
+ while (bytes--)
1177
+ {
1178
+ if (*ptr_exp != *ptr_act)
1179
+ {
1180
+ UnityTestResultsFailBegin(lineNumber);
1181
+ UnityPrint(UnityStrMemory);
1182
+ if (num_elements > 1)
1183
+ {
1184
+ UnityPrint(UnityStrElement);
1185
+ UnityPrintNumberUnsigned(num_elements - elements - 1);
1186
+ }
1187
+ UnityPrint(UnityStrByte);
1188
+ UnityPrintNumberUnsigned(length - bytes - 1);
1189
+ UnityPrint(UnityStrExpected);
1190
+ UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8);
1191
+ UnityPrint(UnityStrWas);
1192
+ UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8);
1193
+ UnityAddMsgIfSpecified(msg);
1194
+ UNITY_FAIL_AND_BAIL;
1195
+ }
1196
+ ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 1);
1197
+ ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 1);
1198
+ }
1199
+ /////////////////////////////////////
1200
+
1201
+ }
1202
+ }
1203
+
1204
+ //-----------------------------------------------
1205
+ // Control Functions
1206
+ //-----------------------------------------------
1207
+
1208
+ void UnityFail(const char* msg, const UNITY_LINE_TYPE line)
1209
+ {
1210
+ UNITY_SKIP_EXECUTION;
1211
+
1212
+ UnityTestResultsBegin(Unity.TestFile, line);
1213
+ UnityPrintFail();
1214
+ if (msg != NULL)
1215
+ {
1216
+ UNITY_OUTPUT_CHAR(':');
1217
+
1218
+ #ifndef UNITY_EXCLUDE_DETAILS
1219
+ if (Unity.CurrentDetail1)
1220
+ {
1221
+ UnityPrint(UnityStrDetail1Name);
1222
+ UnityPrint(Unity.CurrentDetail1);
1223
+ if (Unity.CurrentDetail2)
1224
+ {
1225
+ UnityPrint(UnityStrDetail2Name);
1226
+ UnityPrint(Unity.CurrentDetail2);
1227
+ }
1228
+ UnityPrint(UnityStrSpacer);
1229
+ }
1230
+ #endif
1231
+ if (msg[0] != ' ')
1232
+ {
1233
+ UNITY_OUTPUT_CHAR(' ');
1234
+ }
1235
+ UnityPrint(msg);
1236
+ }
1237
+
1238
+ UNITY_FAIL_AND_BAIL;
1239
+ }
1240
+
1241
+ //-----------------------------------------------
1242
+ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
1243
+ {
1244
+ UNITY_SKIP_EXECUTION;
1245
+
1246
+ UnityTestResultsBegin(Unity.TestFile, line);
1247
+ UnityPrint(UnityStrIgnore);
1248
+ if (msg != NULL)
1249
+ {
1250
+ UNITY_OUTPUT_CHAR(':');
1251
+ UNITY_OUTPUT_CHAR(' ');
1252
+ UnityPrint(msg);
1253
+ }
1254
+ UNITY_IGNORE_AND_BAIL;
1255
+ }
1256
+
1257
+ //-----------------------------------------------
1258
+ #if defined(UNITY_WEAK_ATTRIBUTE)
1259
+ void setUp(void);
1260
+ void tearDown(void);
1261
+ UNITY_WEAK_ATTRIBUTE void setUp(void) { }
1262
+ UNITY_WEAK_ATTRIBUTE void tearDown(void) { }
1263
+ #elif defined(UNITY_WEAK_PRAGMA)
1264
+ # pragma weak setUp
1265
+ void setUp(void) { }
1266
+ # pragma weak tearDown
1267
+ void tearDown(void) { }
1268
+ #else
1269
+ void setUp(void);
1270
+ void tearDown(void);
1271
+ #endif
1272
+ //-----------------------------------------------
1273
+ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)
1274
+ {
1275
+ Unity.CurrentTestName = FuncName;
1276
+ Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum;
1277
+ Unity.NumberOfTests++;
1278
+ UNITY_CLR_DETAILS();
1279
+ if (TEST_PROTECT())
1280
+ {
1281
+ setUp();
1282
+ Func();
1283
+ }
1284
+ if (TEST_PROTECT() && !(Unity.CurrentTestIgnored))
1285
+ {
1286
+ tearDown();
1287
+ }
1288
+ UnityConcludeTest();
1289
+ }
1290
+
1291
+ //-----------------------------------------------
1292
+ void UnityBegin(const char* filename)
1293
+ {
1294
+ Unity.TestFile = filename;
1295
+ Unity.CurrentTestName = NULL;
1296
+ Unity.CurrentTestLineNumber = 0;
1297
+ Unity.NumberOfTests = 0;
1298
+ Unity.TestFailures = 0;
1299
+ Unity.TestIgnores = 0;
1300
+ Unity.CurrentTestFailed = 0;
1301
+ Unity.CurrentTestIgnored = 0;
1302
+
1303
+ UNITY_CLR_DETAILS();
1304
+ UNITY_OUTPUT_START();
1305
+ }
1306
+
1307
+ //-----------------------------------------------
1308
+ int UnityEnd(void)
1309
+ {
1310
+ UNITY_PRINT_EOL();
1311
+ UnityPrint(UnityStrBreaker);
1312
+ UNITY_PRINT_EOL();
1313
+ UnityPrintNumber((_U_SINT)(Unity.NumberOfTests));
1314
+ UnityPrint(UnityStrResultsTests);
1315
+ UnityPrintNumber((_U_SINT)(Unity.TestFailures));
1316
+ UnityPrint(UnityStrResultsFailures);
1317
+ UnityPrintNumber((_U_SINT)(Unity.TestIgnores));
1318
+ UnityPrint(UnityStrResultsIgnored);
1319
+ UNITY_PRINT_EOL();
1320
+ if (Unity.TestFailures == 0U)
1321
+ {
1322
+ UnityPrintOk();
1323
+ }
1324
+ else
1325
+ {
1326
+ UnityPrintFail();
1327
+ }
1328
+ UNITY_PRINT_EOL();
1329
+ UNITY_OUTPUT_COMPLETE();
1330
+ return (int)(Unity.TestFailures);
1331
+ }
1332
+
1333
+ //-----------------------------------------------