diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-03 16:19:40 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-03 16:19:40 +0000 |
commit | b53cf149ad8d7c46572e4567ca949b4f82ebb22c (patch) | |
tree | ee5032bcb38573dade8ba2c46acbcc0d5f3ddfe3 /spec/ruby/library/socket/shared/pack_sockaddr.rb | |
parent | aeeaadaad08038217440c1e9e7c5ca126d7dc633 (diff) | |
download | ruby-b53cf149ad8d7c46572e4567ca949b4f82ebb22c.tar.gz |
Update to ruby/spec@9be7c7e
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/library/socket/shared/pack_sockaddr.rb')
-rw-r--r-- | spec/ruby/library/socket/shared/pack_sockaddr.rb | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/spec/ruby/library/socket/shared/pack_sockaddr.rb b/spec/ruby/library/socket/shared/pack_sockaddr.rb index 4ffa02a8d8..714becc488 100644 --- a/spec/ruby/library/socket/shared/pack_sockaddr.rb +++ b/spec/ruby/library/socket/shared/pack_sockaddr.rb @@ -18,10 +18,28 @@ describe :socket_pack_sockaddr_in, shared: true do sockaddr_in = Socket.public_send(@method, nil, '127.0.0.1') Socket.unpack_sockaddr_in(sockaddr_in).should == [0, '127.0.0.1'] end + + describe 'using an IPv4 address' do + it 'returns a String of 16 bytes' do + str = Socket.public_send(@method, 80, '127.0.0.1') + + str.should be_an_instance_of(String) + str.bytesize.should == 16 + end + end + + describe 'using an IPv6 address' do + it 'returns a String of 28 bytes' do + str = Socket.public_send(@method, 80, '::1') + + str.should be_an_instance_of(String) + str.bytesize.should == 28 + end + end end describe :socket_pack_sockaddr_un, shared: true do - platform_is_not :windows do + with_feature :unix_socket do it 'should be idempotent' do bytes = Socket.public_send(@method, '/tmp/foo').bytes bytes[2..9].should == [47, 116, 109, 112, 47, 102, 111, 111] @@ -40,10 +58,28 @@ describe :socket_pack_sockaddr_un, shared: true do end end + platform_is :linux do + it 'returns a String of 110 bytes' do + str = Socket.public_send(@method, '/tmp/test.sock') + + str.should be_an_instance_of(String) + str.bytesize.should == 110 + end + end + + platform_is :bsd do + it 'returns a String of 106 bytes' do + str = Socket.public_send(@method, '/tmp/test.sock') + + str.should be_an_instance_of(String) + str.bytesize.should == 106 + end + end + platform_is_not :windows, :aix do - it "raises if path length exceeds max size" do + it "raises ArgumentError for paths that are too long" do # AIX doesn't raise error - long_path = Array.new(512, 0).join + long_path = 'a' * 110 lambda { Socket.public_send(@method, long_path) }.should raise_error(ArgumentError) end end |