Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array of constant pointers as an argument of mock function #450

Open
slavko-m opened this issue Jul 22, 2023 · 2 comments
Open

Array of constant pointers as an argument of mock function #450

slavko-m opened this issue Jul 22, 2023 · 2 comments
Labels
bug_parser Bug -- specifically one that requires better parser bug

Comments

@slavko-m
Copy link

Hi,

I am trying to mock a function from OpenVX:

vx_image vxCreateImageFromHandle(vx_context context, vx_df_image color, const vx_imagepatch_addressing_t addrs[], void *const ptrs[], vx_enum memory_type);

The problem is when the mock is generated, there is a weird function called UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY_ARRAY generated (which doesn't exist in Unity), because of void *const ptrs[] argument:

  if (!cmock_call_instance->IgnoreArg_ptrs)
  {
    UNITY_SET_DETAILS(CMockString_vxCreateImageFromHandle,CMockString_ptrs);
    if (cmock_call_instance->Expected_ptrs == NULL)
      { UNITY_TEST_ASSERT_NULL(ptrs, cmock_line, CMockStringExpNULL); }
    else
      { UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY_ARRAY(cmock_call_instance->Expected_ptrs, ptrs, cmock_call_instance->Expected_ptrs_Depth, cmock_line, CMockStringMismatch); }
  }

Anyone knows why is this happening, and if there is a solution for this?

@mvandervoord
Copy link
Member

It's happening because it's a bug. ;)

It's processing the brackets and the pointer separately, and using each to specify that you're talking to an array... so it's decided it's and array of array (correctly) but (incorrectly) not collapsed it down to a single pointer as it does other things.

The handling for arrays and pointers should be getting major improvements soon. this is one of the things to be addressed.

Sorry for the headaches. :(

@slavko-m
Copy link
Author

Thanks for the answer! For now, I will use workaround by using :unity_helper_path: where I defined

#define UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY_ARRAY UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY

to avoid build issues.

@mvandervoord mvandervoord added bug bug_parser Bug -- specifically one that requires better parser labels Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug_parser Bug -- specifically one that requires better parser bug
Projects
None yet
Development

No branches or pull requests

2 participants