added test case for cbson utf-8
This commit is contained in:
parent
a7c75d7fae
commit
f029cdde6a
|
@ -21,6 +21,26 @@ class BSONTest < Test::Unit::TestCase
|
|||
assert_equal doc, @b.deserialize
|
||||
end
|
||||
|
||||
|
||||
begin
|
||||
CBson
|
||||
|
||||
def test_valid_utf8_string
|
||||
doc = {'doc' => "aéあ"}
|
||||
bson = CBson.serialize(doc, false)
|
||||
assert_equal doc, CBson.deserialize(bson)
|
||||
end
|
||||
|
||||
def test_invalid_string
|
||||
string = Iconv.conv('iso-8859-1', 'utf-8', 'aé').first
|
||||
doc = {'doc' => string}
|
||||
assert_raise InvalidStringEncoding do
|
||||
CBson.serialize(doc, false)
|
||||
end
|
||||
end
|
||||
|
||||
rescue
|
||||
|
||||
def test_valid_utf8_string
|
||||
doc = {'doc' => "aéあ"}
|
||||
@b.serialize(doc)
|
||||
|
@ -35,6 +55,8 @@ class BSONTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def test_code
|
||||
doc = {'$where' => Code.new('this.a.b < this.b')}
|
||||
@b.serialize(doc)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
||||
require 'rubygems'
|
||||
require 'mongo'
|
||||
require 'test/unit'
|
||||
|
||||
begin
|
||||
|
@ -17,8 +18,6 @@ MSG
|
|||
exit
|
||||
end
|
||||
|
||||
require 'mongo'
|
||||
|
||||
# NOTE: most tests assume that MongoDB is running.
|
||||
class Test::Unit::TestCase
|
||||
include Mongo
|
||||
|
|
Loading…
Reference in New Issue