-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from Autoc0diq/fix-nsdata-matcher
Converting NSData to NSString can be nil if arbitrary data.
- Loading branch information
Showing
6 changed files
with
43 additions
and
3 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 |
---|---|---|
|
@@ -4,4 +4,6 @@ | |
|
||
- (BOOL)matches:(NSString *)string; | ||
|
||
- (BOOL)matchesData:(NSData *)data; | ||
|
||
@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
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,30 @@ | ||
#import "Kiwi.h" | ||
#import "LSDataMatcher.h" | ||
|
||
SPEC_BEGIN(LSDataMatcherSpec) | ||
|
||
__block LSDataMatcher *matcher = nil; | ||
__block NSData *data = nil; | ||
|
||
beforeEach(^{ | ||
const char bytes[] = { 0xF1, 0x00, 0xFF }; | ||
data = [NSData dataWithBytes:bytes length:sizeof(bytes)]; | ||
matcher = [[LSDataMatcher alloc] initWithData:data]; | ||
}); | ||
|
||
context(@"when both data are equal", ^{ | ||
it(@"matches", ^{ | ||
[[theValue([matcher matchesData:[data copy]]) should] beYes]; | ||
}); | ||
}); | ||
|
||
context(@"when both data are different", ^{ | ||
it(@"does not match", ^{ | ||
const char other_bytes[] = { 0xA1, 0x00, 0xAF }; | ||
NSData *other_data = [NSData dataWithBytes:other_bytes length:sizeof(other_bytes)]; | ||
|
||
[[theValue([matcher matchesData:other_data]) should] beNo]; | ||
}); | ||
}); | ||
|
||
SPEC_END |