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.8.5.pre0 spec/lib/protobuf/varint_spec.rb
protobuf-3.8.4 spec/lib/protobuf/varint_spec.rb
protobuf-3.8.3 spec/lib/protobuf/varint_spec.rb
protobuf-3.8.2 spec/lib/protobuf/varint_spec.rb
protobuf-3.8.1 spec/lib/protobuf/varint_spec.rb
protobuf-3.8.0 spec/lib/protobuf/varint_spec.rb
protobuf-3.8.0.pre1 spec/lib/protobuf/varint_spec.rb
protobuf-3.7.5 spec/lib/protobuf/varint_spec.rb
protobuf-3.7.4 spec/lib/protobuf/varint_spec.rb
protobuf-3.7.3 spec/lib/protobuf/varint_spec.rb
protobuf-3.7.2 spec/lib/protobuf/varint_spec.rb
protobuf-3.7.2.pre1 spec/lib/protobuf/varint_spec.rb
protobuffy-4.0.1 spec/lib/protobuf/varint_spec.rb
protobuf-3.7.1 spec/lib/protobuf/varint_spec.rb
protobuf-3.7.0 spec/lib/protobuf/varint_spec.rb
protobuf-3.7.0.pre3 spec/lib/protobuf/varint_spec.rb
protobuffy-4.0.0 spec/lib/protobuf/varint_spec.rb