Found and fixed code deserialization bug.

This commit is contained in:
Jim Menard 2008-12-16 07:23:22 -05:00
parent bce01bbaa6
commit c75bee763b
2 changed files with 8 additions and 2 deletions

View File

@ -87,7 +87,7 @@ class BSON
while @buf.more?
type = @buf.get
case type
when STRING
when STRING, CODE
key = deserialize_element_name(@buf)
doc[key] = deserialize_string_data(@buf)
when NUMBER

View File

@ -10,7 +10,13 @@ class BSONTest < Test::Unit::TestCase
end
def test_object_encoding
doc = {'doc' => {'age' => 41.2, 'name' => 'Spongebob'}}
doc = {'doc' => {'age' => 42, 'name' => 'Spongebob', 'shoe_size' => 9.5}}
@b.serialize(doc)
assert_equal doc, @b.deserialize
end
def test_code_encoding
doc = {'$where' => 'this.a.b < this.b'}
@b.serialize(doc)
assert_equal doc, @b.deserialize
end