提交 f5ce02f1 编写于 作者: M mvandervoord

- removed pointless cast from UnityPrint

- test executable returns number of failures as exit status
- caught up lame text docs

git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@90 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
上级 7ff6761f
......@@ -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 <setjmp.h>')
output.puts('#include <stdio.h>')
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 => [] }
......
......@@ -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.
......@@ -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'
......
......@@ -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;
}
......@@ -187,7 +187,7 @@ extern struct _Unity Unity;
//-------------------------------------------------------
void UnityBegin(void);
void UnityEnd(void);
int UnityEnd(void);
void UnityConcludeTest(void);
//-------------------------------------------------------
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册