aboutsummaryrefslogtreecommitdiff
path: root/antlr-3.4/runtime/ObjC/Framework/test/runtime/misc/IntArrayTest.m
blob: 2b3f3f0c4feb07a7d72f61cc4fab84631af59dd2 (plain)
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
47
//
//  IntArrayTest.m
//  ANTLR
//
//  Created by Ian Michell on 13/05/2010.
//  Copyright 2010 Ian Michell. All rights reserved.
//

#import "IntArrayTest.h"
#import "IntArray.h"

@implementation IntArrayTest

-(void) testAdd
{
	IntArray *intArray = [IntArray newIntArrayWithLen:10];
	[intArray addInteger:1];
	STAssertTrue([intArray count] == 1, @"Int array should be of size 1");
	STAssertTrue([intArray integerAtIndex:0] == 1, @"First item in int array should be 1");
	[intArray release];
}

-(void) testPushPop
{
	IntArray *intArray = [IntArray newIntArrayWithLen:10];
	for (NSInteger i = 0; i < 10; i++)
	{
		[intArray push:i + 1];
	}
	NSInteger popped = [intArray pop];
	NSLog(@"Popped value: %d", popped);
	STAssertTrue(popped == 10, @"Pop should pull the last element out, which should be 10 was: %d", popped);
	[intArray release];
}

-(void) testClearAndAdd
{
	IntArray *intArray = [IntArray newIntArrayWithLen:10];
	[intArray addInteger:1];
	STAssertTrue([intArray count] == 1, @"Int array should be of size 1");
	STAssertTrue([intArray integerAtIndex:0] == 1, @"First item in int array should be 1");
	[intArray reset];
	STAssertTrue([intArray count] == 0, @"Array size should be 0");
	[intArray release];
}

@end