From 00d67d07a9cde9d5736909b5357bf829bd1c1663 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Mon, 17 Jan 2011 15:31:22 -0500 Subject: [PATCH] some tests for getFieldDotted --- dbtests/jsobjtests.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 >();