static void assert_concatenated_nvpairs(LogTransportAuxData *aux, const gchar *expected) { gchar *concatenated = _concat_nvpairs(aux);; assert_string(concatenated, expected, "foreach() didn't return all-added nvpairs"); g_free(concatenated); }
static void test_aux_data_copy_creates_an_identical_copy(void) { LogTransportAuxData *aux = construct_aux_with_some_data(); LogTransportAuxData aux_copy; gchar *orig, *copy; log_transport_aux_data_copy(&aux_copy, aux); orig = _concat_nvpairs(aux); copy = _concat_nvpairs(&aux_copy); assert_string(orig, copy, "copy incorrectly copied aux->nvpairs"); g_free(orig); g_free(copy); log_transport_aux_data_destroy(&aux_copy); free_aux(aux); }
static void test_aux_data_copy_separates_the_copies(void) { LogTransportAuxData *aux = construct_aux_with_some_data(); LogTransportAuxData aux_copy; gchar *orig, *copy; log_transport_aux_data_copy(&aux_copy, aux); log_transport_aux_data_add_nv_pair(aux, "super", "lativus"); orig = _concat_nvpairs(aux); copy = _concat_nvpairs(&aux_copy); assert_false(strcmp(orig, copy) == 0, "copy incorrectly copied aux->nvpairs as change to one of them affected the other, orig=%s, copy=%s", orig, copy); g_free(orig); g_free(copy); log_transport_aux_data_destroy(&aux_copy); free_aux(aux); }