function testDecodeVarintInt() { foreach ($this->tests as $i => $enc) { if (!is_int($i) || $i < 0) { // Skip non-int values continue; } $a = Protobuf::decode_varint_int($enc, strlen($enc)); $this->assertSame($i, $a, "Failed to decode_varint_int(...)={$i}"); } }
function decode_tests() { run("decode_varint", function () { for ($i = 0; $i < LOOPS; $i++) { Protobuf::decode_varint(mt_rand_varint()); } }); run("decode_varint_int", function () { for ($i = 0; $i < LOOPS; $i++) { $v = mt_rand_varint(); Protobuf::decode_varint_int($v, strlen($v)); } }); run("decode_varint_float", function () { for ($i = 0; $i < LOOPS; $i++) { $v = mt_rand_varint(); Protobuf::decode_varint_float($v, strlen($v)); } }); run("decode_varint_bc", function () { for ($i = 0; $i < LOOPS; $i++) { $v = mt_rand_varint(); Protobuf::decode_varint_bc($v, strlen($v)); } }); run("decode_varint_gmp", function () { for ($i = 0; $i < LOOPS; $i++) { $v = mt_rand_varint(); Protobuf::decode_varint_gmp($v, strlen($v)); } }); }