Class: AbstractInputStreamTest
- Inherits:
-
MiniTest::Test
- Object
- MiniTest::Test
- AbstractInputStreamTest
show all
- Defined in:
- lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_input_stream_test.rb
Defined Under Namespace
Classes: TestAbstractInputStream
Constant Summary
collapse
- TEST_LINES =
AbstractInputStream subclass that provides a read method
["Hello world#{$/}",
"this is the second line#{$/}",
"this is the last line"]
- TEST_STRING =
TEST_LINES.join
- LONG_LINES =
[
'x'*48 + "\r\n",
'y'*49 + "\r\n",
'rest',
]
Instance Method Summary
collapse
Instance Method Details
#test_each_line ⇒ Object
82
83
84
85
86
87
88
89
|
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_input_stream_test.rb', line 82
def test_each_line
lineNumber=0
@io.each_line {
|line|
assert_equal(TEST_LINES[lineNumber], line)
lineNumber+=1
}
end
|
#test_gets ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_input_stream_test.rb', line 39
def test_gets
assert_equal(TEST_LINES[0], @io.gets)
assert_equal(1, @io.lineno)
assert_equal(TEST_LINES[0].length, @io.pos)
assert_equal(TEST_LINES[1], @io.gets)
assert_equal(2, @io.lineno)
assert_equal(TEST_LINES[2], @io.gets)
assert_equal(3, @io.lineno)
assert_equal(nil, @io.gets)
assert_equal(4, @io.lineno)
end
|
#test_getsMulitCharSeperator_split ⇒ Object
62
63
64
65
66
67
|
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_input_stream_test.rb', line 62
def test_getsMulitCharSeperator_split
io = TestAbstractInputStream.new(LONG_LINES.join)
assert_equal(LONG_LINES[0], io.gets("\r\n"))
assert_equal(LONG_LINES[1], io.gets("\r\n"))
assert_equal(LONG_LINES[2], io.gets("\r\n"))
end
|
#test_getsMultiCharSeperator ⇒ Object
51
52
53
54
|
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_input_stream_test.rb', line 51
def test_getsMultiCharSeperator
assert_equal("Hell", @io.gets("ll"))
assert_equal("o world#{$/}this is the second l", @io.gets("d l"))
end
|
#test_getsWithIndex ⇒ Object
77
78
79
80
|
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_input_stream_test.rb', line 77
def test_getsWithIndex
assert_equal(TEST_LINES[0], @io.gets(100))
assert_equal('this', @io.gets(4))
end
|
#test_getsWithSepAndIndex ⇒ Object
69
70
71
72
73
74
75
|
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_input_stream_test.rb', line 69
def test_getsWithSepAndIndex
io = TestAbstractInputStream.new(LONG_LINES.join)
assert_equal('x', io.gets("\r\n", 1))
assert_equal('x'*47 + "\r", io.gets("\r\n", 48))
assert_equal("\n", io.gets(nil, 1))
assert_equal('yy', io.gets(nil, 2))
end
|
#test_readline ⇒ Object
95
96
97
98
99
100
101
102
|
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_input_stream_test.rb', line 95
def test_readline
test_gets
begin
@io.readline
fail "EOFError expected"
rescue EOFError
end
end
|
#test_readlines ⇒ Object
91
92
93
|
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_input_stream_test.rb', line 91
def test_readlines
assert_equal(TEST_LINES, @io.readlines)
end
|