ThrowTheSwitch / CMock

CMock - Mock/stub generator for C
http://throwtheswitch.org
MIT License
684 stars 276 forks source link

UNITY_TEST_ASSERT_EQUAL_uint8_array is generated instead of UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY #478

Closed JohannesLichtenberger closed 5 months ago

JohannesLichtenberger commented 5 months ago

Hello,

I have a small config file:

---
# General CMock options
:cmock:
  :framework: unity
#  :mock_prefix: mock_
  :includes:
    - "unity.h"
  :plugins:
    - array

  # Treat pointers to arrays as arrays for mocking
  :treat_as:
    int8_t*: :int8_array
    int16_t*: :int16_array
    int32_t*: :int32_array
    uint8_t*: :uint8_array
    uint16_t*: :uint16_array
    uint32_t*: :uint32_array
    char*: :string

# Additional plugin options
:array:
  :length_param: "Length"  # Customize this to match your code convention for array length params

# Verbose output for debugging
:verbosity: 3

# Custom mock path if needed
:mock_path: "mocks"  # Directory where mocks will be generated

However, with the array functions generated it seems that these calls are generated:

UNITY_TEST_ASSERT_EQUAL_uint8_array(cmock_call_instance->Expected_bytes, bytes, cmock_line, CMockStringMismatch);

However, in my Unity it seems to be the right thing would be (with an additional size param and uppercase UINT8_ARRAY):

UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY(cmock_call_instance->Expected_bytes, bytes, size, cmock_line, CMockStringMismatch);

I've changed the calls manually though, and it seems to be OK then :-)

kind regards Johannes

mvandervoord commented 5 months ago

Hi. I believe all you need to do is correct your yaml file and this should fix the issue up.

  # Treat pointers to arrays as arrays for mocking
  :treat_as:
    int8_t*: INT8_ARRAY
    int16_t*: INT16_ARRAY
    int32_t*: INT32_ARRAY
    uint8_t*: UINT8_ARRAY
    uint16_t*: UINT16_ARRAY
    uint32_t*: UINT32_ARRAY
    char*: STRING

The :treat_as needs to tell CMock which handler it is using. There isn't a handler for :int8_array but there is a handler for INT8_ARRAY :)

JohannesLichtenberger commented 5 months ago

Oh, thanks :)