Add tests to verify UTF-8 support works

pull/33/head
Thijs Cadier 7 years ago
parent ac0020c0be
commit e028d5f2d3

@ -30,6 +30,31 @@ fn test_basics() {
let document = doc! {"key_1" => "Value 1"}; let document = doc! {"key_1" => "Value 1"};
bulk_operation.insert(&document).unwrap(); bulk_operation.insert(&document).unwrap();
assert!(bulk_operation.execute().is_ok()); assert!(bulk_operation.execute().is_ok());
let first_document = collection.find(&doc!{}, None).unwrap().next().unwrap().unwrap();
assert_eq!(
first_document.get("key_1").unwrap(),
&bson::Bson::String("Value 1".to_string())
);
}
#[test]
fn test_utf8() {
let uri = Uri::new("mongodb://localhost:27017/").unwrap();
let pool = ClientPool::new(uri, None);
let client = pool.pop();
let collection = client.get_collection("rust_driver_test", "bulk_operation_utf8");
let bulk_operation = collection.create_bulk_operation(None);
let document = doc! {"key_1" => "kācaṃ śaknomyattum; nopahinasti mām."};
bulk_operation.insert(&document).unwrap();
assert!(bulk_operation.execute().is_ok());
let first_document = collection.find(&doc!{}, None).unwrap().next().unwrap().unwrap();
assert_eq!(
first_document.get("key_1").unwrap(),
&bson::Bson::String("kācaṃ śaknomyattum; nopahinasti mām.".to_string())
);
} }
#[test] #[test]

@ -72,9 +72,20 @@ fn test_mutation_and_finding() {
let document = doc! { let document = doc! {
"key_1" => "Value 1", "key_1" => "Value 1",
"key_2" => "Value 2" "key_2" => "kācaṃ śaknomyattum; nopahinasti mām."
}; };
assert!(collection.insert(&document, None).is_ok()); assert!(collection.insert(&document, None).is_ok());
{
let found_document = collection.find(&document, None).unwrap().next().unwrap().unwrap();
assert_eq!(
found_document.get("key_1").unwrap(),
&bson::Bson::String("Value 1".to_string())
);
assert_eq!(
found_document.get("key_2").unwrap(),
&bson::Bson::String("kācaṃ śaknomyattum; nopahinasti mām.".to_string())
);
}
let second_document = doc! { let second_document = doc! {
"key_1" => "Value 3" "key_1" => "Value 3"

Loading…
Cancel
Save