Esempio n. 1
0
static void verify_conf(conflate_config_t* a, conflate_config_t* b)
{
    fail_unless(count_nulls(a) == count_nulls(b),
                "Differing number of NULLs between a and b");

    fail_unless(strcmp(a->jid, b->jid) == 0,
                "jids are different.");
    fail_unless(strcmp(a->pass, b->pass) == 0,
                "passwords are different.");
    if (a->host == NULL && b->host == NULL) {
        /* OK */
    } else if (a->host == NULL) {
        fail("a was null and b was not null");
    } else if (b->host == NULL) {
        fail("b was null and a was not null");
    } else {
        fail_unless(strcmp(a->host, b->host) == 0,
                    "hosts are different.");
    }
    fail_unless(strcmp(a->software, b->software) == 0,
                "software is different.");
    fail_unless(strcmp(a->version, b->version) == 0,
                "versions are different.");

    fail_unless(a->userdata == b->userdata, "userdata is different.");
    fail_unless(a->new_config == b->new_config, "new_config is different.");
}
Esempio n. 2
0
/*
 * num_nonnulls()
 *	Count the number of non-NULL arguments
 */
Datum
pg_num_nonnulls(PG_FUNCTION_ARGS)
{
	int32		nargs,
				nulls;

	if (!count_nulls(fcinfo, &nargs, &nulls))
		PG_RETURN_NULL();

	PG_RETURN_INT32(nargs - nulls);
}
Esempio n. 3
0
END_TEST

START_TEST (test_dup_with_host)
{
    conflate_config_t conf;

    init_config(&conf);
    conf.host = "example.com";
    int count = count_nulls(&conf);
    fail_unless(count == 0, "Expected exactly one null. Got: %d", count);

    verify_conf(&conf, dup_conf(conf));
}