瀏覽代碼

failing test for #2036:

* add a repeated field to the tested hash
* also assert that two messages with identical values produce identical hashes
Brendan Ribera 9 年之前
父節點
當前提交
047419a172
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      ruby/tests/basic.rb

+ 4 - 1
ruby/tests/basic.rb

@@ -183,12 +183,15 @@ module BasicTest
 
     def test_hash
       m1 = TestMessage.new(:optional_int32 => 42)
-      m2 = TestMessage.new(:optional_int32 => 102)
+      m2 = TestMessage.new(:optional_int32 => 102, repeated_string: ['please', 'work', 'ok?'])
+      m3 = TestMessage.new(:optional_int32 => 102, repeated_string: ['please', 'work', 'ok?'])
       assert m1.hash != 0
       assert m2.hash != 0
+      assert m3.hash != 0
       # relying on the randomness here -- if hash function changes and we are
       # unlucky enough to get a collision, then change the values above.
       assert m1.hash != m2.hash
+      assert_equal m2.hash, m3.hash
     end
 
     def test_unknown_field_errors