public function testVarIntTooLarge() { //more than 5 bytes = failure //bin - 1000 0000 1000 0000 1000 0000 1000 0000 1000 0000 1000 0000 //hex - 0x808080808080 $data = hex2bin('808080808080'); $this->setExpectedException('\\PublicUHC\\MinecraftAuth\\ReactServer\\InvalidDataException'); VarInt::readUnsignedVarInt($data); }
public function variableArray($name, $min, $max, $size) { foreach (range(1, $size) as $i) { $var = new VarInt(); $var->setName("name[{$i}]"); $var->setValue(range($min, $max)); $var->setDomainType(DomainType::DOMAIN_MIN_MAX); $this->add($var); } }
public static function write($data) { $stringLength = strlen($data); $stringLengthVarInt = VarInt::writeUnsignedVarInt($stringLength); return new StringType($data, $stringLengthVarInt->getEncoded() . $data, $stringLengthVarInt->getDataLength() + $stringLength); }