Skip to content

Commit

Permalink
Validate correct serialization of regexp with /gi by adding test
Browse files Browse the repository at this point in the history
  • Loading branch information
christkv committed Feb 24, 2014
1 parent 0fc7f85 commit cc4e76c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/node/bson_parser_comparision_test.js
Expand Up @@ -583,6 +583,25 @@ exports['Should correctly serialize prototype fields'] = function(test) {
test.done(); test.done();
} }


/**
* @ignore
*/
exports['Should correctly serialize regexp'] = function(test) {
// Create doc to serialize
var doc = {regexp: /<[^>]>/gi}

// Serialize using both
var simple_string_serialized = bsonJS.serialize(doc, false, true, true);
var simple_string_serialized_2 = bsonC.serialize(doc, false, true, true);

// Deserialize the string
var doc1 = bsonJS.deserialize(simple_string_serialized);
var doc2 = bsonC.deserialize(simple_string_serialized_2);
assert.equal("/<[^>]>/gi", doc1.regexp.toString());
assert.equal("/<[^>]>/gi", doc2.regexp.toString());
test.done();
}

/** /**
* @ignore * @ignore
*/ */
Expand Down

0 comments on commit cc4e76c

Please sign in to comment.