Skip to content

Commit

Permalink
Adding streaming document test.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel committed Jul 23, 2009
1 parent c3e6a47 commit b82663e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions Tests/Samples/stream_array1.json
@@ -0,0 +1 @@
[1, 2, 3
1 change: 1 addition & 0 deletions Tests/Samples/stream_array2.json
@@ -0,0 +1 @@
, 4, 5, 6]
19 changes: 19 additions & 0 deletions Tests/YAJLDocumentTest.m
Expand Up @@ -23,6 +23,25 @@ - (void)test {
[document release];
}

- (void)testStreaming {
YAJLDocument *document = [[YAJLDocument alloc] initWithParserOptions:0];

NSError *error = nil;
NSData *data1 = [self loadData:@"stream_array1"];
YAJLParserStatus status1 = [document parse:data1 error:&error];
GHAssertTrue(status1 == YAJLParserStatusInsufficientData, nil);
if (error) GHFail(@"Error: %@", error);
GHTestLog(@"First part: %@", document.root);

NSData *data2 = [self loadData:@"stream_array2"];
YAJLParserStatus status2 = [document parse:data2 error:&error];
GHAssertTrue(status2 == YAJLParserStatusOK, nil);
if (error) GHFail(@"Error: %@", error);

GHTestLog(@"Root: %@", document.root);
[document release];
}

// This sample.json is too insane; Will need to revisit
- (void)_testEqualToSBJSON {

Expand Down

0 comments on commit b82663e

Please sign in to comment.