Class: ZipFsDirIteratorTest

Inherits:
MiniTest::Test
  • Object
show all
Defined in:
lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/dir_iterator_test.rb

Constant Summary collapse

FILENAME_ARRAY =
[ "f1", "f2", "f3", "f4", "f5", "f6"  ]

Instance Method Summary collapse

Instance Method Details

#setupObject



8
9
10
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/dir_iterator_test.rb', line 8

def setup
  @dirIt = ::Zip::FileSystem::ZipFsDirIterator.new(FILENAME_ARRAY)
end

#test_closeObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/dir_iterator_test.rb', line 12

def test_close
  @dirIt.close
  assert_raises(IOError, "closed directory") {
    @dirIt.each { |e| p e }
  }
  assert_raises(IOError, "closed directory") {
    @dirIt.read
  }
  assert_raises(IOError, "closed directory") {
    @dirIt.rewind
  }
  assert_raises(IOError, "closed directory") {
    @dirIt.seek(0)
  }
  assert_raises(IOError, "closed directory") {
    @dirIt.tell
  }

end

#test_eachObject



32
33
34
35
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/dir_iterator_test.rb', line 32

def test_each
  # Tested through Enumerable.entries
  assert_equal(FILENAME_ARRAY, @dirIt.entries)
end

#test_readObject



37
38
39
40
41
42
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/dir_iterator_test.rb', line 37

def test_read
  FILENAME_ARRAY.size.times {
    |i|
    assert_equal(FILENAME_ARRAY[i], @dirIt.read)
  }
end

#test_rewindObject



44
45
46
47
48
49
50
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/dir_iterator_test.rb', line 44

def test_rewind
  @dirIt.read
  @dirIt.read
  assert_equal(FILENAME_ARRAY[2], @dirIt.read)
  @dirIt.rewind
  assert_equal(FILENAME_ARRAY[0], @dirIt.read)
end

#test_tell_seekObject



52
53
54
55
56
57
58
59
60
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/dir_iterator_test.rb', line 52

def test_tell_seek
  @dirIt.read
  @dirIt.read
  pos = @dirIt.tell
  valAtPos = @dirIt.read
  @dirIt.read
  @dirIt.seek(pos)
  assert_equal(valAtPos, @dirIt.read)
end