|
31 | 31 | #import "FileBasedTestCase.h"
|
32 | 32 | #import "SentryCrashJSONCodec.h"
|
33 | 33 | #import "SentryCrashJSONCodecObjC.h"
|
| 34 | +#import "SentryInvalidJSONString.h" |
34 | 35 |
|
35 | 36 | @interface SentryCrashJSONCodec_Tests : FileBasedTestCase
|
36 | 37 | @end
|
@@ -196,6 +197,39 @@ - (void)testSerializeDeserializeArrayString
|
196 | 197 | XCTAssertEqualObjects(result, original, @"");
|
197 | 198 | }
|
198 | 199 |
|
| 200 | +- (void)testSerializeJapaneseArrayString |
| 201 | +{ |
| 202 | + NSError *error = (NSError *)self; |
| 203 | + NSString *expected = @"[\"こんにちは\"]"; // "Hello" in Japanese |
| 204 | + id original = [NSArray arrayWithObjects:@"こんにちは", nil]; |
| 205 | + NSString *jsonString = toString([SentryCrashJSONCodec encode:original |
| 206 | + options:SentryCrashJSONEncodeOptionSorted |
| 207 | + error:&error]); |
| 208 | + XCTAssertNotNil(jsonString, @""); |
| 209 | + XCTAssertNil(error, @""); |
| 210 | + XCTAssertEqualObjects(jsonString, expected, @""); |
| 211 | + id result = [SentryCrashJSONCodec decode:toData(jsonString) options:0 error:&error]; |
| 212 | + XCTAssertNotNil(result, @""); |
| 213 | + XCTAssertNil(error, @""); |
| 214 | + XCTAssertEqualObjects(result, original, @""); |
| 215 | +} |
| 216 | + |
| 217 | +- (void)testSerializeInvalidJSONString |
| 218 | +{ |
| 219 | + |
| 220 | + NSString *string = [[SentryInvalidJSONString alloc] initWithLengthInvocationsToBeInvalid:0]; |
| 221 | + NSError *error = (NSError *)self; |
| 222 | + |
| 223 | + id original = [NSArray arrayWithObjects:string, nil]; |
| 224 | + NSString *jsonString = toString([SentryCrashJSONCodec encode:original |
| 225 | + options:SentryCrashJSONEncodeOptionSorted |
| 226 | + error:&error]); |
| 227 | + |
| 228 | + XCTAssertNil(error); |
| 229 | + XCTAssertEqualObjects(jsonString, @"[null]", @""); |
| 230 | + XCTAssertNotNil(jsonString, @""); |
| 231 | +} |
| 232 | + |
199 | 233 | - (void)testSerializeDeserializeArrayStringIntl
|
200 | 234 | {
|
201 | 235 | NSError *error = (NSError *)self;
|
|
0 commit comments