Use a BINARY encoded string when doing read/write comparisons.

This is a bit of a cheat really, but `#read` returns an ASCII encoded
string, where as our ruby generates UTF-8 encoded strings, causing
assertion failures.

Fixes #20
This commit is contained in:
Patrick J Cherry
2016-10-05 10:01:15 +01:00
parent 218c55fb63
commit 356e1fd6a1
2 changed files with 14 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ class TestServeMode < Test::Unit::TestCase
def setup
super
@b = String.new("\xFF", ecoding: "BINARY")
@env = Environment.new
@env.writefile1( "0" )
@env.serve1
@@ -53,18 +54,18 @@ class TestServeMode < Test::Unit::TestCase
assert_equal FlexNBD::REPLY_MAGIC, rsp[:magic]
assert_equal 0, rsp[:error]
client.write( 0, "\xFF" )
client.write( 0, @b )
rsp = client.read_response
assert_equal FlexNBD::REPLY_MAGIC, rsp[:magic]
assert_equal 0, rsp[:error]
client.write( 0, "\xFF\xFF" )
client.write( 0, @b * 2 )
rsp = client.read_response
assert_equal FlexNBD::REPLY_MAGIC, rsp[:magic]
assert_equal 0, rsp[:error]
end
assert_equal "\xFF\xFF", @env.file1.read( 0, 2 )
assert_equal @b * 2, @env.file1.read( 0, 2 )
end