summaryrefslogtreecommitdiff
path: root/jstests/aggregation/bugs/server14670.js
blob: dc8a750e9dbe1abb37acab7cbe840af57d58e04a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// SERVER-14670 introduced the $strLenBytes and $strLenCP aggregation expressions. In this file, we
// test the error cases for these expressions.
load("jstests/aggregation/extras/utils.js");  // For assertErrorCode.

(function() {
    "use strict";

    var coll = db.substr;
    coll.drop();

    // Need an empty document for the pipeline.
    coll.insert({});

    assertErrorCode(coll,
                    [{$project: {strLen: {$strLenBytes: 1}}}],
                    34473,
                    "$strLenBytes requires a string argument.");

    assertErrorCode(coll,
                    [{$project: {strLen: {$strLenCP: 1}}}],
                    34471,
                    "$strLenCP requires a string argument.");
}());