Permalink
Browse files

Fixed bin_encode test that failed after 64bit fixes. Fixed class typo…

… in Protocol.
  • Loading branch information...
1 parent be6efed commit 6fe9932fab345a033cc854bf41f062312812959d @andygrundman andygrundman committed with David Bushong Feb 1, 2011
Showing with 7 additions and 9 deletions.
  1. +1 −3 README
  2. +4 −4 lib/Avro/BinaryEncoder.pm
  3. +2 −2 lib/Avro/Protocol.pm
View
4 README
@@ -1,12 +1,10 @@
NAME
- Avro -
+ Avro - Modern Data Serializer
SYNOPSIS
use Avro;
DESCRIPTION
- Avro is
-
AUTHOR
Yann Kerherve <yannk@cpank.org>
@@ -72,8 +72,8 @@ sub encode_boolean {
sub encode_int {
my $class = shift;
my ($schema, $data, $cb) = @_;
- if (abs($data) > 0x7fffffff) {
- throw Avro::BinaryEncoder::Error("int should be 32bits");
+ if ($data !~ /^-?\d+$/ || abs($data) > 0x7fffffff) {
+ throw Avro::BinaryEncoder::Error("int ($data) should be <= 32bits");
}
my $enc = unsigned_varint(zigzag($data));
@@ -83,8 +83,8 @@ sub encode_int {
sub encode_long {
my $class = shift;
my ($schema, $data, $cb) = @_;
- if (abs($data) > $max64) {
- throw Avro::BinaryEncoder::Error("int should be 64bits");
+ if ($data !~ /^-?\d+$/ || abs($data) > $max64) {
+ throw Avro::BinaryEncoder::Error("int ($data) should be <= 64bits");
}
my $enc = unsigned_varint(zigzag($data));
$cb->(\$enc);
View
@@ -27,7 +27,7 @@ sub parse {
$json->decode($enc_proto);
}
catch {
- throw Avro::Proto::Error::Parse(
+ throw Avro::Protocol::Error::Parse(
"Cannot parse json string: $_"
);
};
@@ -39,7 +39,7 @@ sub from_struct {
my $struct = shift || {};
my $name = $struct->{protocol};
unless (defined $name or length $name) {
- throw Avro::Proto::Error::Parse("protocol name is required");
+ throw Avro::Protocol::Error::Parse("protocol name is required");
}
my $types = $class->parse_types($struct->{types});

0 comments on commit 6fe9932

Please sign in to comment.