added test case for cbson utf-8

This commit is contained in:
Kyle Banker 2009-11-30 17:50:54 -05:00
parent a7c75d7fae
commit f029cdde6a
2 changed files with 23 additions and 2 deletions

View File

@ -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)

View File

@ -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