Files
mongo/jstests/core/regex_limit.js
Siyuan Zhou 3660343e0b SERVER-12127 migrate js tests to jscore suite when not related to writes
Migrate js tests starting from j-z.
Include SERVER-12920 Update use_power_of_2.js

Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
2014-03-03 22:54:10 -05:00

23 lines
524 B
JavaScript

var t = db.regex_limit;
t.drop();
var repeatStr = function(str, n){
return new Array(n + 1).join(str);
};
t.insert({ z: repeatStr('c', 100000) });
var maxOkStrLen = repeatStr('c', 32764);
var strTooLong = maxOkStrLen + 'c';
assert(t.findOne({ z: { $regex: maxOkStrLen }}) != null);
assert.throws(function() {
t.findOne({ z: { $regex: strTooLong }});
});
assert(t.findOne({ z: { $in: [ new RegExp(maxOkStrLen) ]}}) != null);
assert.throws(function() {
t.findOne({ z: { $in: [ new RegExp(strTooLong) ]}});
});