Sha256: d0f052e373214948a41207fe48a2e88f548f56954cfe241837f6b9d60fc5ac1a

Contents?: true

Size: 737 Bytes

Versions: 29

Compression:

Stored size: 737 Bytes

Contents

require 'spec_helper'

describe 'String#unpack' do
  it 'correctly unpacks with U* strings with latin-1 characters' do
    'café'.unpack('U*').should == [99, 97, 102, 233]
    [99, 97, 102, 233].pack('U*').unpack('U*').should == [99, 97, 102, 233]
  end

  it 'correctly unpacks with U* strings with latin-2 characters' do
    'pół'.unpack('U*').should == [112, 243, 322]
    [112, 243, 322].pack('U*').unpack('U*').should == [112, 243, 322]
  end

  it 'correctly unpacks with c* strings with latin-2 characters' do
    'ść'.unpack('c*').should == [-59, -101, -60, -121]
  end

  it 'correctly unpacks with s* binary strings' do
    "\xc8\x01".unpack('s*').should == [456]
    [678].pack('s').unpack('s').should == [678]
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
opal-1.8.3.rc1 spec/opal/core/string/unpack_spec.rb
opal-1.8.2 spec/opal/core/string/unpack_spec.rb
opal-1.8.1 spec/opal/core/string/unpack_spec.rb
opal-1.8.0 spec/opal/core/string/unpack_spec.rb
opal-1.8.0.beta1 spec/opal/core/string/unpack_spec.rb
opal-1.7.4 spec/opal/core/string/unpack_spec.rb
opal-1.8.0.alpha1 spec/opal/core/string/unpack_spec.rb
opal-1.7.3 spec/opal/core/string/unpack_spec.rb
opal-1.7.2 spec/opal/core/string/unpack_spec.rb
opal-1.7.1 spec/opal/core/string/unpack_spec.rb
opal-1.7.0 spec/opal/core/string/unpack_spec.rb
opal-1.7.0.rc1 spec/opal/core/string/unpack_spec.rb
opal-1.6.1 spec/opal/core/string/unpack_spec.rb
opal-1.6.0 spec/opal/core/string/unpack_spec.rb
opal-1.6.0.rc1 spec/opal/core/string/unpack_spec.rb
opal-1.6.0.alpha1 spec/opal/core/string/unpack_spec.rb
opal-1.5.1 spec/opal/core/string/unpack_spec.rb
opal-1.5.0 spec/opal/core/string/unpack_spec.rb
opal-1.5.0.rc1 spec/opal/core/string/unpack_spec.rb
opal-1.4.1 spec/opal/core/string/unpack_spec.rb