static void test_find (ACE_Naming_Context &ns_context, int sign, int result) { char temp_val[BUFSIZ]; char temp_type[BUFSIZ]; int array [ACE_NS_MAX_ENTRIES]; randomize (array, sizeof array / sizeof (int)); // do the finds for (size_t i = 0; i < ACE_NS_MAX_ENTRIES; i++) { if (sign == 1) { ACE_OS::sprintf (temp_val, "%s%d", "value", array[i]); ACE_OS::sprintf (temp_type, "%s%d", "type", array[i]); } else { ACE_OS::sprintf (temp_val, "%s%d", "value", -array[i]); ACE_OS::sprintf (temp_type, "%s%d", "type", -array[i]); } ACE_OS::sprintf (name, "%s%d", "name", array[i]); ACE_WString w_name (name); ACE_WString w_value; char *type_out = 0; ACE_WString val (temp_val); ACE_ASSERT (ns_context.resolve (w_name, w_value, type_out) == result); char *l_value = w_value.char_rep (); if (l_value) { ACE_ASSERT (w_value == val); if (ns_context.name_options ()->debug ()) { if (type_out) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Name: %s\tValue: %s\tType: %s\n"), name, l_value, type_out)); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Name: %s\tValue: %s\n"), name, l_value)); } if (type_out) { ACE_ASSERT (ACE_OS::strcmp (type_out, temp_type) == 0); delete[] type_out; } } delete[] l_value; } }
static void test_find_failure (ACE_Naming_Context &ns_context) { ACE_OS::sprintf (name, "%s", "foo-bar"); ACE_WString w_name (name); ACE_WString w_value; char *l_type = 0; // Do the finds. for (size_t i = 0; i < ACE_NS_MAX_ENTRIES; i++) ACE_ASSERT (ns_context.resolve (w_name, w_value, l_type) == -1); }
void unbind (ACE_Naming_Context *ns_context, int result) { // do the unbinds for (int i = 1; i <= ACE_NS_MAX_ENTRIES; i++) { ACE_OS::sprintf (name, "%s%d", "name", i); ACE_WString w_name (name); if (ns_context->unbind (w_name) != result) { ACE_ERROR ((LM_ERROR, "unbind failed!")); } } }
static void test_unbind (ACE_Naming_Context &ns_context) { int array [ACE_NS_MAX_ENTRIES]; randomize (array, sizeof array / sizeof (int)); // do the unbinds for (size_t i = 0; i < ACE_NS_MAX_ENTRIES; i++) { ACE_OS::sprintf (name, "%s%d", "name", array[i]); ACE_WString w_name (name); ACE_ASSERT (ns_context.unbind (w_name) != -1); } }
void find (ACE_Naming_Context *ns_context, int sign, int result) { char temp_val[BUFSIZ]; char temp_type[BUFSIZ]; // do the finds for (int i = 1; i <= ACE_NS_MAX_ENTRIES; i++) { ACE_OS::sprintf (name, "%s%d", "name", i); ACE_WString w_name (name); ACE_WString w_value; char *type_out; if (sign == 1) { ACE_OS::sprintf (temp_val, "%s%d", "value", i); ACE_OS::sprintf (temp_type, "%s%d", "type", i); } else { ACE_OS::sprintf (temp_val, "%s%d", "value", -i); ACE_OS::sprintf (temp_type, "%s%d", "type", -i); } ACE_WString val (temp_val); int resolve_result = ns_context->resolve (w_name, w_value, type_out); if (resolve_result != result) { ACE_ERROR ((LM_ERROR, "resolved failed!")); } ACE_ASSERT (resolve_result == result); ACE_UNUSED_ARG (resolve_result); // To avoid compile warning // with ACE_NDEBUG. if (w_value.char_rep ()) { ACE_DEBUG ((LM_DEBUG, "Name: %s\tValue: %s\tType: %s\n", name, w_value.char_rep (), type_out)); ACE_ASSERT (w_value == val); if (type_out) { ACE_ASSERT (::strcmp (type_out, temp_type) == 0); delete[] type_out; } } } }
void rebind (ACE_Naming_Context *ns_context, int result) { // do the rebinds for (int i = 1; i <= ACE_NS_MAX_ENTRIES; i++) { ACE_OS::sprintf (name, "%s%d", "name", i); ACE_WString w_name (name); ACE_OS::sprintf (value, "%s%d", "value", -i); ACE_WString w_value (value); ACE_OS::sprintf (type, "%s%d", "type", -i); if (ns_context->rebind (w_name, w_value, type) != result) { ACE_ERROR ((LM_ERROR, "rebind failed!")); } } }
static void test_unbind (ACE_Naming_Context &ns_context) { int array [ACE_NS_MAX_ENTRIES]; initialize_array (array, sizeof (array) / sizeof (array[0])); randomize (array, sizeof (array) / sizeof (array[0])); // do the unbinds for (size_t i = 0; i < ACE_NS_MAX_ENTRIES; i++) { ACE_OS::sprintf (name, "%s%d", "name", array[i]); ACE_NS_WString w_name (name); int unbind = ns_context.unbind (w_name); ACE_TEST_ASSERT (unbind != -1); } }
void bind (ACE_Naming_Context *ns_context, int result) { // do the binds for (int i = 1; i <= ACE_NS_MAX_ENTRIES; i++) { if (i % 50 == 0) ACE_DEBUG ((LM_DEBUG, ".")); ACE_OS::sprintf (name, "%s%d", "name", i); ACE_WString w_name (name); ACE_OS::sprintf (value, "%s%d", "value", i); ACE_WString w_value (value); ACE_OS::sprintf (type, "%s%d", "type", i); if (ns_context->bind (w_name, w_value, type) != result) { ACE_ERROR ((LM_ERROR, "bind failed!")); } } ACE_DEBUG ((LM_DEBUG, "\n")); }
static void test_bind (ACE_Naming_Context &ns_context) { int array [ACE_NS_MAX_ENTRIES]; initialize_array (array, sizeof (array) / sizeof (array[0])); randomize (array, sizeof (array) / sizeof (array[0])); // do the binds for (size_t i = 0; i < ACE_NS_MAX_ENTRIES; i++) { ACE_OS::sprintf (name, "%s%d", "name", array[i]); ACE_NS_WString w_name (name); ACE_OS::sprintf (value, "%s%d", "value", array[i]); ACE_NS_WString w_value (value); ACE_OS::sprintf (type, "%s%d", "type", array [i]); int bind_result = ns_context.bind (w_name, w_value, type); ACE_TEST_ASSERT (bind_result != -1); } }