-
Notifications
You must be signed in to change notification settings - Fork 32
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
Explicit convert UINT64_MAX to unsigned #217
Conversation
…64_MAX to unsigned with @() after we upgraded MACOSX_DEVELOPMENT_TARGET to 12 from 10.14. A test is falied because of it. Fix it by explict cast.
Tests/ObjCTests.mm
Outdated
@@ -62,7 +62,10 @@ static void checkIt(id obj, const char* json) { | |||
checkIt(@123456789, "123456789"); | |||
checkIt(@123456789012, "123456789012"); | |||
checkIt(@(INT64_MAX), "9223372036854775807"); | |||
checkIt(@(UINT64_MAX), "18446744073709551615"); | |||
// checkIt(@(UINT64_MAX), "18446744073709551615"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay. I was waving between whether to remove it.
checkIt(@(UINT64_MAX), "18446744073709551615"); | ||
// It was found that @() may not turn UINT64_MAX to unsigned. In the following, | ||
// we apply an explicit conversion | ||
checkIt(@([@UINT64_MAX unsignedLongLongValue]), "18446744073709551615"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessarily convoluted. You create an NSNumber, turn it back into a native number, then create another NSNumber from that.
It would be much simpler to write [NSNumber numberWithUnsignedLongLong: UINT64_MAX]
.
Or else @((unsigned long long)UINT64_MAX)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the advice. This is test code and won't be in the product. I will change when ported the the master branch.
In Jenkins' build machine (MacOS), we found it failed to convert UINT64_MAX to unsigned with @() after we upgraded MACOSX_DEVELOPMENT_TARGET to 12 from 10.14.
A test is falied because of it. Fix it by explicit cast.