Sha256: 63fe6bcd444502dc25f85057824ab15ef5bfdc7ff5a6bf32205beea11a995c66

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

RSpec.describe Protobuf::Field::Uint64Field do

  it_behaves_like :packable_field, described_class

  let(:message) do
    Class.new(::Protobuf::Message) do
      optional :uint64, :some_field, 1
    end
  end

  # https://developers.google.com/protocol-buffers/docs/proto3#json
  describe '.{to_json, from_json}' do
    it 'serialises 0' do
      instance = message.new(some_field: 0)
      expect(instance.to_json(proto3: true)).to eq('{}')
      expect(instance.to_json).to eq('{"some_field":0}')
    end

    it 'serialises max value' do
      instance = message.new(some_field: described_class.max)
      expect(instance.to_json(proto3: true)).to eq('{"someField":"18446744073709551615"}')
      expect(instance.to_json).to eq('{"some_field":18446744073709551615}')
    end

    it 'serialises min value' do
      instance = message.new(some_field: described_class.min)
      expect(instance.to_json(proto3: true)).to eq('{}')
      expect(instance.to_json).to eq('{"some_field":0}')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
protobuf-cucumber-3.10.8 spec/lib/protobuf/field/uint64_field_spec.rb
protobuf-cucumber-3.10.7 spec/lib/protobuf/field/uint64_field_spec.rb
protobuf-cucumber-3.10.6 spec/lib/protobuf/field/uint64_field_spec.rb
protobuf-cucumber-3.10.5 spec/lib/protobuf/field/uint64_field_spec.rb