Oops; comment out the test I forgot to comment out in the previous check-in

This commit is contained in:
Jim Menard 2009-01-09 19:59:30 -05:00
parent 78fdfe0eb9
commit abd4a4c5a8

View File

@ -24,56 +24,56 @@ class RoundTripTest < Test::Unit::TestCase
end end
end end
# Round-trip comparisons of Ruby-to-BSON and back. # # Round-trip comparisons of Ruby-to-BSON and back.
# * Take the objects that were read from XML # # * Take the objects that were read from XML
# * Turn them into BSON bytes # # * Turn them into BSON bytes
# * Compare that with the BSON files we have # # * Compare that with the BSON files we have
# * Turn those BSON bytes back in to Ruby objects # # * Turn those BSON bytes back in to Ruby objects
# * Turn them back into BSON bytes # # * Turn them back into BSON bytes
# * Compare that with the BSON files we have (or the bytes that were already # # * Compare that with the BSON files we have (or the bytes that were already
# generated) # # generated)
def test_round_trip # def test_round_trip
@@ruby.each { |name, obj| # @@ruby.each { |name, obj|
File.open(File.join(HERE, 'data', "#{name}.bson"), 'r') { |f| # File.open(File.join(HERE, 'data', "#{name}.bson"), 'r') { |f|
# Read the BSON from the file # # Read the BSON from the file
bson = f.read # bson = f.read
bson = if RUBY_VERSION >= '1.9' # bson = if RUBY_VERSION >= '1.9'
bson.bytes.to_a # bson.bytes.to_a
else # else
bson.split(//).collect { |c| c[0] } # bson.split(//).collect { |c| c[0] }
end # end
# Turn the Ruby object into BSON bytes and compare with the BSON bytes # # Turn the Ruby object into BSON bytes and compare with the BSON bytes
# from the file. # # from the file.
bson_from_ruby = BSON.new.serialize(obj).to_a # bson_from_ruby = BSON.new.serialize(obj).to_a
# # DEBUG # # # DEBUG
# File.open(File.join(HERE, 'data', "#{name}_out.bson"), 'wb') { |f| # # File.open(File.join(HERE, 'data', "#{name}_out.bson"), 'wb') { |f|
# bson_from_ruby.each { |b| f.putc(b) } # # bson_from_ruby.each { |b| f.putc(b) }
# } # # }
begin # begin
assert_equal bson.length, bson_from_ruby.length # assert_equal bson.length, bson_from_ruby.length
assert_equal bson, bson_from_ruby # assert_equal bson, bson_from_ruby
rescue => ex # rescue => ex
$stderr.puts "failure while round-tripping #{name}" # DEBUG # $stderr.puts "failure while round-tripping #{name}" # DEBUG
raise ex # raise ex
end # end
# Turn those BSON bytes back into a Ruby object. # # Turn those BSON bytes back into a Ruby object.
# # #
# We're passing a nil db to the contructor here, but that's OK because # # We're passing a nil db to the contructor here, but that's OK because
# the BSON bytes don't contain the db object in any case. # # the BSON bytes don't contain the db object in any case.
obj_from_bson = BSON.new(nil).deserialize(ByteBuffer.new(bson_from_ruby)) # obj_from_bson = BSON.new(nil).deserialize(ByteBuffer.new(bson_from_ruby))
assert_kind_of OrderedHash, obj_from_bson # assert_kind_of OrderedHash, obj_from_bson
# Turn that Ruby object into BSON and compare it to the original BSON # # Turn that Ruby object into BSON and compare it to the original BSON
# bytes. # # bytes.
bson_from_ruby = BSON.new.serialize(obj_from_bson).to_a # bson_from_ruby = BSON.new.serialize(obj_from_bson).to_a
assert_equal bson.length, bson_from_ruby.length # assert_equal bson.length, bson_from_ruby.length
assert_equal bson, bson_from_ruby # assert_equal bson, bson_from_ruby
} # }
} # }
end # end
end end