Skip to content

Instantly share code, notes, and snippets.

@PaulWoodIII
Created September 14, 2016 17:11
Show Gist options
  • Select an option

  • Save PaulWoodIII/d9a73f33aac62071c077e792a8b47a9e to your computer and use it in GitHub Desktop.

Select an option

Save PaulWoodIII/d9a73f33aac62071c077e792a8b47a9e to your computer and use it in GitHub Desktop.
//
// TestSomethingCoolTests.m
// TestSomethingCoolTests
//
// Created by Paul Wood on 9/14/16.
// Copyright © 2016 Paul Wood. All rights reserved.
//
#import <XCTest/XCTest.h>
@interface TestSomethingCoolTests : XCTestCase
@property NSMutableArray *cards;
@property NSInteger testTimes;
@end
@implementation TestSomethingCoolTests
- (void)setUp {
[super setUp];
_testTimes = 10000;
_cards = [[NSMutableArray alloc] initWithArray:@[
@0,
@1,
@2,
@3,
@4,
@5,
@6,
@7,
@8,
@9,
@10
]];
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testShuffleContinue {
// This is an example of a performance test case.
[self measureBlock:^{
while(_testTimes > 0){
for (int i = 0; i < _cards.count; i++){
int random = arc4random_uniform((int)_cards.count);
if(i == random){
continue;
}
[_cards exchangeObjectAtIndex:i withObjectAtIndex:random];
}
_testTimes = _testTimes - 1;
}
// Put the code you want to measure the time of here.
}];
}
- (void)testShuffle {
// This is an example of a performance test case.
[self measureBlock:^{
while(_testTimes > 0){
for (int i = 0; i < _cards.count; i++){
int random = arc4random_uniform((int)_cards.count);
[_cards exchangeObjectAtIndex:i withObjectAtIndex:random];
}
_testTimes = _testTimes - 1;
}
// Put the code you want to measure the time of here.
}];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment