diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-01-17 15:31:22 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-01-17 15:32:40 -0500 |
commit | 00d67d07a9cde9d5736909b5357bf829bd1c1663 (patch) | |
tree | 55611ce5a74f0b53be4d7ec25b880eac6ddda7c6 /dbtests | |
parent | 066deac52970232c73b40b37a9c35027e64f6d53 (diff) | |
download | mongo-00d67d07a9cde9d5736909b5357bf829bd1c1663.tar.gz |
some tests for getFieldDotted
Diffstat (limited to 'dbtests')
-rw-r--r-- | dbtests/jsobjtests.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/dbtests/jsobjtests.cpp b/dbtests/jsobjtests.cpp index a8570e15bfb..6804d71a6de 100644 --- a/dbtests/jsobjtests.cpp +++ b/dbtests/jsobjtests.cpp @@ -469,6 +469,19 @@ namespace JsobjTests { } }; + class GetField { + public: + void run(){ + BSONObj o = BSON( "a" << 1 << + "b" << BSON( "a" << 2 ) << + "c" << BSON_ARRAY( BSON( "a" << 3 ) << BSON( "a" << 4 ) ) ); + ASSERT_EQUALS( 1 , o.getFieldDotted( "a" ).numberInt() ); + ASSERT_EQUALS( 2 , o.getFieldDotted( "b.a" ).numberInt() ); + ASSERT_EQUALS( 3 , o.getFieldDotted( "c.0.a" ).numberInt() ); + ASSERT_EQUALS( 4 , o.getFieldDotted( "c.1.a" ).numberInt() ); + } + }; + namespace Validation { class Base { @@ -1776,6 +1789,8 @@ namespace JsobjTests { add< BSONObjTests::NullString >(); add< BSONObjTests::AppendAs >(); add< BSONObjTests::ArrayAppendAs >(); + add< BSONObjTests::GetField >(); + add< BSONObjTests::Validation::BadType >(); add< BSONObjTests::Validation::EooBeforeEnd >(); add< BSONObjTests::Validation::Undefined >(); |