Class: AbstractOutputStreamTest
- Inherits:
-
MiniTest::Test
- Object
- MiniTest::Test
- AbstractOutputStreamTest
- Defined in:
- lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_output_stream_test.rb
Defined Under Namespace
Classes: TestOutputStream
Instance Method Summary collapse
- #setup ⇒ Object
- #teardown ⇒ Object
- #test_print ⇒ Object
- #test_printf ⇒ Object
- #test_putc ⇒ Object
- #test_puts ⇒ Object
- #test_write ⇒ Object
Instance Method Details
#setup ⇒ Object
20 21 22 23 24 25 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_output_stream_test.rb', line 20 def setup @output_stream = TestOutputStream.new @origCommaSep = $, @origOutputSep = $\ end |
#teardown ⇒ Object
27 28 29 30 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_output_stream_test.rb', line 27 def teardown $, = @origCommaSep $\ = @origOutputSep end |
#test_print ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_output_stream_test.rb', line 42 def test_print $\ = nil # record separator set to nil @output_stream.print("hello") assert_equal("hello", @output_stream.buffer) @output_stream.print(" world.") assert_equal("hello world.", @output_stream.buffer) @output_stream.print(" You ok ", "out ", "there?") assert_equal("hello world. You ok out there?", @output_stream.buffer) $\ = "\n" @output_stream.print assert_equal("hello world. You ok out there?\n", @output_stream.buffer) @output_stream.print("I sure hope so!") assert_equal("hello world. You ok out there?\nI sure hope so!\n", @output_stream.buffer) $, = "X" @output_stream.buffer = "" @output_stream.print("monkey", "duck", "zebra") assert_equal("monkeyXduckXzebra\n", @output_stream.buffer) $\ = nil @output_stream.buffer = "" @output_stream.print(20) assert_equal("20", @output_stream.buffer) end |
#test_printf ⇒ Object
71 72 73 74 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_output_stream_test.rb', line 71 def test_printf @output_stream.printf("%d %04x", 123, 123) assert_equal("123 007b", @output_stream.buffer) end |
#test_putc ⇒ Object
76 77 78 79 80 81 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_output_stream_test.rb', line 76 def test_putc @output_stream.putc("A") assert_equal("A", @output_stream.buffer) @output_stream.putc(65) assert_equal("AA", @output_stream.buffer) end |
#test_puts ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_output_stream_test.rb', line 83 def test_puts @output_stream.puts assert_equal("\n", @output_stream.buffer) @output_stream.puts("hello", "world") assert_equal("\nhello\nworld\n", @output_stream.buffer) @output_stream.buffer = "" @output_stream.puts("hello\n", "world\n") assert_equal("hello\nworld\n", @output_stream.buffer) @output_stream.buffer = "" @output_stream.puts(["hello\n", "world\n"]) assert_equal("hello\nworld\n", @output_stream.buffer) @output_stream.buffer = "" @output_stream.puts(["hello\n", "world\n"], "bingo") assert_equal("hello\nworld\nbingo\n", @output_stream.buffer) @output_stream.buffer = "" @output_stream.puts(16, 20, 50, "hello") assert_equal("16\n20\n50\nhello\n", @output_stream.buffer) end |
#test_write ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_output_stream_test.rb', line 32 def test_write count = @output_stream.write("a little string") assert_equal("a little string", @output_stream.buffer) assert_equal("a little string".length, count) count = @output_stream.write(". a little more") assert_equal("a little string. a little more", @output_stream.buffer) assert_equal(". a little more".length, count) end |