ib_status_t ib_field_setv( ib_field_t *f, void *in_pval ) { ib_status_t rc = ib_field_setv_ex(f, in_pval, NULL, 0); return rc; }
void set_value( ib_field_t* f, void* in_value, const char* arg, size_t arg_length ) { ib_status_t rc = ib_field_setv_ex(f, in_value, arg, arg_length); throw_if_error(rc); }
///@test Test util field library - ib_field_dyn_register_get() TEST_F(TestIBUtilField, test_dyn_field) { ib_field_t *dynf; ib_field_t *cdynf; ib_status_t rc; const char *fval; /* Create a field with no initial value. */ rc = ib_field_create_dynamic( &dynf, MM(), IB_S2SL("test_dynf"), IB_FTYPE_NULSTR, dyn_get, (void *)"dynf_get", dyn_set, (void *)"dynf_set" ); ASSERT_EQ(IB_OK, rc); ASSERT_TRUE(dynf); ASSERT_EQ(9UL, dynf->nlen); ASSERT_EQ(0, memcmp("test_dynf", dynf->name, 9)); /* Get the value from the dynamic field. */ rc = ib_field_value_ex(dynf, ib_ftype_nulstr_out(&fval), (void *)"fetch1", 6 ); ASSERT_EQ(IB_OK, rc); ASSERT_TRUE(fval); ASSERT_EQ( std::string("testval_dynf_get_fetch1_call01"), fval ); /* Get the value from the dynamic field again. */ rc = ib_field_value_ex(dynf, ib_ftype_nulstr_out(&fval), (void *)"fetch2", 6 ); ASSERT_EQ(IB_OK, rc); ASSERT_TRUE(fval); ASSERT_EQ( std::string("testval_dynf_get_fetch2_call02"), fval ); /* Set */ rc = ib_field_setv_ex(dynf, (void *)"val1", (void *)"set1", 4); ASSERT_EQ(IB_OK, rc); ASSERT_EQ(std::string("testval_dynf_set_set1_val1_call03"), g_dyn_call_val); /* Reset call counter. */ g_dyn_call_count = 0; /* Create another field with no initial value. */ rc = ib_field_create_dynamic( &cdynf, MM(), IB_S2SL("test_cdynf"), IB_FTYPE_NULSTR, dyn_get_cached, (void *)("cdynf_get"), dyn_set, NULL ); ASSERT_EQ(IB_OK, rc); ASSERT_TRUE(cdynf); ASSERT_EQ(10UL, cdynf->nlen); ASSERT_EQ(0, memcmp("test_cdynf", cdynf->name, 10)); /* Get the value from the dynamic field. */ rc = ib_field_value_ex(cdynf, ib_ftype_nulstr_out(&fval), (void *)"fetch1", 6 ); ASSERT_EQ(IB_OK, rc); ASSERT_TRUE(fval); ASSERT_EQ( std::string("testval_cdynf_get_fetch1_call01"), fval ); /* Get the value from the dynamic field again. */ rc = ib_field_value_ex(cdynf, ib_ftype_nulstr_out(&fval), NULL, 0 ); ASSERT_EQ(IB_OK, rc); ASSERT_TRUE(fval); ASSERT_EQ( std::string("testval_cdynf_get_fetch1_call01"), fval ); }