Project

General

Profile

Bug #7398 ยป openssl_test_read_and_write.patch

zzak (zzak _), 11/19/2012 01:03 PM

View differences:

test/openssl/test_ssl.rb
ITERATIONS.times{|i|
str = "x" * 100 + "\n"
ssl.syswrite(str)
assert_equal(str, ssl.sysread(str.size))
newstr = ''
newstr << ssl.sysread(str.size - newstr.size) until newstr.size == str.size
assert_equal(str, newstr)
str = "x" * i * 100 + "\n"
buf = ""
ssl.syswrite(str)
assert_equal(buf.object_id, ssl.sysread(str.size, buf).object_id)
assert_equal(str, buf)
newstr = buf
newstr << ssl.sysread(str.size - newstr.size) until newstr.size == str.size
assert_equal(str, newstr)
}
# puts and gets
-
test/openssl/test_pair.rb
ssl_pair {|s1, s2|
s2.write "a\nbcd"
assert_equal("a\n", s1.gets)
assert_equal("bcd", s1.readpartial(10))
result = ""
result << s1.readpartial(10) until result.length == 3
assert_equal("bcd", result)
s2.write "efg"
assert_equal("efg", s1.readpartial(10))
result = ""
result << s1.readpartial(10) until result.length == 3
assert_equal("efg", result)
s2.close
assert_raise(EOFError) { s1.readpartial(10) }
assert_raise(EOFError) { s1.readpartial(10) }
    (1-1/1)