public function testDecodeSimpleMessageComparingTypesWithProtoc($field, $value)
{
$escaped = $value;
$proto = 'simple';
$getter = 'get' . ucfirst($field);
$class = 'ProtobufTest.Protos.Simple';
if (is_string($value)) {
$escaped = '"' . $value . '"';
}
if ($value instanceof \Protobuf\Stream) {
$tell = $value->tell();
$escaped = '"' . $value . '"';
$value->seek($tell);
}
$binary = $this->executeProtoc("{$field}: {$escaped}", $class, $proto);
$message = Simple::fromStream(Stream::wrap($binary));
$result = $message->{$getter}();
// Hack the comparison for float precision
if (is_float($value)) {
$precision = strlen($value) - strpos($value, '.');
$result = round($result, $precision);
}
if ($result instanceof \Protobuf\Stream) {
$result = (string) $result;
}
$this->assertEquals($value, $result, "Decoding {$field} with value {$value}");
}