diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:19:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:20:02 +0000 |
commit | 58daab21cd043e1dc37024a7f99b396788372918 (patch) | |
tree | 96771e43bb69f7c1c2b0b4f7374cb74d7866d0cb /web/server/h2o/libh2o/deps/mruby-input-stream/test | |
parent | Releasing debian version 1.43.2-1. (diff) | |
download | netdata-58daab21cd043e1dc37024a7f99b396788372918.tar.xz netdata-58daab21cd043e1dc37024a7f99b396788372918.zip |
Merging upstream version 1.44.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/deps/mruby-input-stream/test')
-rw-r--r-- | web/server/h2o/libh2o/deps/mruby-input-stream/test/input_stream.rb | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/deps/mruby-input-stream/test/input_stream.rb b/web/server/h2o/libh2o/deps/mruby-input-stream/test/input_stream.rb new file mode 100644 index 000000000..8201786b1 --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby-input-stream/test/input_stream.rb @@ -0,0 +1,111 @@ +assert('InputStream.new()') do + vec = InputStream.new + assert_equal InputStream, vec.class +end + +assert('InputStream.new("foo")') do + vec = InputStream.new("foo") + assert_equal InputStream, vec.class +end + +assert('InputStream#read') do + vec = InputStream.new("foo") + assert_equal "foo", vec.read +end + +assert('InputStream#read(2)') do + vec = InputStream.new("abcdef") + assert_equal "ab", vec.read(2) + assert_equal "cde", vec.read(3) + assert_equal "f", vec.read(4) + assert_equal nil, vec.read(5) +end + +assert('InputStream#read(2, "")') do + vec = InputStream.new("abcdef") + s1 = "" + assert_equal "ab", vec.read(2, s1) + assert_equal "ab", s1 + assert_equal "abcde", vec.read(3, s1) + assert_equal "abcde", s1 + assert_equal "abcdef", vec.read(4, s1) + assert_equal "abcdef", s1 + assert_equal nil, vec.read(5, s1) + assert_equal "abcdef", s1 +end + +assert('InputStream#read(10)') do + vec = InputStream.new("abc") + assert_equal "abc", vec.read(10) + assert_equal nil, vec.read(10) +end + +assert('InputStream#read ""') do + vec = InputStream.new("") + assert_equal nil, vec.read(2) + assert_equal nil, vec.read(0) + assert_equal nil, vec.read(2) +end + +assert('InputStream#read(0)') do + vec = InputStream.new("foo") + assert_equal "", vec.read(0) + assert_equal "", vec.read(0) + assert_equal "f", vec.read(1) +end + + +assert('InputStream#gets') do + vec = InputStream.new("foo") + assert_equal "foo", vec.gets + assert_equal nil, vec.gets +end + +assert('InputStream#gets ""') do + vec = InputStream.new("") + assert_equal nil, vec.gets +end + +assert('InputStream#gets long') do + vec = InputStream.new("foo\nbar\nbuz\n") + assert_equal "foo\n", vec.gets + assert_equal "bar\n", vec.gets + assert_equal "buz\n", vec.gets + assert_equal nil, vec.gets +end + +assert('InputStream#gets NN') do + vec = InputStream.new("\n\nbuz") + assert_equal "\n", vec.gets + assert_equal "\n", vec.gets + assert_equal "buz", vec.gets + assert_equal nil, vec.gets +end + +assert('InputStream#each') do + vec = InputStream.new("foo\nbar\nbuz\nzzz") + buf = [] + vec.each do |line| + buf << line + end + assert_equal ["foo\n", "bar\n", "buz\n", "zzz"], buf +end + +assert('InputStream#each ""') do + vec = InputStream.new("") + buf = [] + vec.each do |line| + buf << line + end + assert_equal [], buf +end + +assert('InputStream#rewind') do + vec = InputStream.new("abcdef") + assert_equal "ab", vec.read(2) + assert_equal "cde", vec.read(3) + vec.rewind + assert_equal "abcd", vec.read(4) + assert_equal "ef", vec.read(5) +end + |