IntArrayTest.m revision 324c4644fee44b9898524c09511bd33c3f12e2df
1//
2//  IntArrayTest.m
3//  ANTLR
4//
5//  Created by Ian Michell on 13/05/2010.
6//  Copyright 2010 Ian Michell. All rights reserved.
7//
8
9#import "IntArrayTest.h"
10#import "IntArray.h"
11
12@implementation IntArrayTest
13
14-(void) testAdd
15{
16	IntArray *intArray = [IntArray newIntArrayWithLen:10];
17	[intArray addInteger:1];
18	STAssertTrue([intArray count] == 1, @"Int array should be of size 1");
19	STAssertTrue([intArray integerAtIndex:0] == 1, @"First item in int array should be 1");
20	[intArray release];
21}
22
23-(void) testPushPop
24{
25	IntArray *intArray = [IntArray newIntArrayWithLen:10];
26	for (NSInteger i = 0; i < 10; i++)
27	{
28		[intArray push:i + 1];
29	}
30	NSInteger popped = [intArray pop];
31	NSLog(@"Popped value: %d", popped);
32	STAssertTrue(popped == 10, @"Pop should pull the last element out, which should be 10 was: %d", popped);
33	[intArray release];
34}
35
36-(void) testClearAndAdd
37{
38	IntArray *intArray = [IntArray newIntArrayWithLen:10];
39	[intArray addInteger:1];
40	STAssertTrue([intArray count] == 1, @"Int array should be of size 1");
41	STAssertTrue([intArray integerAtIndex:0] == 1, @"First item in int array should be 1");
42	[intArray reset];
43	STAssertTrue([intArray count] == 0, @"Array size should be 0");
44	[intArray release];
45}
46
47@end
48