From c70b6058eaae4fa5b1af577c548e6809a53dfd98 Mon Sep 17 00:00:00 2001 From: Adam Greene Date: Fri, 1 May 2015 08:54:18 -0700 Subject: add size alias for length starting to make `RepeatedField` quack like an array additional changes: * make sure gemspec gets all ruby code files * add homepage in gem spec removes one of the warnings, and the gem spec authors are pushing everyone to include a homepage in the gem * remove excess whitespace in test suite to bring formatting inline with the rest of the file --- ruby/tests/basic.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'ruby/tests/basic.rb') diff --git a/ruby/tests/basic.rb b/ruby/tests/basic.rb index 1c3fb62c..307374e3 100644 --- a/ruby/tests/basic.rb +++ b/ruby/tests/basic.rb @@ -377,6 +377,18 @@ module BasicTest end end + def test_rptfield_array_ducktyping + l = Google::Protobuf::RepeatedField.new(:int32) + length_methods = %w(count length size) + length_methods.each do |lm| + assert l.send(lm) == 0 + end + l.push 4 + length_methods.each do |lm| + assert l.send(lm) == 1 + end + end + def test_map_basic # allowed key types: # :int32, :int64, :uint32, :uint64, :bool, :string, :bytes. @@ -827,7 +839,6 @@ module BasicTest assert m['a.b'] == 4 end - def test_int_ranges m = TestMessage.new @@ -933,7 +944,6 @@ module BasicTest assert_raise RangeError do m.optional_uint64 = 1.5 end - end def test_stress_test -- cgit v1.2.3