Package test.apache.kato.common

Source Code of test.apache.kato.common.TestBitMaskMappingArray$MockArrayEntryProvider

/*******************************************************************************
* 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 test.apache.kato.common;

import java.util.List;

import junit.framework.TestCase;

import org.apache.kato.common.BitMaskMappingArray;
import org.apache.kato.common.IArrayEntryProvider;

public class TestBitMaskMappingArray extends TestCase{

 
  public void testCreation() {
   
    BitMaskMappingArray array=new  BitMaskMappingArray(8,2,null);
  }
 
  public void testSingleSpanSeek() {
    BitMaskMappingArray array=new  BitMaskMappingArray(8,2,new MockArrayEntryProvider());
   
    for(int i=0;i<8;i++) {
      Long l=(Long) array.get(i);
      assertEquals(i,l.intValue());
    }
  }
 
  public void testDoubleSpanSeek() {
    BitMaskMappingArray array=new  BitMaskMappingArray(8,2,new MockArrayEntryProvider());
   
    for(int i=9;i<24;i++) {
      Long l=(Long) array.get(i);
      assertEquals(i,l.intValue());
    }
  }
 
  public void testLargeSpanSeek() {
    BitMaskMappingArray array=new  BitMaskMappingArray(8,2,new MockArrayEntryProvider());
   
    Long l=(Long) array.get(100);
    assertEquals(100,l.intValue());
   
    l=(Long) array.get(1000);
    assertEquals(1000,l.intValue());
   
   
   
  }
  class MockArrayEntryProvider implements IArrayEntryProvider {

    long location=0;
    @Override
    public Object getCurrentElement() {
     
      return new Long(location);
    }

    @Override
    public boolean moveRelativeElement(int seekNo) {
      location+=seekNo;
      return true;
    }

    @Override
    public boolean moveToLocation(long l) {
      location=l;
      return true;
    }

    @Override
    public long getCurrentLocation() {
     
      return location;
    }

    @Override
    public void getState(List state) {
      // TODO Auto-generated method stub
     
    }
   
  }
}
TOP

Related Classes of test.apache.kato.common.TestBitMaskMappingArray$MockArrayEntryProvider

TOP
Copyright © 2018 www.massapi.com. 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.