1
exercism fetch objective-c perfect-numbers

PerfectNumbersTest.m

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#import <XCTest/XCTest.h>

#if __has_include("PerfectNumbersExample.h")
# import "PerfectNumbersExample.h"
# else
# import "PerfectNumbers.h"
#endif

NS_ASSUME_NONNULL_BEGIN

@interface PerfectNumbersTest : XCTestCase

@end

@implementation PerfectNumbersTest

- (void)testPerfect {
    NumberClassifier *numberClassifier = [[NumberClassifier alloc] initWithNumber:6];
    NumberClassification expectedValue = NumberClassificationPerfect;
    NumberClassification result = [numberClassifier classification];
    XCTAssertEqual(result, expectedValue);
}

- (void)testPerfectAgain {
    NumberClassifier *numberClassifier = [[NumberClassifier alloc] initWithNumber:28];
    NumberClassification expectedValue = NumberClassificationPerfect;
    NumberClassification result = [numberClassifier classification];
    XCTAssertEqual(result, expectedValue);
}

- (void)testDeficient {
    NumberClassifier *numberClassifier = [[NumberClassifier alloc] initWithNumber:13];
    NumberClassification expectedValue = NumberClassificationDeficient;
    NumberClassification result = [numberClassifier classification];
    XCTAssertEqual(result, expectedValue);
}

- (void)testAbundant {
    NumberClassifier *numberClassifier = [[NumberClassifier alloc] initWithNumber:12];
    NumberClassification expectedValue = NumberClassificationAbundant;
    NumberClassification result = [numberClassifier classification];
    XCTAssertEqual(result, expectedValue);
}

@end
NS_ASSUME_NONNULL_END