int
109110111112113114115116117118119
assertEquals( 0, array.length ); stack.push( 10 ); stack.push( 20 ); stack.push( 30 ); stack.push( 40 ); array = stack.toArray(); assertNotNull( array ); assertEquals( 4, array.length ); // NOTE: Top element in stack should be first element in array
148149150151152153154155156157158
public void testClear() { TIntStack stack = new TIntArrayStack(); assertEquals( 0, stack.size() ); stack.push( 10 ); assertEquals( 1, stack.size() ); assertEquals( 10, stack.pop() ); assertEquals( 0, stack.size() );
154155156157158159160161162163164
assertEquals( 1, stack.size() ); assertEquals( 10, stack.pop() ); assertEquals( 0, stack.size() ); stack.push( 10 ); stack.push( 20 ); stack.push( 30 ); assertEquals( 3, stack.size() ); stack.clear();
155156157158159160161162163164165
156157158159160161162163164165166
assertEquals( 10, stack.pop() ); assertEquals( 0, stack.size() ); stack.push( 10 ); stack.push( 20 ); stack.push( 30 ); assertEquals( 3, stack.size() ); stack.clear(); assertEquals( 0, stack.size() );
169170171172173174175176177178179
public void testEquals() { TIntStack stack = new TIntArrayStack(); assertEquals( 0, stack.size() ); stack.push( 10 ); stack.push( 20 ); assertEquals( 2, stack.size() ); TIntStack other = new TIntArrayStack( 20 ); other.push( 10 );
170171172173174175176177178179180
public void testEquals() { TIntStack stack = new TIntArrayStack(); assertEquals( 0, stack.size() ); stack.push( 10 ); stack.push( 20 ); assertEquals( 2, stack.size() ); TIntStack other = new TIntArrayStack( 20 ); other.push( 10 ); other.push( 20 );
174175176177178179180181182183184
stack.push( 10 ); stack.push( 20 ); assertEquals( 2, stack.size() ); TIntStack other = new TIntArrayStack( 20 ); other.push( 10 ); other.push( 20 ); assertEquals( 2, other.size() ); assertTrue( "stacks should equal itself: " + stack, stack.equals( stack ) );
175176177178179180181182183184185
stack.push( 20 ); assertEquals( 2, stack.size() ); TIntStack other = new TIntArrayStack( 20 ); other.push( 10 ); other.push( 20 ); assertEquals( 2, other.size() ); assertTrue( "stacks should equal itself: " + stack, stack.equals( stack ) );
194195196197198199200201202203204
public void testHashCode() { TIntStack stack = new TIntArrayStack(); assertEquals( 0, stack.size() ); stack.push( 10 ); stack.push( 20 ); assertEquals( 2, stack.size() ); TIntStack other = new TIntArrayStack( 20 ); other.push( 10 );