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

Doing a mockup of a function which have a long long (>32 bits) parameter #2

Open
GoogleCodeExporter opened this issue Dec 8, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

Hi !

If you have a function with "long long" parameters/return value, like this
one :
int myFunction(long long id, char *name);

If I try to do a mockup with this function :

int myFunction(long long id, char *name) {
  check_expected(id);
  check_expected(name);
  return *(int *)mock();
}

First, the computer will warn me "warning: cast to pointer from integer of
different size". The line "check_expected(id);" seems to trig the problem.

In fact the macro cast its parameter to a "void *", but a "void *" is a 32
bits wide and the "id" parameter is 64 bits wide.

I can ignore the warning and continue with it, but the checked value will
be truncated, the test will be a success, if I do someting like :

...
expect_value(myFunction, id, 0x34FFFFFFFF);
...
myFunction(0x89FFFFFFFF, "hello");
...

What is your opinion on it ?


Would it be easy to cast the "value" parameter to the biggest type
available on the current host (long long ?) ?
Or will it break something ?


Thanks for your help and for this amazing tool : mockup in c is a really
cool feature !

Original issue reported on code.google.com by meurant....@gmail.com on 7 Oct 2008 at 9:02

@GoogleCodeExporter
Copy link
Author

Issue 1 has been merged into this issue.

Original comment by stewarta...@gmail.com on 10 Apr 2009 at 9:43

@GoogleCodeExporter
Copy link
Author

Original comment by stewarta...@gmail.com on 10 Apr 2009 at 9:43

@GoogleCodeExporter
Copy link
Author

The fix for this will be integrated into cmockery release 0.1.3.

Original comment by stewarta...@gmail.com on 7 Jul 2009 at 7:43

@GoogleCodeExporter
Copy link
Author

Original comment by stewarta...@gmail.com on 7 Jul 2009 at 7:51

  • Changed state: Started

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant