-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrii Mamchur
committed
Jul 12, 2013
1 parent
6d7c2fe
commit 37dc49b
Showing
6 changed files
with
177 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// JsonLiteObjCStream.h | ||
// JsonLiteObjC | ||
// | ||
// Created by admin on 7/12/13. | ||
// Copyright (c) 2013 Andrii Mamchur. All rights reserved. | ||
// | ||
|
||
#import <SenTestingKit/SenTestingKit.h> | ||
|
||
@interface JsonLiteObjCStream : SenTestCase | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// | ||
// JsonLiteObjCStream.m | ||
// JsonLiteObjC | ||
// | ||
// Created by admin on 7/12/13. | ||
// Copyright (c) 2013 Andrii Mamchur. All rights reserved. | ||
// | ||
|
||
#import "JsonLiteObjCStream.h" | ||
#import "JsonLiteSenTestCaseExt.h" | ||
#import "JsonLiteParser.h" | ||
#import "JsonLiteAccumulator.h" | ||
#import "JsonLiteSerializer.h" | ||
|
||
@interface JsonLiteObjCStream()<JsonLiteParserDelegate> { | ||
volatile BOOL finished; | ||
} | ||
|
||
@end | ||
|
||
@implementation JsonLiteObjCStream | ||
|
||
- (void)parserDidStartObject:(JsonLiteParser *)parser { | ||
} | ||
|
||
- (void)parserDidEndObject:(JsonLiteParser *)parser { | ||
} | ||
|
||
- (void)parserDidStartArray:(JsonLiteParser *)parser { | ||
} | ||
|
||
- (void)parserDidEndArray:(JsonLiteParser *)parser { | ||
} | ||
|
||
- (void)parser:(JsonLiteParser *)parser foundKeyToken:(JsonLiteStringToken *)token { | ||
} | ||
|
||
- (void)parser:(JsonLiteParser *)parser foundStringToken:(JsonLiteStringToken *)token { | ||
} | ||
|
||
- (void)parser:(JsonLiteParser *)parser foundNumberToken:(JsonLiteNumberToken *)token { | ||
} | ||
|
||
- (void)parserFoundTrueToken:(JsonLiteParser *)parser { | ||
} | ||
|
||
- (void)parserFoundFalseToken:(JsonLiteParser *)parser { | ||
} | ||
|
||
- (void)parserFoundNullToken:(JsonLiteParser *)parser { | ||
} | ||
|
||
- (void)parser:(JsonLiteParser *)parser didFinishParsingWithError:(NSError *)error { | ||
finished = [error code] != JsonLiteCodeEndOfStream; | ||
} | ||
|
||
- (void)testStream { | ||
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"random" | ||
ofType:@"json" | ||
inDirectory:@"success"]; | ||
NSInputStream *stream = [NSInputStream inputStreamWithFileAtPath:path]; | ||
JsonLiteParser *parser = [JsonLiteParser parser]; | ||
parser.delegate = self; | ||
NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; | ||
[parser parse:stream inRunLoop:runLoop]; | ||
|
||
finished = NO; | ||
while (!finished) { | ||
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:1]; | ||
[runLoop runMode:NSDefaultRunLoopMode beforeDate:date]; | ||
} | ||
|
||
STAssertNil(parser.parseError, @"Error occurs %@", parser.parseError); | ||
} | ||
|
||
- (void)testInputs { | ||
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"random" | ||
ofType:@"json" | ||
inDirectory:@"success"]; | ||
NSInputStream *stream = [NSInputStream inputStreamWithFileAtPath:path]; | ||
JsonLiteParser *parser = [JsonLiteParser parser]; | ||
[parser parse:nil inRunLoop:nil]; | ||
STAssertTrue([parser.parseError code] == JsonLiteCodeInvalidArgument, @"Incorrect error"); | ||
|
||
[parser parse:stream inRunLoop:nil]; | ||
STAssertTrue([parser.parseError code] == JsonLiteCodeInvalidArgument, @"Incorrect error"); | ||
|
||
[parser parse:nil inRunLoop:[NSRunLoop currentRunLoop]]; | ||
STAssertTrue([parser.parseError code] == JsonLiteCodeInvalidArgument, @"Incorrect error"); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters