Sha256: eb6a29c13af017b3a7b255cbff169dbe1629a374074de11b0e03d172a2fe890d

Contents?: true

Size: 930 Bytes

Versions: 8

Compression:

Stored size: 930 Bytes

Contents

require 'spec_helper'

require 'berkeley_library/util/stringios'

module BerkeleyLibrary
  module Util
    describe StringIOs do
      describe :getbyte do
        let(:s) { '祇園精舎の鐘の声、諸行無常の響きあり。' }
        let(:bytes) { s.bytes }
        let(:sio) { StringIO.new(s) }

        it 'gets the byte at the specified byte index' do
          bytes.each_with_index do |b, i|
            expect(StringIOs.getbyte(sio, i)).to eq(b)
          end
        end

        it 'resets the current offset' do
          StringIOs.getbyte(sio, bytes.size / 2)
          expect(sio.pos).to eq(0)
        end

        it 'returns nil for a too-large positive offset' do
          expect(StringIOs.getbyte(s, bytes.size)).to be_nil
        end

        it 'returns nil for a too-large negative offset' do
          expect(StringIOs.getbyte(s, -(1 + bytes.size))).to be_nil
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
berkeley_library-util-0.1.5 spec/berkeley_library/util/stringios_spec.rb
berkeley_library-util-0.1.4 spec/berkeley_library/util/stringios_spec.rb
berkeley_library-util-0.1.3 spec/berkeley_library/util/stringios_spec.rb
berkeley_library-util-0.1.2 spec/berkeley_library/util/stringios_spec.rb
berkeley_library-util-0.1.1 spec/berkeley_library/util/stringios_spec.rb
berkeley_library-util-0.1.0 spec/berkeley_library/util/stringios_spec.rb
berkeley_library-tind-0.4.1 spec/berkeley_library/util/stringios_spec.rb
berkeley_library-tind-0.4.0 spec/berkeley_library/util/stringios_spec.rb