Created
August 30, 2016 21:45
-
-
Save abscondment/d8254d4482c024ad06a7e683c690ff98 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'grpc', '~> 1.0.0' | |
# prerelease protobuf magic | |
git '[email protected]:google/protobuf.git', tag: 'v3.0.0' do | |
gem 'google-protobuf' | |
end | |
group :development, :test do | |
gem 'rake', '~> 10.5.0' | |
gem 'grpc-tools', '~> 1.0.0' | |
end | |
group :test do | |
gem 'minitest', '~> 5.9.0' | |
gem 'simplecov', '~> 0.12.0' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
require 'protobuf_bug' | |
class HashTest < MiniTest::Test | |
def setup | |
@names = %w{There are many words and I will use some of them} | |
@single_values = @names.each_with_index.map do |name, id| | |
ProtobufBug::SingleValues.new(name: name, id: id) | |
end | |
end | |
def test_single_values_hash | |
@single_values.each do |pb| | |
assert_kind_of Fixnum, pb.hash, format('<%d>%s must hash properly', pb.id, pb.name) | |
end | |
end | |
def test_repeated_values_hash | |
@names.each do |name| | |
(2...@single_values.size).each do |n| | |
@single_values.combination(n).each_with_index do |values, m| | |
pb = ProtobufBug::RepeatedValues.new( | |
name: format('%s<%d/%d>', name, n, m), | |
values: values | |
) | |
assert_kind_of Fixnum, pb.hash, format('%s must hash properly', pb.name) | |
end | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax = "proto3"; | |
package ProtobufBug; | |
message SingleValues { | |
uint32 id = 1; | |
string name = 2; | |
} | |
message RepeatedValues { | |
string name = 1; | |
repeated SingleValues values = 2; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated by the protocol buffer compiler. DO NOT EDIT! | |
# source: protobuf_bug.proto | |
require 'google/protobuf' | |
Google::Protobuf::DescriptorPool.generated_pool.build do | |
add_message "ProtobufBug.SingleValues" do | |
optional :id, :uint32, 1 | |
optional :name, :string, 2 | |
end | |
add_message "ProtobufBug.RepeatedValues" do | |
optional :name, :string, 1 | |
repeated :values, :message, 2, "ProtobufBug.SingleValues" | |
end | |
end | |
module ProtobufBug | |
SingleValues = Google::Protobuf::DescriptorPool.generated_pool.lookup("ProtobufBug.SingleValues").msgclass | |
RepeatedValues = Google::Protobuf::DescriptorPool.generated_pool.lookup("ProtobufBug.RepeatedValues").msgclass | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment