mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-10-05 16:37:25 +00:00
- multi-dimensional arrays now get pointer comparisons (which is better than crashing, right?)
- the pointer size can now be specified (particularly for systems which need 64 bit pointers) - removed a redundant parsing step git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@180 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
@@ -11,10 +11,11 @@ class CMockGeneratorUtils
|
||||
def initialize(config, helpers={})
|
||||
@config = config
|
||||
@ptr_handling = @config.when_ptr
|
||||
@ordered = @config.enforce_strict_ordering
|
||||
@arrays = @config.plugins.include? :array
|
||||
@cexception = @config.plugins.include? :cexception
|
||||
@treat_as = @config.treat_as
|
||||
@ordered = @config.enforce_strict_ordering
|
||||
@arrays = @config.plugins.include? :array
|
||||
@cexception = @config.plugins.include? :cexception
|
||||
@treat_as = @config.treat_as
|
||||
@ptr_compare_assert = "UNITY_TEST_ASSERT_EQUAL_HEX#{@config.ptr_size.to_s}"
|
||||
@helpers = helpers
|
||||
|
||||
if (@arrays)
|
||||
@@ -89,8 +90,8 @@ class CMockGeneratorUtils
|
||||
c_type = arg[:type]
|
||||
arg_name = arg[:name]
|
||||
expected = "cmock_call_instance->Expected_#{arg_name}"
|
||||
unity_func = if ((arg[:ptr?]) and (@ptr_handling == :compare_ptr))
|
||||
["UNITY_TEST_ASSERT_EQUAL_HEX32", '']
|
||||
unity_func = if ((arg[:ptr?]) and ((c_type =~ /\*\*/) or (@ptr_handling == :compare_ptr)))
|
||||
[@ptr_compare_assert, '']
|
||||
else
|
||||
(@helpers.nil? or @helpers[:unity_helper].nil?) ? ["UNITY_TEST_ASSERT_EQUAL",''] : @helpers[:unity_helper].get_helper(c_type)
|
||||
end
|
||||
@@ -155,7 +156,7 @@ class CMockGeneratorUtils
|
||||
when "UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY"
|
||||
[ " if (#{pre}#{expected} == NULL)",
|
||||
" { UNITY_TEST_ASSERT_NULL(#{arg_name}, cmock_line, \"Expected NULL. #{unity_msg}\"); }",
|
||||
((depth_name != 1) ? " else if (#{depth_name} == 0)\n { UNITY_TEST_ASSERT_EQUAL_HEX32(#{pre}#{expected}, #{pre}#{arg_name}, cmock_line, \"#{unity_msg}\"); }" : nil),
|
||||
((depth_name != 1) ? " else if (#{depth_name} == 0)\n { #{@ptr_compare_assert}(#{pre}#{expected}, #{pre}#{arg_name}, cmock_line, \"#{unity_msg}\"); }" : nil),
|
||||
" else",
|
||||
" { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type.sub('*','')}), #{depth_name}, cmock_line, \"#{unity_msg}\"); }\n"].compact.join("\n")
|
||||
when /_ARRAY/
|
||||
@@ -164,7 +165,7 @@ class CMockGeneratorUtils
|
||||
else
|
||||
[ " if (#{pre}#{expected} == NULL)",
|
||||
" { UNITY_TEST_ASSERT_NULL(#{pre}#{arg_name}, cmock_line, \"Expected NULL. #{unity_msg}\"); }",
|
||||
((depth_name != 1) ? " else if (#{depth_name} == 0)\n { UNITY_TEST_ASSERT_EQUAL_HEX32(#{pre}#{expected}, #{pre}#{arg_name}, cmock_line, \"#{unity_msg}\"); }" : nil),
|
||||
((depth_name != 1) ? " else if (#{depth_name} == 0)\n { #{@ptr_compare_assert}(#{pre}#{expected}, #{pre}#{arg_name}, cmock_line, \"#{unity_msg}\"); }" : nil),
|
||||
" else",
|
||||
" { #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, #{depth_name}, cmock_line, \"#{unity_msg}\"); }\n"].compact.join("\n")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user