diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/net/ftp/test_buffered_socket.rb | 2 | ||||
-rw-r--r-- | test/net/ftp/test_mlsx_entry.rb | 96 |
2 files changed, 97 insertions, 1 deletions
diff --git a/test/net/ftp/test_buffered_socket.rb b/test/net/ftp/test_buffered_socket.rb index f9eefcd988..8d7cc2ed52 100644 --- a/test/net/ftp/test_buffered_socket.rb +++ b/test/net/ftp/test_buffered_socket.rb @@ -3,7 +3,7 @@ require "test/unit" require "ostruct" require "stringio" -class FTPTest < Test::Unit::TestCase +class BufferedSocketTest < Test::Unit::TestCase def test_gets_empty sock = create_buffered_socket("") assert_equal(nil, sock.gets) diff --git a/test/net/ftp/test_mlsx_entry.rb b/test/net/ftp/test_mlsx_entry.rb new file mode 100644 index 0000000000..865cf911b9 --- /dev/null +++ b/test/net/ftp/test_mlsx_entry.rb @@ -0,0 +1,96 @@ +require "net/ftp" +require "test/unit" +require "ostruct" +require "stringio" + +class MLSxEntryTest < Test::Unit::TestCase + def test_file? + assert_equal(true, Net::FTP::MLSxEntry.new({"type"=>"file"}, "foo").file?) + assert_equal(false, Net::FTP::MLSxEntry.new({"type"=>"dir"}, "foo").file?) + assert_equal(false, Net::FTP::MLSxEntry.new({"type"=>"cdir"}, "foo").file?) + assert_equal(false, Net::FTP::MLSxEntry.new({"type"=>"pdir"}, "foo").file?) + end + + def test_directory? + assert_equal(false, + Net::FTP::MLSxEntry.new({"type"=>"file"}, "foo").directory?) + assert_equal(true, + Net::FTP::MLSxEntry.new({"type"=>"dir"}, "foo").directory?) + assert_equal(true, + Net::FTP::MLSxEntry.new({"type"=>"cdir"}, "foo").directory?) + assert_equal(true, + Net::FTP::MLSxEntry.new({"type"=>"pdir"}, "foo").directory?) + end + + def test_appendable? + assert_equal(true, + Net::FTP::MLSxEntry.new({"perm"=>"a"}, "foo").appendable?) + assert_equal(false, + Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").appendable?) + end + + def test_creatable? + assert_equal(true, + Net::FTP::MLSxEntry.new({"perm"=>"c"}, "foo").creatable?) + assert_equal(false, + Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").creatable?) + end + + def test_deletable? + assert_equal(true, + Net::FTP::MLSxEntry.new({"perm"=>"d"}, "foo").deletable?) + assert_equal(false, + Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").deletable?) + end + + def test_enterable? + assert_equal(true, + Net::FTP::MLSxEntry.new({"perm"=>"e"}, "foo").enterable?) + assert_equal(false, + Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").enterable?) + end + + def test_renamable? + assert_equal(true, + Net::FTP::MLSxEntry.new({"perm"=>"f"}, "foo").renamable?) + assert_equal(false, + Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").renamable?) + end + + def test_listable? + assert_equal(true, + Net::FTP::MLSxEntry.new({"perm"=>"l"}, "foo").listable?) + assert_equal(false, + Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").listable?) + end + + def test_directory_makable? + assert_equal(true, + Net::FTP::MLSxEntry.new({"perm"=>"m"}, "foo"). + directory_makable?) + assert_equal(false, + Net::FTP::MLSxEntry.new({"perm"=>""}, "foo"). + directory_makable?) + end + + def test_purgeable? + assert_equal(true, + Net::FTP::MLSxEntry.new({"perm"=>"p"}, "foo").purgeable?) + assert_equal(false, + Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").purgeable?) + end + + def test_readable? + assert_equal(true, + Net::FTP::MLSxEntry.new({"perm"=>"r"}, "foo").readable?) + assert_equal(false, + Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").readable?) + end + + def test_writable? + assert_equal(true, + Net::FTP::MLSxEntry.new({"perm"=>"w"}, "foo").writable?) + assert_equal(false, + Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").writable?) + end +end |