FileDocCategorySizeDatePackage
TestPlexOfCps.javaAPI DocApache Poi 3.0.12498Mon Jan 01 18:55:36 GMT 2007org.apache.poi.hwpf.model

TestPlexOfCps

public class TestPlexOfCps extends TestCase

Fields Summary
private PlexOfCps
_plexOfCps
private HWPFDocFixture
_hWPFDocFixture
Constructors Summary
public TestPlexOfCps(String name)


    
  
    super(name);
  
Methods Summary
protected voidsetUp()

    super.setUp();
    /**@todo verify the constructors*/
    _hWPFDocFixture = new HWPFDocFixture(this);

    _hWPFDocFixture.setUp();
  
protected voidtearDown()

    _plexOfCps = null;
    _hWPFDocFixture.tearDown();

    _hWPFDocFixture = null;
    super.tearDown();
  
public voidtestWriteRead()

    _plexOfCps = new PlexOfCps(4);

    int last = 0;
    for (int x = 0; x < 110; x++)
    {
      byte[] intHolder = new byte[4];
      int span = (int)(110.0f * Math.random());
      LittleEndian.putInt(intHolder, span);
      _plexOfCps.addProperty(new GenericPropertyNode(last, last + span, intHolder));
      last += span;
    }

    byte[] output = _plexOfCps.toByteArray();
    _plexOfCps = new PlexOfCps(output, 0, output.length, 4);
    int len = _plexOfCps.length();
    assertEquals(len, 110);

    last = 0;
    for (int x = 0; x < len; x++)
    {
      GenericPropertyNode node = _plexOfCps.getProperty(x);
      assertEquals(node.getStart(), last);
      last = node.getEnd();
      int span = LittleEndian.getInt(node.getBytes());
      assertEquals(node.getEnd()-node.getStart(), span);
    }