Sha256: e57d2154c2258cd0cd7f7b0c131e08f8abdff5d8e75f7e5e968a127b62f3ea82

Contents?: true

Size: 1.63 KB

Versions: 250

Compression:

Stored size: 1.63 KB

Contents

#import <XCTest/XCTest.h>

#if __has_include("PascalsTriangleExample.h")
# import "PascalsTriangleExample.h"
# else
# import "PascalsTriangle.h"
#endif

@interface PascalsTriangleTest : XCTestCase

@end

@implementation PascalsTriangleTest

- (void)testOneRow {
    PascalsTriangle *triangle = [[PascalsTriangle alloc] initWithNumberOfRows:1];
    XCTAssertEqualObjects(@[@[@1]], triangle.rows);
}

- (void)testTwoRows {
    PascalsTriangle *triangle = [[PascalsTriangle alloc] initWithNumberOfRows:2];
    NSArray *expected = @[@[@1], @[@1, @1]];
    XCTAssertEqualObjects(expected, triangle.rows);
}

- (void)testThreeRows {
    PascalsTriangle *triangle = [[PascalsTriangle alloc] initWithNumberOfRows:3];
    NSArray *expected = @[@[@1], @[@1, @1], @[@1, @2, @1]];
    XCTAssertEqualObjects(expected, triangle.rows);
}

- (void)testFourthRow {
    PascalsTriangle *triangle = [[PascalsTriangle alloc] initWithNumberOfRows:4];
    NSArray *expected = @[@1, @3, @3, @1];
    XCTAssertEqualObjects(expected, [triangle.rows lastObject]);
}

- (void)testFifthRow {
    PascalsTriangle *triangle = [[PascalsTriangle alloc] initWithNumberOfRows:5];
    NSArray *expected = @[@1, @4, @6, @4, @1];
    XCTAssertEqualObjects(expected, [triangle.rows lastObject]);
}

- (void)testTwentiethRow {
    PascalsTriangle *triangle = [[PascalsTriangle alloc] initWithNumberOfRows:20];
    NSArray *expected = @[
                    @1, @19, @171, @969, @3876, @11628, @27132, @50388, @75582, @92378, @92378,
                    @75582, @50388, @27132, @11628, @3876, @969, @171, @19, @1
                    ];
    XCTAssertEqualObjects(expected, [triangle.rows lastObject]);
}

@end

Version data entries

250 entries across 250 versions & 1 rubygems

Version Path
trackler-2.2.1.78 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.77 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.76 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.75 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.74 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.73 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.72 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.71 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.70 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.69 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.68 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.67 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.66 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.65 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.64 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.63 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.62 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.61 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.60 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m
trackler-2.2.1.59 tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m