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

Add a workaround to compare C++ types in mocked method #97

Closed
wants to merge 1 commit into from

Conversation

sdefresne
Copy link
Contributor

The description of types returned by @encode(typeof(expr)) and
-[[NSInvocation methodSignature] methodReturnType] are not equals
for C++ objects when building with libc++.

The depth of the recursive expansion of the fields are not the same
and the strings don't compare as equal. So when comparing the types
descriptions in that configuration skip over all the field expansion
since we only care if the types are the same.

BUG=#96

The description of types returned by @encode(__typeof__(expr)) and
-[[NSInvocation methodSignature] methodReturnType] are not equals
for C++ objects when building with libc++.

The depth of the recursive expansion of the fields are not the same
and the strings don't compare as equal. So when comparing the types
descriptions in that configuration skip over all the field expansion
since we only care if the types are the same.
@erikdoe
Copy link
Owner

erikdoe commented Jul 6, 2014

Interesting case. My concern about this pull request is that it contains a fair bit of complicated code without any tests. (I guess this is because the problem can't be created in the context of the normal OCMock unit test suite.) In addition, it is introducing all that complexity for a use case that can arguably be considered very uncommon.

Would it be possible to make a change in OCMock that allows you guys to add a special class or handler into your test suite that modifies the OCMock behaviour so that it works for this scenario?

@carllindberg
Copy link
Contributor

I added an updated version of the NSNumber type PR which also solves this problem (#115), by using a different (regular C) implementation which is shorter and avoids usage of C++ (since it's not a C++ specific issue). It can happen when a method return type knows a full structure type, but outside API only knows opaque pointer types, I think. We might also solve the issue by allowing any two pointer types to be OK, regardless of what they point to, even if that is encoded in the type.

@erikdoe
Copy link
Owner

erikdoe commented Jul 22, 2014

I have now merged #115 into master. Could you verify whether this fixes your problem?

@erikdoe
Copy link
Owner

erikdoe commented Nov 5, 2014

Assumed fixed by #115.

@erikdoe erikdoe closed this Nov 5, 2014
@sdefresne
Copy link
Contributor Author

Sorry for never replying. Yes #115 fixed the issue, thank you. However when testing it today I found another issue with #115 and I'll send a pull request to fix it.

@sdefresne
Copy link
Contributor Author

See #180

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

Successfully merging this pull request may close these issues.

3 participants