Reputation: 55152
In one of my Unit tests I need to declare a [String:AnyObject]
which contains sometimes big (>32 bits) Integer values.
[
["timestamp": 1460793600000,"expectedState": "close"],
["timestamp": 1460822400000,"expectedState": "open"]
]
Writing the integers as literals triggers the following error :
Integer literal overflows when stored into 'Int' error
I know I could write it with NSNumbers
[
["timestamp": NSNumber(longLong:1460793600000),"expectedState": "close"],
["timestamp": NSNumber(longLong:1460822400000),"expectedState": "open"]
]
But that doesn't match the data I'm expecting (It's a JSON
array stored in a Transformatable Core Data property).
The purpose of my test is to ensure that I'm handling correctly 64 bits values on a 32bits device.
Upvotes: 1
Views: 63
Reputation: 55152
Actually, I feel a bit dumb on this.
The numbers returned by my NSManagedObject
's array are of type __NSCFNumber
so they are a NSNumber.
Yet, I'm still figuring out how I could write a test to ensure It handles 64 bits values without having to running the unit test on a 32bits device.
Upvotes: 0