erikdoe/ocmock — pull request #115 by carllindberg (2014-07-12 14:22:27+00:00)
Title: Support for converting between NSNumber types for boxed return values, and opaque pointers

Implement support for converting between NSNumber/NSValue types, but raise if the conversion is lossy (values out of range, non-whole-number float values to integers, etc.).

Solves a number of problems with different BOOL types ('c' vs 'B') and method signature vs NSValue types which can differ a little in different architectures.

This is using the approach I outlined in the comments to #58 but with a couple of additional range checks which Apple seems to intentionally allow for back-compatibility reasons. This is an update for #89 which incorporates code recently added to master.

I also implemented support for comparing objcType strings where one side has an opaque pointer type, and the other side has the full type information. This is an alternate fix for #97, though it can definitely happen in non-C++ situations as well. I included some test cases for it. It's more code than I'd like for a relatively rare situation, but it is shorter than the other PR and does not involve any C++ code. Perhaps though it could be changed to simply compare any two pointer types as OK, since that would be enough to ensure runtime size, and pointers are compared with direct equality usually. That would be a much easier test to write.