예제 #1
0
 function testEncodeVarintGMP()
 {
     foreach ($this->tests as $i => $enc) {
         if ($i < 0) {
             continue;
         }
         // Only test positive values
         $result = Protobuf::encode_varint_gmp($i);
         $this->assertBinaryEqual($enc, $result, "Failed to encode_varint_gmp({$i})");
     }
     try {
         Protobuf::encode_varint_gmp("bob");
         $this->fail("Exception should have been thrown");
     } catch (InvalidArgumentException $e) {
     }
     try {
         $result = Protobuf::encode_varint_gmp("-1");
         $this->fail("Exception should have been thrown");
     } catch (InvalidArgumentException $e) {
     }
     try {
         $result = Protobuf::encode_varint_gmp(-1);
         $this->fail("Exception should have been thrown");
     } catch (InvalidArgumentException $e) {
     }
     try {
         $result = Protobuf::encode_varint_gmp("18446744073709551616");
         $this->fail("Exception should have been thrown");
     } catch (InvalidArgumentException $e) {
     }
 }