Skip to content

Instantly share code, notes, and snippets.

@marcphilipp
Created August 5, 2012 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcphilipp/3263627 to your computer and use it in GitHub Desktop.
Save marcphilipp/3263627 to your computer and use it in GitHub Desktop.
Objective-C Intro @ SoCraTes 2012 (by Johannes Seitz)
//
// primefactorsTests.h
// primefactorsTests
//
// Created by Marc Philipp on 04.08.12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <SenTestingKit/SenTestingKit.h>
@interface PrimefactorsTests : SenTestCase
@end
//
// primefactorsTests.m
// primefactorsTests
//
// Created by Marc Philipp on 04.08.12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "PrimefactorsTests.h"
@interface PrimeFactors : NSObject
@end
@implementation PrimeFactors
-(id) initMyClass
{
self = [super init];
if (self != nil) {
}
return self;
}
-(NSArray *)factorsOf:(int) aNumber
{
return [[[NSArray alloc] init] autorelease];
}
@end
@implementation NSString (MyCategory)
+(NSString*)myName
{
return @"Marc";
}
@end
@implementation PrimefactorsTests
- (void)testPrimeFactorsOfOneAreEmptyList
{
PrimeFactors *primeFactors = [[PrimeFactors alloc] init];
NSArray *emptyArray = [[NSArray alloc] init];
STAssertEquals([primeFactors factorsOf: 1], emptyArray, @"prime factors of one");
STAssertEquals(@"Marc", [NSString myName], nil);
[emptyArray release];
[primeFactors release];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment