2 # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
4 # See LICENSE.txt for permissions.
7 require File.join(File.expand_path(File.dirname(__FILE__)),
8 'gem_package_tar_test_case')
9 require 'rubygems/package'
11 class TestGemPackageTarReaderEntry < TarTestCase
16 @contents = ('a'..'z').to_a.join * 100
19 @tar << tar_file_header("lib/foo", "", 0, @contents.size)
21 @tar << "\0" * (512 - (@tar.size % 512))
23 @entry = util_entry @tar
27 assert_equal 0, @entry.bytes_read
31 assert_equal 1, @entry.bytes_read
37 assert @entry.bytes_read
39 e = assert_raise IOError do @entry.eof? end
40 assert_equal 'closed Gem::Package::TarReader::Entry', e.message
42 e = assert_raise IOError do @entry.getc end
43 assert_equal 'closed Gem::Package::TarReader::Entry', e.message
45 e = assert_raise IOError do @entry.pos end
46 assert_equal 'closed Gem::Package::TarReader::Entry', e.message
48 e = assert_raise IOError do @entry.read end
49 assert_equal 'closed Gem::Package::TarReader::Entry', e.message
51 e = assert_raise IOError do @entry.rewind end
52 assert_equal 'closed Gem::Package::TarReader::Entry', e.message
68 assert_equal 'lib/foo', @entry.full_name
72 assert_equal ?a, @entry.getc
76 assert_equal false, @entry.directory?
77 assert_equal true, util_dir_entry.directory?
81 assert_equal true, @entry.file?
82 assert_equal false, util_dir_entry.file?
86 assert_equal 0, @entry.pos
90 assert_equal 1, @entry.pos
94 assert_equal @contents, @entry.read
98 assert_equal @contents, @entry.read(@contents.size * 2)
102 assert_equal @contents[0...100], @entry.read(100)
110 assert_equal 0, @entry.pos
112 assert_equal char, @entry.getc