Example #1
0
int main() {
    tap_plan(18);
    
    //is/isn't
    tap_is('a','a', "'a' is 'a'");
    tap_is(1, 1, "1 is 1");
    tap_is(4.0, 4.0, "4.0 is 4.0");
    tap_isnt('a', 'b', "'a' isn't 'b'");
    tap_isnt(0, 1, "0 isn't 1");
    tap_isnt(2.0, 4.0, "2.0 isn't 4.0");
    
    //todo
    tap_todo(4, "strings");
    tap_is_str("foo", "foo", "\"foo\" is \"foo\"");
    tap_is_str("1", "1", "\"1\" is \"1\"");
    tap_isnt_str("foo", "bar", "\"foo\" isn't \"bar\"");
    tap_isnt_str("0", "1", "\"0\" isn't \"1\"");
    
    //like/unlike
    tap_like("foobar", "foo*", REG_EXTENDED, "\"foobar\" is like \"foo*\"");
    tap_like("foobar", "^foo", REG_EXTENDED, "\"foobar\" is like \"^foo\"");
    tap_like("foobar", "bar$", REG_EXTENDED, "\"foobar\" is like \"bar$\"");
    tap_todo(2, "don't care");
    tap_like("foobar", "fooba[rz]", REG_EXTENDED, "\"foobar\" is like \"fooba[rz]\"");
    tap_unlike("foobar", "foobaz", REG_EXTENDED, "\"foobar\" is unlike \"foobaz\"");
    tap_unlike("foobar", "baz$", REG_EXTENDED, "\"foobar\" is unlike \"baz$\"");
    tap_unlike("foobar", "foo$", REG_EXTENDED, "\"foobar\" is unlike \"foo$\"");
    tap_unlike("foobar", "^foo$", REG_EXTENDED, "\"foobar\" is unlike \"^foo$\"");
    
    return tap_status();
}
Example #2
0
static void test(void) {
    tap_plan(0);
    tap_plan(1);
    tap_plan(2);

    tap_skip_all(NULL);
    tap_skip_all("foo %s", "bar");

    tap_skip(0, NULL);
    tap_skip(1, "foo %s", "bar");
    tap_skip(2, NULL);

    tap_diag("foo");
    tap_diag("foo %s", "bar");

    tap_bail(NULL);
    tap_bail("foo %s", "bar");

    tap_ok(0, NULL);
    tap_ok(1, NULL);
    tap_ok(0, "%s", "foo");
    tap_ok(1, "%s", "foo");

    tap_is_str("foo", "foo", NULL);
    tap_is_str("foo", "bar", NULL);
    tap_is_str("foo", "foo", "foo %s", "bar");
    tap_is_str("foo", "bar", "foo %s", "bar");
    tap_is_str(NULL, NULL, NULL);
    tap_is_str(NULL, "bar", NULL);

    tap_is_int(1, 1, NULL);
    tap_is_int(1, 0, NULL);
    tap_is_int(1, 1, "foo %s", "bar");
    tap_is_int(1, 0, "foo %s", "bar");

    tap_is_float(1.0, 1.0, 0.1, NULL);
    tap_is_float(1.0, 2.0, 0.1, NULL);
    tap_is_float(1.0, 1.0, 0.1, "foo %s", "bar");
    tap_is_float(1.0, 2.0, 0.1, "foo %s", "bar");

    tap_done_testing();
}
Example #3
0
int main(void) {
    tap_plan(12);

    tap_is_str(strcasechr("aBcDeF", 'd'), "DeF", NULL);
    tap_is_str(strcasechr("aBcDeF", 'D'), "DeF", NULL);
    tap_is_str(strcasechr("aBcDeF", 'e'), "eF", NULL);
    tap_is_str(strcasechr("aBcDeF", 'E'), "eF", NULL);

    tap_is_str(strfuzzy("abcdefg", "adg"), "g", NULL);
    tap_is_str(strfuzzy("abcdefg", "cdg"), "g", NULL);
    tap_is_str(strfuzzy("abcdefg", "ace"), "efg", NULL);
    tap_is_str(strfuzzy("abcdefg", "cb"), NULL, NULL);

    tap_is_str(strcasefuzzy("abcdefg", "aDg"), "g", NULL);
    tap_is_str(strcasefuzzy("abcdefg", "cDg"), "g", NULL);
    tap_is_str(strcasefuzzy("abcdefg", "aCe"), "efg", NULL);
    tap_is_str(strcasefuzzy("abcdefg", "cB"), NULL, NULL);

    return tap_finish();
}
int main(void) {
	pu_log_action_t *a;

	tap_plan(31);

	tap_ok((a = pu_log_action_parse("installed pacutils (1.0.0)")) != NULL, "install");
	tap_is_int(a->operation, PU_LOG_OPERATION_INSTALL, "operation");
	tap_is_str(a->target, "pacutils", "package");
	tap_is_str(a->new_version, "1.0.0", "new_version");
	tap_is_str(a->old_version, NULL, "old_version");
	pu_log_action_free(a);

	tap_ok((a = pu_log_action_parse("upgraded pacutils (1.0.0 -> 2.0.0)")) != NULL, "upgrade");
	tap_is_int(a->operation, PU_LOG_OPERATION_UPGRADE, "operation");
	tap_is_str(a->target, "pacutils", "package");
	tap_is_str(a->new_version, "2.0.0", "new_version");
	tap_is_str(a->old_version, "1.0.0", "old_version");
	pu_log_action_free(a);

	tap_ok((a = pu_log_action_parse("downgraded pacutils (2.0.0 -> 1.0.0)")) != NULL, "downgrade");
	tap_is_int(a->operation, PU_LOG_OPERATION_DOWNGRADE, "operation");
	tap_is_str(a->target, "pacutils", "package");
	tap_is_str(a->new_version, "1.0.0", "new_version");
	tap_is_str(a->old_version, "2.0.0", "old_version");
	pu_log_action_free(a);

	tap_ok((a = pu_log_action_parse("reinstalled pacutils (1.0.0)")) != NULL, "reinstall");
	tap_is_int(a->operation, PU_LOG_OPERATION_REINSTALL, "operation");
	tap_is_str(a->target, "pacutils", "package");
	tap_is_str(a->new_version, "1.0.0", "new_version");
	tap_is_str(a->old_version, "1.0.0", "old_version");
	pu_log_action_free(a);

	tap_ok((a = pu_log_action_parse("removed pacutils (1.0.0)")) != NULL, "removed");
	tap_is_int(a->operation, PU_LOG_OPERATION_REMOVE, "operation");
	tap_is_str(a->target, "pacutils", "package");
	tap_is_str(a->new_version, NULL, "new_version");
	tap_is_str(a->old_version, "1.0.0", "old_version");
	pu_log_action_free(a);

	tap_ok(pu_log_action_parse("") == NULL, "empty input");
	tap_is_int(errno, EINVAL, "errno");

	tap_ok(pu_log_action_parse(NULL) == NULL, "NULL input");
	tap_is_int(errno, EINVAL, "errno");

	tap_ok(pu_log_action_parse("not a valid action") == NULL, "invalid input");
	tap_is_int(errno, EINVAL, "errno");

	return tap_finish();
}