diff options
author | Randolph Tan <randolph@10gen.com> | 2013-12-06 15:44:02 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2013-12-09 14:52:48 -0500 |
commit | 5a741123578072e0439f8b3b837f43643b809e0b (patch) | |
tree | 2a870cc65f505c21d1d877b3c555808ed19c8765 /src/mongo/db/field_parser_test.cpp | |
parent | 1df18f9530aec174f384d5f4ff5efda8218ecd32 (diff) | |
download | mongo-5a741123578072e0439f8b3b837f43643b809e0b.tar.gz |
SERVER-11968 Write commands allow illegal collection names
Diffstat (limited to 'src/mongo/db/field_parser_test.cpp')
-rw-r--r-- | src/mongo/db/field_parser_test.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mongo/db/field_parser_test.cpp b/src/mongo/db/field_parser_test.cpp index 1a458c3960e..9e3f974c915 100644 --- a/src/mongo/db/field_parser_test.cpp +++ b/src/mongo/db/field_parser_test.cpp @@ -422,4 +422,23 @@ namespace { ASSERT_NOT_EQUALS(errMsg, ""); } + TEST(EdgeCases, EmbeddedNullStrings) { + + // Test extraction of string values with embedded nulls. + BSONField<string> field("testStr"); + + const char* str = "a\0c"; + const size_t strSize = 4; + BSONObjBuilder doc; + doc.append(field(), str, strSize); + BSONObj obj(doc.obj()); + + string parsed; + string errMsg; + ASSERT(FieldParser::extract(obj, field, &parsed, &errMsg)); + + ASSERT_EQUALS(0, memcmp(parsed.data(), str, strSize)); + ASSERT_EQUALS(errMsg, ""); + } + } // unnamed namespace |