Sha256: 8550731d53f5871f8c89d8813c70919aacdc1a0546d2f107475ed64128cdd0e5

Contents?: true

Size: 860 Bytes

Versions: 52

Compression:

Stored size: 860 Bytes

Contents

# -*- encoding: ascii-8bit -*-
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)
require File.expand_path('../shared/basic', __FILE__)
require File.expand_path('../shared/string', __FILE__)

describe "String#unpack with format 'Z'" do
  it_behaves_like :string_unpack_basic, 'Z'
  it_behaves_like :string_unpack_no_platform, 'Z'
  it_behaves_like :string_unpack_string, 'Z'

  it "stops decoding at NULL bytes when passed the '*' modifier" do
    "a\x00\x00 b \x00c".unpack('Z*Z*Z*Z*').should == ["a", "", " b ", "c"]
  end

  it "decodes the number of bytes specified by the count modifier and truncates the decoded string at the first NULL byte" do
    [ ["a\x00 \x00b c",      ["a", " "]],
      ["\x00a\x00 bc \x00",  ["", "c"]]
    ].should be_computed_by(:unpack, "Z5Z")
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-7.5.1 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-7.4.1 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-7.1.17 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-6.2.0 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-6.0.11 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-5.5.18 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-5.5.17 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-5.5.15 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-5.5.2 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-5.5.0 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-3.5.1.12 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-3.3.5 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb
rhodes-3.4.2 spec/framework_spec/app/spec/core/string/unpack/z_spec.rb