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