@ -495,20 +495,27 @@ inline void MapReflectionTester::SetMapFieldsViaMapReflection(
Message * sub_foreign_message = nullptr ;
MapValueRef map_val ;
MapValueConstRef map_val_const ;
// Add first element.
MapKey map_key ;
map_key . SetInt32Value ( 0 ) ;
EXPECT_FALSE ( reflection - > LookupMapValue ( * message , F ( " map_int32_int32 " ) ,
map_key , & map_val_const ) ) ;
EXPECT_TRUE ( reflection - > InsertOrLookupMapValue ( message , F ( " map_int32_int32 " ) ,
map_key , & map_val ) ) ;
map_val . SetInt32Value ( 0 ) ;
map_key . SetInt64Value ( 0 ) ;
EXPECT_FALSE ( reflection - > LookupMapValue ( * message , F ( " map_int64_int64 " ) ,
map_key , & map_val_const ) ) ;
EXPECT_TRUE ( reflection - > InsertOrLookupMapValue ( message , F ( " map_int64_int64 " ) ,
map_key , & map_val ) ) ;
map_val . SetInt64Value ( 0 ) ;
map_key . SetUInt32Value ( 0 ) ;
EXPECT_FALSE ( reflection - > LookupMapValue ( * message , F ( " map_uint32_uint32 " ) ,
map_key , & map_val_const ) ) ;
EXPECT_TRUE ( reflection - > InsertOrLookupMapValue (
message , F ( " map_uint32_uint32 " ) , map_key , & map_val ) ) ;
map_val . SetUInt32Value ( 0 ) ;
@ -559,26 +566,36 @@ inline void MapReflectionTester::SetMapFieldsViaMapReflection(
map_val . SetDoubleValue ( 0.0 ) ;
map_key . SetBoolValue ( false ) ;
EXPECT_FALSE ( reflection - > LookupMapValue ( * message , F ( " map_bool_bool " ) , map_key ,
& map_val_const ) ) ;
EXPECT_TRUE ( reflection - > InsertOrLookupMapValue ( message , F ( " map_bool_bool " ) ,
map_key , & map_val ) ) ;
map_val . SetBoolValue ( false ) ;
map_key . SetStringValue ( " 0 " ) ;
EXPECT_FALSE ( reflection - > LookupMapValue ( * message , F ( " map_string_string " ) ,
map_key , & map_val_const ) ) ;
EXPECT_TRUE ( reflection - > InsertOrLookupMapValue (
message , F ( " map_string_string " ) , map_key , & map_val ) ) ;
map_val . SetStringValue ( " 0 " ) ;
map_key . SetInt32Value ( 0 ) ;
EXPECT_FALSE ( reflection - > LookupMapValue ( * message , F ( " map_int32_bytes " ) ,
map_key , & map_val_const ) ) ;
EXPECT_TRUE ( reflection - > InsertOrLookupMapValue ( message , F ( " map_int32_bytes " ) ,
map_key , & map_val ) ) ;
map_val . SetStringValue ( " 0 " ) ;
map_key . SetInt32Value ( 0 ) ;
EXPECT_FALSE ( reflection - > LookupMapValue ( * message , F ( " map_int32_enum " ) ,
map_key , & map_val_const ) ) ;
EXPECT_TRUE ( reflection - > InsertOrLookupMapValue ( message , F ( " map_int32_enum " ) ,
map_key , & map_val ) ) ;
map_val . SetEnumValue ( map_enum_bar_ - > number ( ) ) ;
map_key . SetInt32Value ( 0 ) ;
EXPECT_FALSE ( reflection - > LookupMapValue (
* message , F ( " map_int32_foreign_message " ) , map_key , & map_val_const ) ) ;
EXPECT_TRUE ( reflection - > InsertOrLookupMapValue (
message , F ( " map_int32_foreign_message " ) , map_key , & map_val ) ) ;
sub_foreign_message = map_val . MutableMessageValue ( ) ;
@ -933,6 +950,7 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
const Reflection * reflection = message . GetReflection ( ) ;
const Message * sub_message ;
MapKey map_key ;
MapValueConstRef map_value_const_ref ;
// -----------------------------------------------------------------
@ -971,6 +989,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetInt32Value ( key ) ;
EXPECT_TRUE (
reflection - > ContainsMapKey ( message , F ( " map_int32_int32 " ) , map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue ( message , F ( " map_int32_int32 " ) ,
map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetInt32Value ( ) , val ) ;
}
}
{
@ -990,6 +1011,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetInt64Value ( key ) ;
EXPECT_TRUE (
reflection - > ContainsMapKey ( message , F ( " map_int64_int64 " ) , map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue ( message , F ( " map_int64_int64 " ) ,
map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetInt64Value ( ) , val ) ;
}
}
{
@ -1009,6 +1033,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetUInt32Value ( key ) ;
EXPECT_TRUE (
reflection - > ContainsMapKey ( message , F ( " map_uint32_uint32 " ) , map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue ( message , F ( " map_uint32_uint32 " ) ,
map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetUInt32Value ( ) , val ) ;
}
}
{
@ -1027,6 +1054,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetUInt64Value ( key ) ;
EXPECT_TRUE (
reflection - > ContainsMapKey ( message , F ( " map_uint64_uint64 " ) , map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue ( message , F ( " map_uint64_uint64 " ) ,
map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetUInt64Value ( ) , val ) ;
}
}
{
@ -1045,6 +1075,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetInt32Value ( key ) ;
EXPECT_EQ ( true , reflection - > ContainsMapKey (
message , F ( " map_sint32_sint32 " ) , map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue ( message , F ( " map_sint32_sint32 " ) ,
map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetInt32Value ( ) , val ) ;
}
}
{
@ -1063,6 +1096,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetInt64Value ( key ) ;
EXPECT_EQ ( true , reflection - > ContainsMapKey (
message , F ( " map_sint64_sint64 " ) , map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue ( message , F ( " map_sint64_sint64 " ) ,
map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetInt64Value ( ) , val ) ;
}
}
{
@ -1081,6 +1117,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetUInt32Value ( key ) ;
EXPECT_EQ ( true , reflection - > ContainsMapKey (
message , F ( " map_fixed32_fixed32 " ) , map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue ( message , F ( " map_fixed32_fixed32 " ) ,
map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetUInt32Value ( ) , val ) ;
}
}
{
@ -1099,6 +1138,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetUInt64Value ( key ) ;
EXPECT_EQ ( true , reflection - > ContainsMapKey (
message , F ( " map_fixed64_fixed64 " ) , map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue ( message , F ( " map_fixed64_fixed64 " ) ,
map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetUInt64Value ( ) , val ) ;
}
}
{
@ -1117,6 +1159,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetInt32Value ( key ) ;
EXPECT_EQ ( true , reflection - > ContainsMapKey (
message , F ( " map_sfixed32_sfixed32 " ) , map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue (
message , F ( " map_sfixed32_sfixed32 " ) , map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetInt32Value ( ) , val ) ;
}
}
{
@ -1135,6 +1180,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetInt64Value ( key ) ;
EXPECT_EQ ( true , reflection - > ContainsMapKey (
message , F ( " map_sfixed64_sfixed64 " ) , map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue (
message , F ( " map_sfixed64_sfixed64 " ) , map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetInt64Value ( ) , val ) ;
}
}
{
@ -1153,6 +1201,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetInt32Value ( key ) ;
EXPECT_EQ ( true , reflection - > ContainsMapKey ( message , F ( " map_int32_float " ) ,
map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue ( message , F ( " map_int32_float " ) ,
map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetFloatValue ( ) , val ) ;
}
}
{
@ -1171,6 +1222,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetInt32Value ( key ) ;
EXPECT_EQ ( true , reflection - > ContainsMapKey ( message , F ( " map_int32_double " ) ,
map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue ( message , F ( " map_int32_double " ) ,
map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetDoubleValue ( ) , val ) ;
}
}
{
@ -1189,6 +1243,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetBoolValue ( key ) ;
EXPECT_EQ ( true , reflection - > ContainsMapKey ( message , F ( " map_bool_bool " ) ,
map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue ( message , F ( " map_bool_bool " ) ,
map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetBoolValue ( ) , val ) ;
}
}
{
@ -1207,6 +1264,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetStringValue ( key ) ;
EXPECT_EQ ( true , reflection - > ContainsMapKey (
message , F ( " map_string_string " ) , map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue ( message , F ( " map_string_string " ) ,
map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetStringValue ( ) , val ) ;
}
}
{
@ -1225,6 +1285,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetInt32Value ( key ) ;
EXPECT_EQ ( true , reflection - > ContainsMapKey ( message , F ( " map_int32_bytes " ) ,
map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue ( message , F ( " map_int32_bytes " ) ,
map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetStringValue ( ) , val ) ;
}
}
{
@ -1243,6 +1306,9 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetInt32Value ( key ) ;
EXPECT_EQ ( true , reflection - > ContainsMapKey ( message , F ( " map_int32_enum " ) ,
map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue ( message , F ( " map_int32_enum " ) ,
map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( map_value_const_ref . GetEnumValue ( ) , val - > number ( ) ) ;
}
}
{
@ -1263,6 +1329,12 @@ inline void MapReflectionTester::ExpectMapFieldsSetViaReflection(
map_key . SetInt32Value ( key ) ;
EXPECT_EQ ( true , reflection - > ContainsMapKey (
message , F ( " map_int32_foreign_message " ) , map_key ) ) ;
EXPECT_TRUE ( reflection - > LookupMapValue ( message ,
F ( " map_int32_foreign_message " ) ,
map_key , & map_value_const_ref ) ) ;
EXPECT_EQ ( foreign_message . GetReflection ( ) - > GetInt32 (
map_value_const_ref . GetMessageValue ( ) , foreign_c_ ) ,
val ) ;
}
}
}