Sha256: de2ba3aa20028a3183716b22af33e9768358175716acd4d99c9147aa8fe54cb9

Contents?: true

Size: 911 Bytes

Versions: 4

Compression:

Stored size: 911 Bytes

Contents

describe :socket_pack_sockaddr_in, :shared => true do
  it "packs and unpacks" do
    sockaddr_in = Socket.pack_sockaddr_in 0, nil
    port, addr = Socket.unpack_sockaddr_in(sockaddr_in)
    ["127.0.0.1", "::1"].include?(addr).should == true
    port.should == 0

    sockaddr_in = Socket.pack_sockaddr_in 0, ''
    Socket.unpack_sockaddr_in(sockaddr_in).should == [0, '0.0.0.0']

    sockaddr_in = Socket.pack_sockaddr_in 80, '127.0.0.1'
    Socket.unpack_sockaddr_in(sockaddr_in).should == [80, '127.0.0.1']

    sockaddr_in = Socket.pack_sockaddr_in '80', '127.0.0.1'
    Socket.unpack_sockaddr_in(sockaddr_in).should == [80, '127.0.0.1']
  end
end

describe :socket_pack_sockaddr_un, :shared => true do
  not_supported_on :jruby, :windows do
    it "packs and unpacks" do
      sockaddr_un = Socket.pack_sockaddr_un '/tmp/s'
      Socket.unpack_sockaddr_un(sockaddr_un).should == '/tmp/s'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubysl-socket-1.0.1 spec/shared/pack_sockaddr.rb
rubysl-socket-2.0.1 spec/shared/pack_sockaddr.rb
rubysl-socket-1.0.0 spec/shared/pack_sockaddr.rb
rubysl-socket-2.0.0 spec/shared/pack_sockaddr.rb