diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 0845019dddcb34a88d8a99de6a82181ea1cf7a93..3d8e6ae71747c2479f61cebb8bd1d7130a5e836f 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -25,7 +25,6 @@ class UnityTestRunnerGenerator yaml_guts = YAML.load_file(config_file) yaml_goodness = yaml_guts[:unity] ? yaml_guts[:unity] : yaml_guts[:cmock] options[:cexception] = 1 unless (yaml_goodness[:plugins] & ['cexception', :cexception]).empty? - options[:coverage ] = 1 if (yaml_goodness[:coverage]) options[:order] = 1 if (yaml_goodness[:enforce_strict_ordering]) options[:framework] = (yaml_goodness[:framework] || :unity) options[:includes] << (yaml_goodness[:includes]) @@ -126,7 +125,6 @@ class UnityTestRunnerGenerator output.puts('#include ') output.puts('#include ') output.puts('#include "CException.h"') if @options[:cexception] - output.puts('#include "BullseyeCoverage.h"') if @options[:coverage] mocks.each do |mock| output.puts("#include \"#{mock.gsub('.h','')}.h\"") end @@ -230,9 +228,7 @@ class UnityTestRunnerGenerator end output.puts() - output.puts(" UnityEnd();") - output.puts(" cov_write();") if @options[:coverage] - output.puts(" return 0;") + output.puts(" return UnityEnd();") output.puts("}") end end @@ -242,7 +238,6 @@ if ($0 == __FILE__) usage = ["usage: ruby #{__FILE__} (yaml) (options) input_test_file output_test_runner (includes)", " blah.yml - will use config options in the yml file (see CMock docs)", " -cexception - include cexception support", - " -coverage - include bullseye coverage support", " -order - include cmock order-enforcement support" ] options = { :includes => [] } diff --git a/docs/Unity Summary.txt b/docs/Unity Summary.txt index b1bb79ff48d3d738f78a672b00303c3db75db0e8..5384b6ebade24ba268c7e3747752d34db934c9e9 100644 --- a/docs/Unity Summary.txt +++ b/docs/Unity Summary.txt @@ -90,85 +90,51 @@ This test is automatically marked as a failure. The message is output stating w Numerical Assertions: Integers ------------------------------ -TEST_ASSERT_EQUAL(expected, actual) - -Another way of calling TEST_ASSERT_EQUAL_INT - TEST_ASSERT_EQUAL_INT(expected, actual) +TEST_ASSERT_EQUAL_INT8(expected, actual) +TEST_ASSERT_EQUAL_INT16(expected, actual) +TEST_ASSERT_EQUAL_INT32(expected, actual) +TEST_ASSERT_EQUAL_INT64(expected, actual) -Compare two integers for equality and display errors as signed integers. - -TEST_ASSERT_EQUAL_UINT(expected, actual) - -Compare two integers for equality and display errors as unsigned integers. - -TEST_ASSERT_EQUAL_HEX8(expected, actual) - -Compare two integers for equality and display errors as an 8-bit hex value - -TEST_ASSERT_EQUAL_HEX16(expected, actual) - -Compare two integers for equality and display errors as an 16-bit hex value - -TEST_ASSERT_EQUAL_HEX32(expected, actual) - -Compare two integers for equality and display errors as an 32-bit hex value - -TEST_ASSERT_EQUAL_HEX(expected, actual) - -Another way of calling TEST_ASSERT_EQUAL_HEX32 - -TEST_ASSERT_INT_WITHIN(delta, expected, actual) - -Asserts that the actual value is within plus or minus delta of the expected value. +Compare two integers for equality and display errors as signed integers. A cast will be performed +to your natural integer size so often this can just be used. When you need to specify the exact size, +like when comparing arrays, you can use a specific version: -TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) -Another way of calling TEST_ASSERT_EQUAL_INT_MESSAGE -TEST_ASSERT_EQUAL_INT_MESSAGE(expected, actual, message) - -Compare two integers for equality and display errors as signed integers. Outputs a custom message on failure. +TEST_ASSERT_EQUAL_UINT(expected, actual) -TEST_ASSERT_EQUAL_UINT_MESSAGE(expected, actual, message) +Compare two integers for equality and display errors as unsigned integers. Like INT, there are +variants for different sizes also. -Compare two integers for equality and display errors as unsigned integers. Outputs a custom message on failure. -TEST_ASSERT_EQUAL_HEX8_MESSAGE(expected, actual, message) - -Compare two integers for equality and display errors as an 8-bit hex value. Outputs a custom message on failure. -TEST_ASSERT_EQUAL_HEX16_MESSAGE(expected, actual, message) - -Compare two integers for equality and display errors as an 16-bit hex value. Outputs a custom message on failure. +TEST_ASSERT_EQUAL_HEX(expected, actual) -TEST_ASSERT_EQUAL_HEX32_MESSAGE(expected, actual, message) +Compares two integers for equality and display errors as hexadecimal. Like the other integer comparisons, +you can specify the size... here the size will also effect how many nibbles are shown (for example, HEX16 +will show 4 nibbles). -Compare two integers for equality and display errors as an 32-bit hex value. Outputs a custom message on failure. +_ARRAY -TEST_ASSERT_EQUAL_HEX_MESSAGE(expected, actual, message) - -Another way of calling TEST_ASSERT_EQUAL_HEX32_MESSAGE +You can append _ARRAY to any of these macros to make an array comparison of that type. Here you will +need to care a bit more about the actual size of the value being checked. You will also specify an +additional argument which is the number of elements to compare. For example: ------------------------------------- -Numerical Assertions: Integer Arrays ------------------------------------- +TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, elements) -TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements) -Compare two arrays for equality and display errors as signed integers. +TEST_ASSERT_EQUAL(expected, actual) -TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements) +Another way of calling TEST_ASSERT_EQUAL_INT -Compare two arrays for equality and display errors as unsigned integers. -TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements) -Compare two arrays for equality and display errors as 32-bit hex values. +TEST_ASSERT_INT_WITHIN(delta, expected, actual) -TEST_ASSERT_EQUAL_HEX_ARRAY(expected, actual, num_elements) +Asserts that the actual value is within plus or minus delta of the expected value. This also comes in +size specific variants. -Another way of calling TEST_ASSERT_EQUAL_HEX32_ARRAY. ----------------------------- Numerical Assertions: Bitwise @@ -202,6 +168,10 @@ TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) Asserts that the actual value is within plus or minus delta of the expected value. +TEST_ASSERT_EQUAL_FLOAT(expected, actual) + +Asserts that two floating point values are "equal" within a small % delta of the expected value. + ----------------- String Assertions ----------------- @@ -228,3 +198,24 @@ TEST_ASSERT_NOT_NULL(pointer) Fails if the pointer is equal to NULL + +----------------- +Memory Assertions +----------------- + +TEST_ASSERT_EQUAL_MEMORY(expected, actual, len) + +Compare two blocks of memory. This is a good generic assertion for types that can't be coerced into acting like +standard types... but since it's a memory compare, you have to be careful that your data types are packed. + +-------- +_MESSAGE +-------- + +you can append _MESSAGE to any of the macros to make them take an additional argument. This argument +is a string that will be printed at the end of the failure strings. This is useful for specifying more +information about the problem. + + + + diff --git a/examples/rakefile_helper.rb b/examples/rakefile_helper.rb index d90808702c1fdbe39913da20b906443204a9c7d7..4d2fb299ae516ba6db883901bc44edc03162219c 100644 --- a/examples/rakefile_helper.rb +++ b/examples/rakefile_helper.rb @@ -139,11 +139,11 @@ module RakefileHelpers return {:command => command, :pre_support => pre_support, :post_support => post_support} end - def execute(command_string, verbose=true) + def execute(command_string, verbose=true, raise_on_fail=true) report command_string output = `#{command_string}`.chomp report(output) if (verbose && !output.nil? && (output.length > 0)) - if $?.exitstatus != 0 + if (($?.exitstatus != 0) and (raise_on_fail)) raise "Command failed. (Returned #{$?.exitstatus})" end return output @@ -215,7 +215,7 @@ module RakefileHelpers else cmd_str = "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}" end - output = execute(cmd_str) + output = execute(cmd_str, true, false) test_results = $cfg['compiler']['build_path'] + test_base if output.match(/OK$/m).nil? test_results += '.testfail' diff --git a/src/unity.c b/src/unity.c index 6645cb90284eaa493397183a0dff08c589afcc99..9d8d29d8a26e462402ad8abfcecd17fbdd112ba2 100644 --- a/src/unity.c +++ b/src/unity.c @@ -34,7 +34,7 @@ const char* UnityStrNullPointerForActual = " Actual pointer was NULL"; void UnityPrint(const char* string) { - unsigned char* pch = (unsigned char*)string; + const char* pch = string; if (pch != NULL) { @@ -796,7 +796,7 @@ void UnityBegin(void) } //----------------------------------------------- -void UnityEnd(void) +int UnityEnd(void) { UnityPrint("-----------------------"); UNITY_PRINT_CR_LF; @@ -816,4 +816,5 @@ void UnityEnd(void) UnityPrint("FAIL"); } UNITY_PRINT_CR_LF; + return Unity.TestFailures; } diff --git a/src/unity_internals.h b/src/unity_internals.h index 0639b82c5093e95d725b3a59857a93d9d6008bd0..07fbbaa7712daf7c6568896102ca746f6e5ef1ff 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -187,7 +187,7 @@ extern struct _Unity Unity; //------------------------------------------------------- void UnityBegin(void); -void UnityEnd(void); +int UnityEnd(void); void UnityConcludeTest(void); //-------------------------------------------------------