Example #1
0
 /**
  * Return an unsigned byte from the data.
  *
  * @param
  *            int the offset into the data. An offset of zero will
  *            return the first byte in the current allowed window. The last
  *            valid offset is equal to {@link getSize()}-1. Invalid offsets
  *            will result in a {@link PelDataWindowOffsetException} being
  *            thrown.
  *
  * @return int the unsigned byte found at offset.
  */
 public function getByte($o = 0)
 {
     /*
      * Validate the offset --- this throws an exception if offset is
      * out of range.
      */
     $this->validateOffset($o);
     /* Translate the offset into an offset into the data. */
     $o += $this->start;
     /* Return an unsigned byte. */
     return PelConvert::bytesToByte($this->data, $o);
 }
 function testByte()
 {
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 0), 0x0);
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 1), 0x0);
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 2), 0x0);
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 3), 0x0);
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 4), 0x1);
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 5), 0x23);
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 6), 0x45);
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 7), 0x67);
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 8), 0x89);
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 9), 0xab);
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 10), 0xcd);
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 11), 0xef);
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 12), 0xff);
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 13), 0xff);
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 14), 0xff);
     $this->assertEqual(PelConvert::bytesToByte($this->bytes, 15), 0xff);
 }