avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosu...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/src/test/org/apache/avalon/excalibur/collections/test VariableSizeBufferTestCase.java
Date Wed, 06 Mar 2002 08:18:30 GMT
leosutic    02/03/06 00:18:30

  Added:       src/test/org/apache/avalon/excalibur/collections/test
                        VariableSizeBufferTestCase.java
  Log:
  Test case exposing a buffer resize bug. This bug has been fixed, and the test case is added
for regression testing purposes.
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-excalibur/src/test/org/apache/avalon/excalibur/collections/test/VariableSizeBufferTestCase.java
  
  Index: VariableSizeBufferTestCase.java
  ===================================================================
  package org.apache.avalon.excalibur.collections.test;
  
  import junit.framework.TestCase;
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  import org.apache.avalon.excalibur.collections.VariableSizeBuffer;
  
  public class VariableSizeBufferTestCase
      extends TestCase
  {
      public VariableSizeBufferTestCase( final String name )
      {
          super( name );
      }
  
  
      /**
       * Triggers a situation when m_tail < m_head during buffer
       * extension, so copying will be wrapping around the end of
       * the buffer.
       */
      public void testGrowthWrapAround ()
          throws Exception
      {
          VariableSizeBuffer buf = new VariableSizeBuffer(1);
          buf.add("1");
          assertEquals("Got 1 that just added", "1", buf.remove());
          buf.add("2");
          buf.add("3");
          assertEquals("After 3 puts and 1 remove buffer size must be 2",
                       2, buf.size());
          assertEquals("Got 2", "2", buf.remove());
          assertEquals("Got 3", "3", buf.remove());
          assertTrue("Buffer is empty", buf.isEmpty());
      }
  
      /**
       * Extension is done when m_head = 0 and m_tail = m_buffer.length - 1.
       */
      public void testGrowthCopyStartToEnd() {
          VariableSizeBuffer buf = new VariableSizeBuffer(1);
          buf.add("1");
          buf.add("2");
          assertEquals("After 2 puts buffer size must be 2",
                       2, buf.size());
          assertEquals("Got 1", "1", buf.remove());
          assertEquals("Got 2", "2", buf.remove());
          assertTrue("Buffer is empty", buf.isEmpty());
      }
  }
  
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message