Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/CMock_Summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,10 @@ from the defaults. We've tried to specify what the defaults are below.

GoBananas_ExpectWithArray(b, 2, 2);

`:array_as_byte`:
When checking arrays, the element size will always be 1, ie depth is the number
of bytes to check.

* `:fail_on_unexpected_calls`:
By default, CMock will fail a test if a mock is called without `_Expect` and `_Ignore`
called first. While this forces test writers to be more explicit in their expectations,
Expand Down
1 change: 1 addition & 0 deletions lib/cmock_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class CMockConfig
:orig_header_include_fmt => '#include "%s"',
:array_size_type => [],
:array_size_name => 'size|len',
:array_as_byte => false,
:skeleton => false,
:exclude_setjmp_h => false,

Expand Down
7 changes: 6 additions & 1 deletion lib/cmock_generator_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def initialize(config, helpers = {})
@ignore_stateless = @config.plugins.include? :ignore_stateless
@treat_as = @config.treat_as
@helpers = helpers
@array_as_byte = @config.array_as_byte
end

def self.arg_type_with_const(arg)
Expand Down Expand Up @@ -230,7 +231,11 @@ def code_verify_an_arg_expectation_with_smart_arrays(function, arg)
lines << " { UNITY_TEST_ASSERT_NULL(#{arg_name}, cmock_line, CMockStringExpNULL); }\n"
lines << (depth_name != 1 ? " else if (#{depth_name} == 0)\n { UNITY_TEST_ASSERT_EQUAL_PTR(#{pre}#{expected}, #{pre}#{arg_name}, cmock_line, CMockStringMismatch); }\n" : '')
lines << " else\n"
lines << " { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type.sub('*', '')}), #{depth_name}, cmock_line, CMockStringMismatch); }\n"
if @array_as_byte
lines << " { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), 1, #{depth_name}, cmock_line, CMockStringMismatch); }\n"
else
lines << " { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type.sub('*', '')}), #{depth_name}, cmock_line, CMockStringMismatch); }\n"
end
end
when /_ARRAY/
if pre == '&'
Expand Down
Loading