Package etch.util.core.nio

Examples of etch.util.core.nio.History


  /** @throws Exception */
  @Test( expected = IllegalStateException.class )
  public void alloc6() throws Exception
  {
    // newAlloc < 0
    History h = new History( 0, 10, 5 );
    checkUsedAlloc( h, 0, 0 );
    // try to underflow
    h.alloc( -1 );
  }
View Full Code Here


  /** @throws Exception */
  @Test( expected = IllegalStateException.class )
  public void alloc7() throws Exception
  {
    // newAlloc < 0
    History h = new History( 0, 10, 5 );
    checkUsedAlloc( h, 0, 0 );
    h.alloc( 1 );
    checkUsedAlloc( h, 0, 1 );
    // try to underflow
    h.alloc( -2 );
  }
View Full Code Here

 
  /** @throws Exception */
  @Test
  public void alloc8() throws Exception
  {
    History h = new History( 0, 10, 5 );
    checkUsedAlloc( h, 0, 0 );
    h.alloc( 1 );
    checkUsedAlloc( h, 0, 1 );
    try
    {
      // try to underflow
      h.alloc( -2 );
      fail( "never reached" );
    }
    catch ( IllegalStateException e )
    {
      // make sure alloc was not adjusted...
View Full Code Here

  /** @throws Exception */
  @Test( expected = IllegalArgumentException.class )
  public void alloc9() throws Exception
  {
    // k == 0
    History h = new History( 0, 10, 5 );
    h.alloc( 0 );
  }
View Full Code Here

 
  /** @throws Exception */
  @Test
  public void suggested1() throws Exception
  {
    History h = new History( 0, 10, 5 );
    assertEquals( 0, h.suggested() );
    h.tickle();
    assertEquals( 0, h.suggested() );
    h.init();
    assertEquals( 0, h.suggested() );
  }
View Full Code Here

 
  /** @throws Exception */
  @Test
  public void suggested2() throws Exception
  {
    History h = new History( 2, 10, 5 );
    assertEquals( 2, h.suggested() );
    h.tickle();
    assertEquals( 2, h.suggested() );
    h.init();
    assertEquals( 2, h.suggested() );
  }
View Full Code Here

 
  /** @throws Exception */
  @Test
  public void suggested3() throws Exception
  {
    History h = new History( 0, 10, 5 );
    assertEquals( 0, h.suggested() );
   
    assertTrue( h.used( 10 ) );
    assertEquals( 10, h.getUsed() );
   
    assertEquals( 0, h.suggested() ); // avg(0, 0, 0, 0, 0) == 0
    h.tickle();
    assertEquals( 2, h.suggested() ); // avg(10, 0, 0, 0, 0) == 2
    h.tickle();
    assertEquals( 4, h.suggested() ); // avg(10, 10, 0, 0, 0) == 4
    h.tickle();
    assertEquals( 6, h.suggested() ); // avg(10, 10, 10, 0, 0) == 6
    h.tickle();
    assertEquals( 8, h.suggested() ); // avg(10, 10, 10, 10, 0) == 8
    h.tickle();
    assertEquals( 10, h.suggested() ); // avg(10, 10, 10, 10, 10) == 10
    h.tickle();
    assertEquals( 10, h.suggested() ); // avg(10, 10, 10, 10, 10) == 10
   
    assertTrue( h.used( -10 ) );
    assertEquals( 0, h.getUsed() );
   
    h.tickle();
    assertEquals( 10, h.suggested() ); // avg(10, 10, 10, 10, 10) == 10
    h.tickle();
    assertEquals( 8, h.suggested() ); // avg(0, 10, 10, 10, 10) == 8
    h.tickle();
    assertEquals( 6, h.suggested() ); // avg(0, 0, 10, 10, 10) == 6
    h.tickle();
    assertEquals( 4, h.suggested() ); // avg(0, 0, 0, 10, 10) == 4
    h.tickle();
    assertEquals( 2, h.suggested() ); // avg(0, 0, 0, 0, 10) == 2
    h.tickle();
    assertEquals( 0, h.suggested() ); // avg(0, 0, 0, 0, 0) == 0
  }
View Full Code Here

 
  /** @throws Exception */
  @Test
  public void suggested4() throws Exception
  {
    History h = new History( 2, 10, 5 );
    assertEquals( 2, h.suggested() );
   
    assertTrue( h.used( 10 ) );
    assertEquals( 10, h.getUsed() );
   
    assertEquals( 2, h.suggested() ); // avg(2, 2, 2, 2, 2) == 2
    h.tickle();
    assertEquals( 3, h.suggested() ); // avg(10, 2, 2, 2, 2) == 3
    h.tickle();
    assertEquals( 5, h.suggested() ); // avg(10, 10, 2, 2, 2) == 5
    h.tickle();
    assertEquals( 6, h.suggested() ); // avg(10, 10, 10, 2, 2) == 6
    h.tickle();
    assertEquals( 8, h.suggested() ); // avg(10, 10, 10, 10, 2) == 8
    h.tickle();
    assertEquals( 10, h.suggested() ); // avg(10, 10, 10, 10, 10) == 10
    h.tickle();
    assertEquals( 10, h.suggested() ); // avg(10, 10, 10, 10, 10) == 10
   
    assertTrue( h.used( -10 ) );
    assertEquals( 0, h.getUsed() );
   
    h.tickle();
    assertEquals( 10, h.suggested() ); // avg(10, 10, 10, 10, 10) == 10
    h.tickle();
    assertEquals( 8, h.suggested() ); // avg(2, 10, 10, 10, 10) == 8
    h.tickle();
    assertEquals( 6, h.suggested() ); // avg(2, 2, 10, 10, 10) == 6
    h.tickle();
    assertEquals( 5, h.suggested() ); // avg(2, 2, 2, 10, 10) == 5
    h.tickle();
    assertEquals( 3, h.suggested() ); // avg(2, 2, 2, 2, 10) == 3
    h.tickle();
    assertEquals( 2, h.suggested() ); // avg(2, 2, 2, 2, 2) == 2
  }
View Full Code Here

TOP

Related Classes of etch.util.core.nio.History

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.