Sha256: 5c4f1676bbaeba8733239e86117f66b86c77bbacdfb1e90fa0d2b37f632b05bf

Contents?: true

Size: 793 Bytes

Versions: 37

Compression:

Stored size: 793 Bytes

Contents

require 'base64'
require 'spec_helper'

RSpec.describe Protobuf::Varint do
  VALUES = {
    0 => "AA==",
    5 => "BQ==",
    51 => "Mw==",
    9_192 => "6Ec=",
    80_389 => "hfQE",
    913_389 => "7d83",
    516_192_829_912_693 => "9eyMkpivdQ==",
    9_999_999_999_999_999_999 => "//+fz8jgyOOKAQ==",
  }.freeze

  [defined?(::Varint) ? ::Varint : nil, Protobuf::VarintPure].compact.each do |klass|
    context "with #{klass}" do
      before { described_class.extend(klass) }
      after { load ::File.expand_path('../../../../lib/protobuf/varint.rb', __FILE__) }

      VALUES.each do |number, encoded|
        it "decodes #{number}" do
          io = StringIO.new(Base64.decode64(encoded))
          expect(described_class.decode(io)).to eq(number)
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 3 rubygems

Version Path
protobuf-3.10.9 spec/lib/protobuf/varint_spec.rb
protobuf-3.10.8 spec/lib/protobuf/varint_spec.rb
protobuf-3.10.7 spec/lib/protobuf/varint_spec.rb
protobuf-3.10.6 spec/lib/protobuf/varint_spec.rb
protobuf-3.10.5 spec/lib/protobuf/varint_spec.rb
protobuf-3.10.4 spec/lib/protobuf/varint_spec.rb
protobuf-cucumber-3.10.8 spec/lib/protobuf/varint_spec.rb
protobuf-cucumber-3.10.7 spec/lib/protobuf/varint_spec.rb
protobuf-cucumber-3.10.6 spec/lib/protobuf/varint_spec.rb
protobuf-cucumber-3.10.5 spec/lib/protobuf/varint_spec.rb
protobuf-cucumber-3.10.4 spec/lib/protobuf/varint_spec.rb
protobuf-3.10.3 spec/lib/protobuf/varint_spec.rb
protobuf-3.10.2 spec/lib/protobuf/varint_spec.rb
protobuf-3.10.1 spec/lib/protobuf/varint_spec.rb
protobuf-3.10.0 spec/lib/protobuf/varint_spec.rb
protobuf-3.10.0.pre0 spec/lib/protobuf/varint_spec.rb
protobuf-3.9.0 spec/lib/protobuf/varint_spec.rb
protobuf-3.9.0.pre2 spec/lib/protobuf/varint_spec.rb
protobuf-3.9.0.pre spec/lib/protobuf/varint_spec.rb
protobuf-3.8.5 spec/lib/protobuf/varint_spec.rb