int _Stg_ComponentFactory_GetRootDictInt( void* cf, Dictionary_Entry_Key key, const int defaultVal ) { Stg_ComponentFactory* self = (Stg_ComponentFactory*)cf; Journal_PrintfL( self->infoStream, 2, "Getting int from root dictionary with key '%s' and default value '%d'\n", key, defaultVal ); assert( self->rootDict ); return Dictionary_GetInt_WithDefault( self->rootDict, key, defaultVal ); }
void DictionarySuite_TestShortcuts( DictionarySuiteData* data ) { DictionarySuite_PopulateDictWithTestValues( data->dict, data->testDD ); /* Testing GetString_WithDefault. If an entry with that key already exists, then * the value of the existing key should be returned, and the default passed in * ignored. However if the given key _doesn't_ exist, the default should be * returned, and a new entry with the given key added to the dict. */ pcu_check_streq( data->testDD->testString, Dictionary_GetString_WithDefault( data->dict, "test_cstring", "heya" ) ); pcu_check_streq( "heya", Dictionary_GetString_WithDefault( data->dict, "test_cstring2", "heya" ) ); pcu_check_true( NULL != Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_cstring2" ) ); data->testDD->testDouble = Dictionary_GetDouble_WithDefault( data->dict, (Dictionary_Entry_Key)"test_double", 2.8 ); pcu_check_true( data->testDD->testDouble ); pcu_check_true( 2.8 == Dictionary_GetDouble_WithDefault( data->dict, (Dictionary_Entry_Key)"test_double2", 2.8 ) ); /* test_placeholder refers to test_double which equals 45.567 */ pcu_check_true( 45.567 == Dictionary_GetDouble_WithScopeDefault( data->dict, (Dictionary_Entry_Key)"test_placeholder", -1 ) ); pcu_check_true( NULL != Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_double2" ) ); data->testDD->testUint = Dictionary_GetUnsignedInt_WithDefault( data->dict, "test_uint", 33 ); pcu_check_true( data->testDD->testUint ); pcu_check_true( 33 == Dictionary_GetUnsignedInt_WithDefault( data->dict, "test_uint2", 33 ) ); pcu_check_true( NULL != Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_uint2" ) ); data->testDD->testInt = Dictionary_GetInt_WithDefault( data->dict, (Dictionary_Entry_Key)"test_int", -24 ); pcu_check_true( data->testDD->testInt ); pcu_check_true( -24 == Dictionary_GetInt_WithDefault( data->dict, (Dictionary_Entry_Key)"test_int2", -24 ) ); pcu_check_true( NULL != Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_int2" ) ); data->testDD->testUnsignedlong = Dictionary_GetUnsignedLong_WithDefault( data->dict, "test_unsignedlong", 32433 ); pcu_check_true( data->testDD->testUnsignedlong ); pcu_check_true( 32433 == Dictionary_GetUnsignedLong_WithDefault( data->dict, "test_unsignedlong2", 32433 ) ); pcu_check_true( NULL != Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_unsignedlong2" ) ); data->testDD->testBool = Dictionary_GetBool_WithDefault( data->dict, (Dictionary_Entry_Key)"test_bool", False ); pcu_check_true( data->testDD->testBool ); pcu_check_true( False == Dictionary_GetBool_WithDefault( data->dict, (Dictionary_Entry_Key)"test_bool2", False ) ); pcu_check_true( NULL != Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_bool2" ) ); pcu_check_streq( data->testDD->testString, Dictionary_GetString_WithPrintfDefault( data->dict, "test_cstring", "heya%s%u", "hey", 3 ) ); pcu_check_streq( "heyahey3", Dictionary_GetString_WithPrintfDefault( data->dict, "test_cstring3", "heya%s%u", "hey", 3 ) ); pcu_check_true( NULL != Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_cstring3" ) ); }