mongo-debian/jstests/regex_limit.js
2013-03-23 13:40:41 +01:00

22 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) ]}});
});