Sha256: 275aa49fc6a91e0d4d9a69b2245d6b267db50b0e5d157ef671df1d47f297f689

Contents?: true

Size: 1.1 KB

Versions: 10

Compression:

Stored size: 1.1 KB

Contents

########################################################################
# test_aref.rb
#
# Test suite for the Pathname#[] method.
########################################################################
require 'test-unit'
require 'pathname2'

class TC_Pathname_Aref < Test::Unit::TestCase
  def setup
    @path = Pathname.new("C:/Program Files/Windows NT/Accessories")
  end

  test "[] with index works as expected" do
    assert_equal("C:", @path[0])
    assert_equal("Program Files", @path[1])
    assert_equal("Accessories", @path[-1])
    assert_nil(@path[10])
  end

  test "[] with range argument works as expected" do
    assert_equal("C:\\Program Files", @path[0..1])
    assert_equal("C:\\Program Files\\Windows NT", @path[0..2])
    assert_equal("Program Files\\Windows NT", @path[1..2])
    #assert_equal(@path, @path[0..-1]) # TODO: Spews tons of warnings
  end

  test "[] with index and length works as expected" do
    assert_equal("C:", @path[0,1])
    assert_equal("C:\\Program Files", @path[0,2])
    assert_equal("Program Files\\Windows NT", @path[1,2])
  end

  def teardown
    @path = nil
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pathname2-1.8.4 test/windows/test_aref.rb
pathname2-1.8.3 test/windows/test_aref.rb
pathname2-1.8.2 test/windows/test_aref.rb
pathname2-1.8.1 test/windows/test_aref.rb
pathname2-1.8.0 test/windows/test_aref.rb
pathname2-1.7.4 test/windows/test_aref.rb
pathname2-1.7.3 test/windows/test_aref.rb
pathname2-1.7.2 test/windows/test_aref.rb
pathname2-1.7.1 test/windows/test_aref.rb
pathname2-1.7.0 test/windows/test_aref.rb