mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
add test
This commit is contained in:
parent
05184a7e1a
commit
910f086e26
2 changed files with 26 additions and 1 deletions
|
@ -4,6 +4,8 @@
|
||||||
makes sure that unsigned integer types are written as such,
|
makes sure that unsigned integer types are written as such,
|
||||||
avoiding a potential overflow.
|
avoiding a potential overflow.
|
||||||
|
|
||||||
|
* Tests/base/NSJSONSerialization/tests00.m: Test case for above.
|
||||||
|
|
||||||
2017-11-16 Richard Frith-Macdonald <rfm@gnu.org>
|
2017-11-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSArray.m: Fix for bug reported on github by zneak.
|
* Source/NSArray.m: Fix for bug reported on github by zneak.
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
#import "ObjectTesting.h"
|
#import "ObjectTesting.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -322,6 +323,28 @@ static NSString *percentQuoted(NSString *s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)longLongOverflow
|
||||||
|
{
|
||||||
|
NSNumber *big = [NSNumber numberWithUnsignedLongLong: 0xffffffffffffffff];
|
||||||
|
NSNumber *small = [NSNumber numberWithLongLong: 0xffffffffffffffff];
|
||||||
|
|
||||||
|
NSData *data = [NSJSONSerialization dataWithJSONObject: big
|
||||||
|
options: 0
|
||||||
|
error: NULL];
|
||||||
|
NSString *string = [[NSString alloc] initWithData: data
|
||||||
|
encoding: NSUTF8StringEncoding];
|
||||||
|
NSAssert([string isEqualToString:@"18446744073709551615"], @"unsigned long long");
|
||||||
|
[string release];
|
||||||
|
|
||||||
|
data = [NSJSONSerialization dataWithJSONObject: small
|
||||||
|
options: 0
|
||||||
|
error: NULL];
|
||||||
|
string = [[NSString alloc] initWithData: data
|
||||||
|
encoding: NSUTF8StringEncoding];
|
||||||
|
NSAssert([string isEqualToString:@"-1"], @"signed long long");
|
||||||
|
[string release];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@ -338,7 +361,7 @@ int main(int argc, char *argv[])
|
||||||
PASS([gtb performTest: @"cr1524466"], "cr1524466");
|
PASS([gtb performTest: @"cr1524466"], "cr1524466");
|
||||||
PASS([gtb performTest: @"cr2096767"], "cr2096767");
|
PASS([gtb performTest: @"cr2096767"], "cr2096767");
|
||||||
PASS([gtb performTest: @"cr2549370"], "cr2549370");
|
PASS([gtb performTest: @"cr2549370"], "cr2549370");
|
||||||
|
PASS([gtb performTest: @"longLongOverflow"], "longLongOverflow");
|
||||||
[gtb release];
|
[gtb release];
|
||||||
|
|
||||||
[pool release];
|
[pool release];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue