[protobuf-perl commit] r161 - trunk/perl/t

0 views
Skip to first unread message

codesite...@google.com

unread,
Aug 1, 2008, 5:56:03 PM8/1/08
to protobuf-p...@googlegroups.com
Author: nothi...@woobling.org
Date: Fri Aug 1 14:55:50 2008
New Revision: 161

Modified:
trunk/perl/t/parse-from-string.t

Log:
failing test for roundtripping of unknown field

Modified: trunk/perl/t/parse-from-string.t
==============================================================================
--- trunk/perl/t/parse-from-string.t (original)
+++ trunk/perl/t/parse-from-string.t Fri Aug 1 14:55:50 2008
@@ -119,3 +119,36 @@
is($p->stats->misses, 8);
is($p->stats->oldest_item_age, 257);
}
+
+# unknown fields
+{
+ my $i1 = AppEngine::Service::MemcacheGetResponse::Item->new;
+ $i1->set_key("key1");
+ $i1->set_value("value1");
+ $i1->set_flags(123);
+
+ # a field not in the .proto
+ $i1->merge_from_string("(\x01");
+
+ is($i1->key, "key1", "key unchanged");
+ is($i1->value, "value1", "value unchanged");
+ is($i1->flags, 123, "flags unchanged");
+
+ my $meta = Class::MOP::Class->initialize(ref $i1);
+
+ my @attrs = $meta->protobuf_attributes;
+
+ ok(my $events = Protobuf::Decoder->decode($i1->serialize_to_string));
+
+ my %by_field = map { delete $_->{fieldnum} => $_ } @$events;
+ is( scalar keys %by_field, 4, "four events" );
+
+ is( @attrs, 3, "three attrs" );
+
+ foreach my $attr ( @attrs ) {
+ ok( $by_field{$attr->field->number}, "data for " .
$attr->name . " exists in output" );
+ }
+
+ ok( $by_field{5}, "field 5 set" );
+}
+

Reply all
Reply to author
Forward
0 new messages