You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2004/04/15 00:42:08 UTC

cvs commit: jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives TestIntStack.java TestFloatStack.java TestCharStack.java TestBooleanStack.java TestShortStack.java TestByteStack.java TestLongStack.java TestDoubleStack.java PackageTestSuite.java IntStackTest.java ShortStackTest.java BooleanStackTest.java DoubleStackTest.java FloatStackTest.java ByteStackTest.java LongStackTest.java CharStackTest.java

scolebourne    2004/04/14 15:42:08

  Modified:    primitives/src/test/org/apache/commons/collections/primitives
                        PackageTestSuite.java
  Added:       primitives/src/test/org/apache/commons/collections/primitives
                        TestIntStack.java TestFloatStack.java
                        TestCharStack.java TestBooleanStack.java
                        TestShortStack.java TestByteStack.java
                        TestLongStack.java TestDoubleStack.java
  Removed:     primitives/src/test/org/apache/commons/collections/primitives
                        IntStackTest.java ShortStackTest.java
                        BooleanStackTest.java DoubleStackTest.java
                        FloatStackTest.java ByteStackTest.java
                        LongStackTest.java CharStackTest.java
  Log:
  Rename test classes in line with primitives standards and integrate into suite
  
  Revision  Changes    Path
  1.10      +10 -1     jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/PackageTestSuite.java
  
  Index: PackageTestSuite.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/PackageTestSuite.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PackageTestSuite.java	25 Feb 2004 20:46:30 -0000	1.9
  +++ PackageTestSuite.java	14 Apr 2004 22:42:08 -0000	1.10
  @@ -38,43 +38,52 @@
       public static Test suite() {
           TestSuite suite = new TestSuite();
   
  +        suite.addTest(TestBooleanStack.suite());
  +        
           suite.addTest(TestByteCollections.suite());
           suite.addTest(TestAbstractByteCollection.suite());
           suite.addTest(TestRandomAccessByteList.suite());
           suite.addTest(TestArrayByteList.suite());
  +        suite.addTest(TestByteStack.suite());
   
           suite.addTest(TestShortCollections.suite());
           suite.addTest(TestAbstractShortCollection.suite());
           suite.addTest(TestRandomAccessShortList.suite());
           suite.addTest(TestArrayShortList.suite());
           suite.addTest(TestArrayUnsignedByteList.suite());
  +        suite.addTest(TestShortStack.suite());
   
           suite.addTest(TestCharCollections.suite());
           suite.addTest(TestAbstractCharCollection.suite());
           suite.addTest(TestRandomAccessCharList.suite());
           suite.addTest(TestArrayCharList.suite());
  +        suite.addTest(TestCharStack.suite());
   
           suite.addTest(TestIntCollections.suite());
           suite.addTest(TestAbstractIntCollection.suite());
           suite.addTest(TestRandomAccessIntList.suite());
           suite.addTest(TestArrayIntList.suite());
           suite.addTest(TestArrayUnsignedShortList.suite());
  +        suite.addTest(TestIntStack.suite());
   
           suite.addTest(TestLongCollections.suite());
   		suite.addTest(TestAbstractLongCollection.suite());
   		suite.addTest(TestRandomAccessLongList.suite());
           suite.addTest(TestArrayLongList.suite());
           suite.addTest(TestArrayUnsignedIntList.suite());
  +        suite.addTest(TestLongStack.suite());
   
           suite.addTest(TestFloatCollections.suite());
           suite.addTest(TestAbstractFloatCollection.suite());
           suite.addTest(TestRandomAccessFloatList.suite());
           suite.addTest(TestArrayFloatList.suite());
  +        suite.addTest(TestFloatStack.suite());
   
           suite.addTest(TestDoubleCollections.suite());
           suite.addTest(TestAbstractDoubleCollection.suite());
           suite.addTest(TestRandomAccessDoubleList.suite());
           suite.addTest(TestArrayDoubleList.suite());
  +        suite.addTest(TestDoubleStack.suite());
   
           return suite;
       }
  
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/TestIntStack.java
  
  Index: TestIntStack.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.commons.collections.primitives;
  
  import java.util.EmptyStackException;
  
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  /**
   * Tests the IntStack class.
   *
   * @author Apache Directory Project
   * @since Commons Primitives 1.1
   * @version $Revision: 1.1 $ $Date: 2004/04/14 22:42:07 $
   */
  public class TestIntStack extends TestCase
  {
      IntStack stack = null ;
      
      
      /**
       * Runs the test. 
       * 
       * @param args nada
       */
      public static void main( String[] args )
      {
          junit.textui.TestRunner.run( TestIntStack.class ) ;
      }
  
      public static TestSuite suite() {
          return new TestSuite(TestBooleanStack.class);
      }
  
      
      /* (non-Javadoc)
       * @see junit.framework.TestCase#setUp()
       */
      protected void setUp() throws Exception
      {
          super.setUp() ;
          stack = new IntStack() ;
      }
      
      
      /**
       * Constructor for IntStackTest.
       * @param arg0
       */
      public TestIntStack( String arg0 )
      {
          super( arg0 ) ;
      }
  
      
      public void testEmpty()
      {
          assertTrue( "Newly created stacks should be empty", stack.empty() ) ;
          stack.push( 0 ) ;
          assertFalse( "Stack with item should not be empty", stack.empty() ) ;
          stack.pop() ;
          assertTrue( "Stack last int popped should be empty", stack.empty() ) ;
      }
  
      
      public void testPeek()
      {
          try
          {
              stack.peek() ;
              throw new AssertionError( 
                      "Peek should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( int ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
              assertEquals( ii, stack.peek() ) ;
          }
      }
  
      
      public void testPop()
      {
          try
          {
              stack.pop() ;
              throw new AssertionError( 
                      "Pop should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( int ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
              assertEquals( ii, stack.pop() ) ;
          }
  
          for( int ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
          }
          for( int ii = 10; ii < 0; ii-- )
          {    
              stack.push( ii ) ;
              assertEquals( ii, stack.pop() ) ;
          }
      }
  
      
      public void testPush()
      {
          stack.push( 0 ) ;
          stack.push( 0 ) ;
          assertFalse( stack.empty() ) ;
          assertEquals( 0, stack.pop() ) ;
          assertEquals( 0, stack.pop() ) ;
      }
  
      
      public void testSearch()
      {
          stack.push( 0 ) ;
          stack.push( 1 ) ;
          assertEquals( 2, stack.search( 0 ) ) ;
          stack.push( 0 ) ;
          assertEquals( 1, stack.search( 0 ) ) ;
          stack.push( 0 ) ;
          assertEquals( 3, stack.search( 1 ) ) ;
          assertEquals( -1, stack.search( 44 ) ) ;
      }
  }
  
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/TestFloatStack.java
  
  Index: TestFloatStack.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.commons.collections.primitives;
  
  import java.util.EmptyStackException;
  
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  /**
   * Tests the FloatStack class.
   *
   * @author Apache Directory Project
   * @since Commons Primitives 1.1
   * @version $Revision: 1.1 $ $Date: 2004/04/14 22:42:08 $
   */
  public class TestFloatStack extends TestCase
  {
      FloatStack stack = null ;
      
      
      /**
       * Runs the test. 
       * 
       * @param args nada
       */
      public static void main( String[] args )
      {
          junit.textui.TestRunner.run( TestFloatStack.class ) ;
      }
  
      public static TestSuite suite() {
          return new TestSuite(TestBooleanStack.class);
      }
  
      
      /* (non-Javadoc)
       * @see junit.framework.TestCase#setUp()
       */
      protected void setUp() throws Exception
      {
          super.setUp() ;
          stack = new FloatStack() ;
      }
      
      
      /**
       * Constructor for IntStackTest.
       * @param arg0
       */
      public TestFloatStack( String arg0 )
      {
          super( arg0 ) ;
      }
  
      
      public void testEmpty()
      {
          assertTrue( "Newly created stacks should be empty", stack.empty() ) ;
          stack.push( 1.4f ) ;
          assertFalse( "Stack with item should not be empty", stack.empty() ) ;
          stack.pop() ;
          assertTrue( "Stack last int popped should be empty", stack.empty() ) ;
      }
  
      
      public void testPeek()
      {
          try
          {
              stack.peek() ;
              throw new AssertionError( 
                      "Peek should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( float ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
              assertTrue( ii == stack.peek() ) ;
          }
      }
  
      
      public void testPop()
      {
          try
          {
              stack.pop() ;
              throw new AssertionError( 
                      "Pop should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( float ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
              assertTrue( ii == stack.pop() ) ;
          }
  
          for( float ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
          }
          for( float ii = 10; ii < 0; ii-- )
          {    
              stack.push( ii ) ;
              assertTrue( ii == stack.pop() ) ;
          }
      }
  
      
      public void testPush()
      {
          stack.push( ( float ) 1.4f ) ;
          stack.push( ( float ) 2.67f ) ;
          assertFalse( stack.empty() ) ;
          assertTrue( 2.67f == stack.pop() ) ;
          assertTrue( 1.4f == stack.pop() ) ;
      }
  
      
      public void testSearch()
      {
          stack.push( ( float ) 0 ) ;
          stack.push( ( float ) 1 ) ;
          assertTrue( 2 == stack.search( ( float ) 0 ) ) ;
          stack.push( ( float ) 0 ) ;
          assertTrue( 1 == stack.search( ( float ) 0 ) ) ;
          stack.push( ( float ) 0 ) ;
          assertTrue( 3 == stack.search( ( float ) 1 ) ) ;
          assertTrue( -1 == stack.search( ( float ) 44 ) ) ;
      }
  }
  
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/TestCharStack.java
  
  Index: TestCharStack.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.commons.collections.primitives;
  
  import java.util.EmptyStackException;
  
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  /**
   * Tests the CharStack class.
   *
   * @author Apache Directory Project
   * @since Commons Primitives 1.1
   * @version $Revision: 1.1 $ $Date: 2004/04/14 22:42:08 $
   */
  public class TestCharStack extends TestCase
  {
      CharStack stack = null ;
      
      
      /**
       * Runs the test. 
       * 
       * @param args nada
       */
      public static void main( String[] args )
      {
          junit.textui.TestRunner.run( TestCharStack.class ) ;
      }
  
      public static TestSuite suite() {
          return new TestSuite(TestBooleanStack.class);
      }
  
      
      /* (non-Javadoc)
       * @see junit.framework.TestCase#setUp()
       */
      protected void setUp() throws Exception
      {
          super.setUp() ;
          stack = new CharStack() ;
      }
      
      
      /**
       * Constructor for IntStackTest.
       * @param arg0
       */
      public TestCharStack( String arg0 )
      {
          super( arg0 ) ;
      }
  
      
      public void testEmpty()
      {
          assertTrue( "Newly created stacks should be empty", stack.empty() ) ;
          stack.push( 'A' ) ;
          assertFalse( "Stack with item should not be empty", stack.empty() ) ;
          stack.pop() ;
          assertTrue( "Stack last int popped should be empty", stack.empty() ) ;
      }
  
      
      public void testPeek()
      {
          try
          {
              stack.peek() ;
              throw new AssertionError( 
                      "Peek should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( char ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
              assertTrue( ii == stack.peek() ) ;
          }
      }
  
      
      public void testPop()
      {
          try
          {
              stack.pop() ;
              throw new AssertionError( 
                      "Pop should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( char ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
              assertTrue( ii == stack.pop() ) ;
          }
  
          for( char ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
          }
          for( char ii = 10; ii < 0; ii-- )
          {    
              stack.push( ( char ) ii ) ;
              assertTrue( ii == stack.pop() ) ;
          }
      }
  
      
      public void testPush()
      {
          stack.push( ( char ) 0 ) ;
          stack.push( ( char ) 0 ) ;
          assertFalse( stack.empty() ) ;
          assertTrue( 0 == stack.pop() ) ;
          assertTrue( 0 == stack.pop() ) ;
      }
  
      
      public void testSearch()
      {
          stack.push( ( char ) 0 ) ;
          stack.push( ( char ) 1 ) ;
          assertTrue( 2 == stack.search( ( char ) 0 ) ) ;
          stack.push( ( char ) 0 ) ;
          assertTrue( 1 == stack.search( ( char ) 0 ) ) ;
          stack.push( ( char ) 0 ) ;
          assertTrue( 3 == stack.search( ( char ) 1 ) ) ;
          assertTrue( -1 == stack.search( ( char ) 44 ) ) ;
      }
  }
  
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/TestBooleanStack.java
  
  Index: TestBooleanStack.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.commons.collections.primitives;
  
  import java.util.EmptyStackException;
  
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  /**
   * Tests the BooleanStack class.
   *
   * @author Apache Directory Project
   * @since Commons Primitives 1.1
   * @version $Revision: 1.1 $ $Date: 2004/04/14 22:42:08 $
   */
  public class TestBooleanStack extends TestCase
  {
      BooleanStack stack = null ;
      
      
      /**
       * Runs the test. 
       * 
       * @param args nada
       */
      public static void main( String[] args )
      {
          junit.textui.TestRunner.run( TestBooleanStack.class ) ;
      }
  
      public static TestSuite suite() {
          return new TestSuite(TestBooleanStack.class);
      }
  
      
      /* (non-Javadoc)
       * @see junit.framework.TestCase#setUp()
       */
      protected void setUp() throws Exception
      {
          super.setUp() ;
          stack = new BooleanStack() ;
      }
      
      
      /**
       * Constructor for IntStackTest.
       * @param arg0
       */
      public TestBooleanStack( String arg0 )
      {
          super( arg0 ) ;
      }
  
      
      public void testEmpty()
      {
          assertTrue( "Newly created stacks should be empty", stack.empty() ) ;
          stack.push( true ) ;
          assertFalse( "Stack with item should not be empty", stack.empty() ) ;
          stack.pop() ;
          assertTrue( "Stack last int popped should be empty", stack.empty() ) ;
      }
  
      
      public void testPeek()
      {
          try
          {
              stack.peek() ;
              throw new AssertionError( 
                      "Peek should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( int ii = 0; ii < 10; ii++ )
          {
              if ( ii % 2 == 0 )
              {
                  stack.push( false ) ;
                  assertFalse( stack.peek() ) ;
              }
              else
              {
                  stack.push( true ) ;
                  assertTrue( stack.peek() ) ;
              }
          }
      }
  
      
      public void testPop()
      {
          try
          {
              stack.pop() ;
              throw new AssertionError( 
                      "Pop should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( int ii = 0; ii < 10; ii++ )
          {    
              if ( ii % 2 == 0 )
              {
                  stack.push( false ) ;
                  assertFalse( stack.pop() ) ;
              }
              else
              {
                  stack.push( true ) ;
                  assertTrue( stack.pop() ) ;
              }
          }
  
          for( int ii = 0; ii < 10; ii++ )
          {    
              if ( ii % 2 == 0 )
              {
                  stack.push( false ) ;
              }
              else
              {
                  stack.push( true ) ;
              }
          }
  
          for( short ii = 10; ii < 0; ii-- )
          {    
              if ( ii % 2 == 0 )
              {
                  stack.push( false ) ;
                  assertFalse( stack.pop() ) ;
              }
              else
              {
                  stack.push( true ) ;
                  assertTrue( stack.pop() ) ;
              }
          }
      }
  
      
      public void testPush()
      {
          stack.push( false ) ;
          stack.push( false ) ;
          stack.push( true ) ;
          assertFalse( stack.empty() ) ;
          assertTrue( stack.pop() ) ;
          assertFalse( stack.pop() ) ;
          assertFalse( stack.pop() ) ;
      }
  
      
      public void testSearch()
      {
          stack.push( false ) ;
          assertTrue( -1 == stack.search( true ) ) ;
          stack.push( true ) ;
          assertTrue( 2 == stack.search( false ) ) ;
          stack.push( false ) ;
          assertTrue( 1 == stack.search( false ) ) ;
          stack.push( false ) ;
          assertTrue( 3 == stack.search( true ) ) ;
      }
  }
  
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/TestShortStack.java
  
  Index: TestShortStack.java
  ===================================================================
  /*
   *   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   *
   */
  package org.apache.commons.collections.primitives ;
  
  
  import java.util.EmptyStackException;
  
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  
  /**
   * Tests the ShortStack class.
   *
   * @author <a href="mailto:directory-dev@incubator.apache.org">
   * Apache Directory Project</a>
   * @version $Rev: 9968 $
   */
  public class TestShortStack extends TestCase
  {
      ShortStack stack = null ;
      
      
      /**
       * Runs the test. 
       * 
       * @param args nada
       */
      public static void main( String[] args )
      {
          junit.textui.TestRunner.run( TestShortStack.class ) ;
      }
  
      public static TestSuite suite() {
          return new TestSuite(TestBooleanStack.class);
      }
  
      
      /* (non-Javadoc)
       * @see junit.framework.TestCase#setUp()
       */
      protected void setUp() throws Exception
      {
          super.setUp() ;
          stack = new ShortStack() ;
      }
      
      
      /**
       * Constructor for IntStackTest.
       * @param arg0
       */
      public TestShortStack( String arg0 )
      {
          super( arg0 ) ;
      }
  
      
      public void testEmpty()
      {
          assertTrue( "Newly created stacks should be empty", stack.empty() ) ;
          stack.push( ( short ) 12342 ) ;
          assertFalse( "Stack with item should not be empty", stack.empty() ) ;
          stack.pop() ;
          assertTrue( "Stack last int popped should be empty", stack.empty() ) ;
      }
  
      
      public void testPeek()
      {
          try
          {
              stack.peek() ;
              throw new AssertionError( 
                      "Peek should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( int ii = 0; ii < 10; ii++ )
          {    
              stack.push( ( short ) ii ) ;
              assertTrue( ii == stack.peek() ) ;
          }
      }
  
      
      public void testPop()
      {
          try
          {
              stack.pop() ;
              throw new AssertionError( 
                      "Pop should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( short ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
              assertTrue( ii == stack.pop() ) ;
          }
  
          for( short ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
          }
          for( short ii = 10; ii < 0; ii-- )
          {    
              stack.push( ii ) ;
              assertTrue( ii == stack.pop() ) ;
          }
      }
  
      
      public void testPush()
      {
          stack.push( ( short ) 0 ) ;
          stack.push( ( short ) 0 ) ;
          assertFalse( stack.empty() ) ;
          assertTrue( 0 == stack.pop() ) ;
          assertTrue( 0 == stack.pop() ) ;
      }
  
      
      public void testSearch()
      {
          stack.push( ( short ) 0 ) ;
          stack.push( ( short ) 1 ) ;
          assertTrue( 2 == stack.search( ( short ) 0 ) ) ;
          stack.push( ( short ) 0 ) ;
          assertTrue( 1 == stack.search( ( short ) 0 ) ) ;
          stack.push( ( short ) 0 ) ;
          assertTrue( 3 == stack.search( ( short ) 1 ) ) ;
          assertTrue( -1 == stack.search( ( short ) 44 ) ) ;
      }
  }
  
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/TestByteStack.java
  
  Index: TestByteStack.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.commons.collections.primitives;
  
  import java.util.EmptyStackException;
  
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  /**
   * Tests the ByteStack class.
   *
   * @author Apache Directory Project
   * @since Commons Primitives 1.1
   * @version $Revision: 1.1 $ $Date: 2004/04/14 22:42:08 $
   */
  public class TestByteStack extends TestCase
  {
      ByteStack stack = null ;
      
      
      /**
       * Runs the test. 
       * 
       * @param args nada
       */
      public static void main( String[] args )
      {
          junit.textui.TestRunner.run( TestByteStack.class ) ;
      }
  
      public static TestSuite suite() {
          return new TestSuite(TestBooleanStack.class);
      }
  
      
      /* (non-Javadoc)
       * @see junit.framework.TestCase#setUp()
       */
      protected void setUp() throws Exception
      {
          super.setUp() ;
          stack = new ByteStack() ;
      }
      
      
      /**
       * Constructor for IntStackTest.
       * @param arg0
       */
      public TestByteStack( String arg0 )
      {
          super( arg0 ) ;
      }
  
      
      public void testEmpty()
      {
          assertTrue( "Newly created stacks should be empty", stack.empty() ) ;
          stack.push( ( byte ) 0 ) ;
          assertFalse( "Stack with item should not be empty", stack.empty() ) ;
          stack.pop() ;
          assertTrue( "Stack last int popped should be empty", stack.empty() ) ;
      }
  
      
      public void testPeek()
      {
          try
          {
              stack.peek() ;
              throw new AssertionError( 
                      "Peek should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( int ii = 0; ii < 10; ii++ )
          {    
              stack.push( ( byte ) ii ) ;
              assertTrue( ii == stack.peek() ) ;
          }
      }
  
      
      public void testPop()
      {
          try
          {
              stack.pop() ;
              throw new AssertionError( 
                      "Pop should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( int ii = 0; ii < 10; ii++ )
          {    
              stack.push( ( byte ) ii ) ;
              assertTrue( ii == stack.pop() ) ;
          }
  
          for( int ii = 0; ii < 10; ii++ )
          {    
              stack.push( ( byte ) ii ) ;
          }
          for( int ii = 10; ii < 0; ii-- )
          {    
              stack.push( ( byte ) ii ) ;
              assertTrue( ii == stack.pop() ) ;
          }
      }
  
      
      public void testPush()
      {
          stack.push( ( byte ) 0 ) ;
          stack.push( ( byte ) 0 ) ;
          assertFalse( stack.empty() ) ;
          assertTrue( 0 == stack.pop() ) ;
          assertTrue( 0 == stack.pop() ) ;
      }
  
      
      public void testSearch()
      {
          stack.push( ( byte ) 0 ) ;
          stack.push( ( byte ) 1 ) ;
          assertTrue( 2 == stack.search( ( byte ) 0 ) ) ;
          stack.push( ( byte ) 0 ) ;
          assertTrue( 1 == stack.search( ( byte ) 0 ) ) ;
          stack.push( ( byte ) 0 ) ;
          assertTrue( 3 == stack.search( ( byte ) 1 ) ) ;
          assertTrue( -1 == stack.search( ( byte ) 44 ) ) ;
      }
  }
  
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/TestLongStack.java
  
  Index: TestLongStack.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.commons.collections.primitives;
  
  import java.util.EmptyStackException;
  
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  /**
   * Tests the LongStack class.
   *
   * @author Apache Directory Project
   * @since Commons Primitives 1.1
   * @version $Revision: 1.1 $ $Date: 2004/04/14 22:42:08 $
   */
  public class TestLongStack extends TestCase
  {
      LongStack stack = null ;
      
      
      /**
       * Runs the test. 
       * 
       * @param args nada
       */
      public static void main( String[] args )
      {
          junit.textui.TestRunner.run( TestLongStack.class ) ;
      }
  
      public static TestSuite suite() {
          return new TestSuite(TestBooleanStack.class);
      }
  
      
      /* (non-Javadoc)
       * @see junit.framework.TestCase#setUp()
       */
      protected void setUp() throws Exception
      {
          super.setUp() ;
          stack = new LongStack() ;
      }
      
      
      /**
       * Constructor for IntStackTest.
       * @param arg0
       */
      public TestLongStack( String arg0 )
      {
          super( arg0 ) ;
      }
  
      
      public void testEmpty()
      {
          assertTrue( "Newly created stacks should be empty", stack.empty() ) ;
          stack.push( 1234223332233234322l ) ;
          assertFalse( "Stack with item should not be empty", stack.empty() ) ;
          stack.pop() ;
          assertTrue( "Stack last int popped should be empty", stack.empty() ) ;
      }
  
      
      public void testPeek()
      {
          try
          {
              stack.peek() ;
              throw new AssertionError( 
                      "Peek should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( int ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
              assertTrue( ii == stack.peek() ) ;
          }
      }
  
      
      public void testPop()
      {
          try
          {
              stack.pop() ;
              throw new AssertionError( 
                      "Pop should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( long ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
              assertTrue( ii == stack.pop() ) ;
          }
  
          for( long ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
          }
          for( long ii = 10; ii < 0; ii-- )
          {    
              stack.push( ii ) ;
              assertTrue( ii == stack.pop() ) ;
          }
      }
  
      
      public void testPush()
      {
          stack.push( 0L ) ;
          stack.push( 0L ) ;
          assertFalse( stack.empty() ) ;
          assertTrue( 0L == stack.pop() ) ;
          assertTrue( 0L == stack.pop() ) ;
      }
  
      
      public void testSearch()
      {
          stack.push( 0L ) ;
          stack.push( 1L ) ;
          assertTrue( 2L == stack.search( 0L ) ) ;
          stack.push( 0L ) ;
          assertTrue( 1L == stack.search( 0L ) ) ;
          stack.push( 0L ) ;
          assertTrue( 3L == stack.search( 1L ) ) ;
          assertTrue( -1L == stack.search( 44L ) ) ;
      }
  }
  
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/TestDoubleStack.java
  
  Index: TestDoubleStack.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.commons.collections.primitives;
  
  import java.util.EmptyStackException;
  
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  /**
   * Tests the DoubleStack class.
   *
   * @author Apache Directory Project
   * @since Commons Primitives 1.1
   * @version $Revision: 1.1 $ $Date: 2004/04/14 22:42:08 $
   */
  public class TestDoubleStack extends TestCase
  {
      DoubleStack stack = null ;
      
      
      /**
       * Runs the test. 
       * 
       * @param args nada
       */
      public static void main( String[] args )
      {
          junit.textui.TestRunner.run( TestDoubleStack.class ) ;
      }
  
      public static TestSuite suite() {
          return new TestSuite(TestBooleanStack.class);
      }
  
      
      /* (non-Javadoc)
       * @see junit.framework.TestCase#setUp()
       */
      protected void setUp() throws Exception
      {
          super.setUp() ;
          stack = new DoubleStack() ;
      }
      
      
      /**
       * Constructor for IntStackTest.
       * @param arg0
       */
      public TestDoubleStack( String arg0 )
      {
          super( arg0 ) ;
      }
  
      
      public void testEmpty()
      {
          assertTrue( "Newly created stacks should be empty", stack.empty() ) ;
          stack.push( 0.3 ) ;
          assertFalse( "Stack with item should not be empty", stack.empty() ) ;
          stack.pop() ;
          assertTrue( "Stack last int popped should be empty", stack.empty() ) ;
      }
  
      
      public void testPeek()
      {
          try
          {
              stack.peek() ;
              throw new AssertionError( 
                      "Peek should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( int ii = 0; ii < 10; ii++ )
          {    
              stack.push( ( double ) ii ) ;
              assertTrue( ii == stack.peek() ) ;
          }
      }
  
      
      public void testPop()
      {
          try
          {
              stack.pop() ;
              throw new AssertionError( 
                      "Pop should have thrown an EmptyStackException" ) ;
          }
          catch( EmptyStackException e )
          {
              assertNotNull( "EmptyStackException should not be null", e ) ;
          }
          
          for( double ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
              assertTrue( ii == stack.pop() ) ;
          }
  
          for( double ii = 0; ii < 10; ii++ )
          {    
              stack.push( ii ) ;
          }
          for( double ii = 10; ii < 0; ii-- )
          {    
              stack.push( ii ) ;
              assertTrue( ii == stack.pop() ) ;
          }
      }
  
      
      public void testPush()
      {
          stack.push( ( double ) 0 ) ;
          stack.push( ( double ) 0 ) ;
          assertFalse( stack.empty() ) ;
          assertTrue( 0 == stack.pop() ) ;
          assertTrue( 0 == stack.pop() ) ;
      }
  
      
      public void testSearch()
      {
          stack.push( ( double ) 0 ) ;
          stack.push( ( double ) 1 ) ;
          assertTrue( 2 == stack.search( ( double ) 0 ) ) ;
          stack.push( ( double ) 0 ) ;
          assertTrue( 1 == stack.search( ( double ) 0 ) ) ;
          stack.push( ( double ) 0 ) ;
          assertTrue( 3 == stack.search( ( double ) 1 ) ) ;
          assertTrue( -1 == stack.search( ( double ) 44 ) ) ;
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org