minor: more tests that already pass (at least in pure ruby)
This commit is contained in:
parent
2af5aa1e38
commit
20c8082e90
|
@ -17,6 +17,12 @@ class BSONTest < Test::Unit::TestCase
|
||||||
assert_equal doc, BSON.deserialize(bson)
|
assert_equal doc, BSON.deserialize(bson)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_valid_utf8_key
|
||||||
|
doc = {'aé' => 'hello'}
|
||||||
|
bson = bson = BSON.serialize(doc)
|
||||||
|
assert_equal doc, BSON.deserialize(bson)
|
||||||
|
end
|
||||||
|
|
||||||
# In 1.8 we test that other string encodings raise an exception.
|
# In 1.8 we test that other string encodings raise an exception.
|
||||||
# In 1.9 we test that they get auto-converted.
|
# In 1.9 we test that they get auto-converted.
|
||||||
if RUBY_VERSION < '1.9'
|
if RUBY_VERSION < '1.9'
|
||||||
|
@ -28,6 +34,14 @@ class BSONTest < Test::Unit::TestCase
|
||||||
BSON.serialize(doc)
|
BSON.serialize(doc)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_invalid_key
|
||||||
|
key = Iconv.conv('iso-8859-1', 'utf-8', 'aé')
|
||||||
|
doc = {key => 'hello'}
|
||||||
|
assert_raise InvalidStringEncoding do
|
||||||
|
BSON.serialize(doc)
|
||||||
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
def test_non_utf8_string
|
def test_non_utf8_string
|
||||||
bson = BSON.serialize({'str' => 'aé'.encode('iso-8859-1')})
|
bson = BSON.serialize({'str' => 'aé'.encode('iso-8859-1')})
|
||||||
|
@ -35,6 +49,11 @@ class BSONTest < Test::Unit::TestCase
|
||||||
assert_equal 'aé', result
|
assert_equal 'aé', result
|
||||||
assert_equal 'UTF-8', result.encoding.name
|
assert_equal 'UTF-8', result.encoding.name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_non_utf8_key
|
||||||
|
bson = BSON.serialize({'aé'.encode('iso-8859-1') => 'hello'})
|
||||||
|
assert_equal 'hello', BSON.deserialize(bson)['aé']
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_code
|
def test_code
|
||||||
|
|
Loading…
Reference in New Issue