Sha256: d78259545ec16dd7185b8bd343eb2700ceadb4210a01d237199d7d4b76628464

Contents?: true

Size: 1.92 KB

Versions: 226

Compression:

Stored size: 1.92 KB

Contents

#import <XCTest/XCTest.h>

#if __has_include("LuhnExample.h")
# import "LuhnExample.h"
# else
# import "Luhn.h"
#endif

@interface LuhnTest : XCTestCase

@end

@implementation LuhnTest

- (void)testSingleDigitStringNotValid {
    Luhn *luhn = [[Luhn alloc] initWithString:@"1"];
    XCTAssertFalse(luhn.isValid);
}

- (void)testSingleZeroInvalid {
    Luhn *luhn = [[Luhn alloc] initWithString:@"0"];
    XCTAssertFalse(luhn.isValid);
}

- (void)testSimpleValidSINRemainsValidIfReversed {
    Luhn *luhn = [[Luhn alloc] initWithString:@"059"];
    XCTAssertTrue(luhn.isValid);
}

- (void)testSimpleValidSINInvalidIfReversed {
    Luhn *luhn = [[Luhn alloc] initWithString:@"59"];
    XCTAssertTrue(luhn.isValid);
}

- (void)testValidCanadianSIN {
    Luhn *luhn = [[Luhn alloc] initWithString:@"055 444 285"];
    XCTAssertTrue(luhn.isValid);
}

- (void)testInvalidCanadianSIN {
    Luhn *luhn = [[Luhn alloc] initWithString:@"055 444 286"];
    XCTAssertFalse(luhn.isValid);
}

- (void)testInvalidCreditCard {
    Luhn *luhn = [[Luhn alloc] initWithString:@"8273 1232 7352 0569"];
    XCTAssertFalse(luhn.isValid);
}

- (void)testValidStringsWithANonDigitInvalid {
    Luhn *luhn = [[Luhn alloc] initWithString:@"055a 444 285"];
    XCTAssertFalse(luhn.isValid);
}

- (void)testValidStringsWithPunctuationInvalid {
    Luhn *luhn = [[Luhn alloc] initWithString:@"055-444-285"];
    XCTAssertFalse(luhn.isValid);
}

- (void)testValidStringWithSymbolsInvalid {
    Luhn *luhn = [[Luhn alloc] initWithString:@"055£ 444$ 285"];
    XCTAssertFalse(luhn.isValid);
}

- (void)testSingleZeroWithSpaceInvalid {
    Luhn *luhn = [[Luhn alloc] initWithString:@" 0"];
    XCTAssertFalse(luhn.isValid);
}

- (void)testMoreThanOneZeroValid {
    Luhn *luhn = [[Luhn alloc] initWithString:@"0000 0"];
    XCTAssertTrue(luhn.isValid);
}

- (void)testInputDigit9CorrectConverted {
    Luhn *luhn = [[Luhn alloc] initWithString:@"091"];
    XCTAssertTrue(luhn.isValid);
}

@end

Version data entries

226 entries across 226 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.158 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.157 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.156 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.155 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.154 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.153 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.152 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.151 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.150 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.149 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.148 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.147 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.146 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.145 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.144 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.143 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.142 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.141 tracks/objective-c/exercises/luhn/LuhnTest.m
trackler-2.2.1.140 tracks/objective-c/exercises/luhn/LuhnTest.m