zxing/iphone/ZXingWidget/Tests/ISBNResultParserTests.m
gln@google.com c9d8400936 Add email, smtp, and isbn result parsers.
git-svn-id: https://zxing.googlecode.com/svn/trunk@1872 59b500cc-1b3d-0410-9834-0bbf25fbcc57
2011-08-01 21:30:04 +00:00

53 lines
1.6 KiB
Objective-C

//
// ISBNResultParserTests.m
// ZXingWidget
//
// Created by George Nachman on 7/27/11.
// Copyright 2011 ZXing Authors. All rights reserved.
//
#import <SenTestingKit/SenTestingKit.h>
#import <UIKit/UIKit.h>
#import "ISBNResultParser.h"
#import "ISBNParsedResult.h"
@interface ISBNResultParserTests : SenTestCase
@end
@implementation ISBNResultParserTests
- (void)testWellFormedISBNResultParser {
NSString *msg = @"9781234567890";
ISBNParsedResult *result = (ISBNParsedResult *)
[ISBNResultParser parsedResultForString:msg
format:BarcodeFormat_EAN_13];
STAssertTrue([result.value isEqualToString:msg],
@"Wrong value %@", result.value);
}
- (void)testMalformedNumDigitsISBNResultParser {
NSString *msg = @"1234";
ISBNParsedResult *result = (ISBNParsedResult *)
[ISBNResultParser parsedResultForString:msg
format:BarcodeFormat_EAN_13];
STAssertNil(result, @"Bogus message parsed");
}
- (void)testMalformedPrefixISBNResultParser {
NSString *msg = @"9991234567890";
ISBNParsedResult *result = (ISBNParsedResult *)
[ISBNResultParser parsedResultForString:msg
format:BarcodeFormat_EAN_13];
STAssertNil(result, @"Bogus message parsed");
}
- (void)testMalformedISBNResultParser {
NSString *msg = @"I like traffic lights";
ISBNParsedResult *result = (ISBNParsedResult *)
[ISBNResultParser parsedResultForString:msg
format:BarcodeFormat_EAN_13];
STAssertNil(result, @"Bogus message parsed");
}
@end