function testEncodeVarintIntSlide() { foreach ($this->tests as $i => $enc) { if (!is_int($i) || $i < 0) { continue; } // Only test positive ints $result = Protobuf::encode_varint_slide($i); $this->assertBinaryEqual($enc, $result, "Failed to encode_varint_slide({$i})"); } }
function encode_tests() { run("encode_varint_int", function () { for ($i = 0; $i < LOOPS; $i++) { Protobuf::encode_varint_int(mt_rand()); } }); run("encode_varint_slide", function () { for ($i = 0; $i < LOOPS; $i++) { Protobuf::encode_varint_slide(mt_rand()); } }); run("encode_varint_float", function () { for ($i = 0; $i < LOOPS; $i++) { Protobuf::encode_varint_float(mt_rand()); } }); run("encode_varint_bc", function () { for ($i = 0; $i < LOOPS; $i++) { Protobuf::encode_varint_float(mt_rand()); } }); run("encode_varint_gmp", function () { for ($i = 0; $i < LOOPS; $i++) { Protobuf::encode_varint_float(mt_rand()); } }); run("encode_varint", function () { for ($i = 0; $i < LOOPS; $i++) { Protobuf::encode_varint(mt_rand()); } }); run("encode_neg_varint", function () { for ($i = 0; $i < LOOPS; $i++) { Protobuf::encode_varint(-mt_rand()); } }); }