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)); } }); }
function testDecodeVarintBC() { foreach ($this->tests as $i => $enc) { if ($i < 0) { continue; } $a = Protobuf::decode_varint_bc($enc, strlen($enc)); $this->assertSame((string) $i, $a, "Failed to decode_varint_bc(...)={$i}"); } }