Class: TestLineText2
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- TestLineText2
show all
- Defined in:
- lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb
Overview
TODO!!! Need tests for overlength headers and text bodies.
Defined Under Namespace
Classes: Basic, Binary, BinaryPair, BinaryTail, ChangeDelimiter, LazyBinary, Multichar, ThrowBack, UnsizedBinary
Instance Method Summary
collapse
Instance Method Details
#test_basic ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb', line 46
def test_basic
testdata = "Line 1\nLine 2\r\nLine 3\n"
a = Basic.new
a.receive_data testdata
assert_equal( ["Line 1", "Line 2", "Line 3"], a.lines )
a = Basic.new
testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
assert_equal( ["Line 1", "Line 2", "Line 3"], a.lines )
end
|
#test_binary ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb', line 109
def test_binary
testdata = %Q(Line 1
Line 2
0000000000Line 3
Line 4
)
a = Binary.new
a.receive_data testdata
assert_equal( ["Line 1", "Line 2", "Line 3", "Line 4"], a.lines)
assert_equal( "0000000000", a.body )
a = Binary.new
testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
assert_equal( ["Line 1", "Line 2", "Line 3", "Line 4"], a.lines)
assert_equal( "0000000000", a.body )
end
|
#test_binary_pairs ⇒ Object
310
311
312
313
314
315
|
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb', line 310
def test_binary_pairs
test_data = "123" * 5
a = BinaryPair.new
a.receive_data test_data
assert_equal( [1,2,1,2,1,2,1,2,1,2], a.sizes )
end
|
#test_binary_tail ⇒ Object
245
246
247
248
249
250
251
252
253
254
255
256
257
|
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb', line 245
def test_binary_tail
testdata = "0" * 500
a = BinaryTail.new
a.receive_data testdata
a.unbind
assert_equal( "0" * 500, a.data )
a = BinaryTail.new
testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
a.unbind
assert_equal( "0" * 500, a.data )
end
|
#test_change_delimiter ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb', line 72
def test_change_delimiter
testdata = %Q(LineaALinebBLinecCLinedD)
a = ChangeDelimiter.new
a.receive_data testdata
assert_equal( ["Linea", "Lineb", "Linec", "Lined"], a.lines )
a = ChangeDelimiter.new
testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
assert_equal( ["Linea", "Lineb", "Linec", "Lined"], a.lines )
end
|
#test_multichar ⇒ Object
215
216
217
218
219
220
221
222
223
224
225
226
|
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb', line 215
def test_multichar
testdata = "Line012Line012Line012Line"
a = Multichar.new
a.receive_data testdata
assert_equal( ["Line"]*3, a.lines )
a = Multichar.new
testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
end
|
#test_receive_end_of_binary_data ⇒ Object
285
286
287
288
289
290
291
|
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb', line 285
def test_receive_end_of_binary_data
testdata = "_" * 1000
a = LazyBinary.new
testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
assert_equal( "_" * 1000, a.data )
assert( a.end )
end
|
#test_throw_back ⇒ Object
187
188
189
190
191
192
193
194
195
196
197
|
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb', line 187
def test_throw_back
testdata = "Line\n" * 10
a = ThrowBack.new
a.receive_data testdata
assert_equal( ["Line"] * 5, a. )
a = ThrowBack.new
testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
assert_equal( ["Line"] * 5, a. )
end
|
#test_unsized_binary ⇒ Object
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb', line 145
def test_unsized_binary
testdata = "X\0" * 1000
a = UnsizedBinary.new
a.receive_data testdata
assert_equal( 1, a.n_calls )
assert_equal( testdata, a.body )
a = UnsizedBinary.new
testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
assert_equal( 2000, a.n_calls )
assert_equal( testdata, a.body )
end
|