static void _test_str(unit_state *state, int expected) { rcint *a = rcint_alloc(expected); return_unless(, a); rcstr *got = rc2str(a); return_unless(, got); rc_release(a); static char buffer[16]; snprintf(buffer, sizeof(buffer), "%d", expected); assert_eq_str(state, buffer, rcstr_str(got)); rc_release(got); }
void test_lookup_existing_user(test_t *t) { mem_init(); user_t *user = user_new_with_name("test"); mem_store_user(user); user_t *found = NULL; mem_res res = mem_lookup_user("test", &found); assert_eq_int(t,MEM_OK, res); assert_eq_str(t,"test", found->username); user_free(user); }
void test_parse_reg(test_t *t) { command_t cmd = parse(str_new("REG test pass")); assert(t,"command code is not CMD_REG", CMD_REG == cmd.code); assert_eq_str(t, "test pass", cmd.args.val); }
void test_parse_pwd(test_t *t) { command_t cmd = parse(str_new("PWD new old")); assert(t,"command code is not CMD_PWD", CMD_PWD == cmd.code); assert_eq_str(t, "new old", cmd.args.val); }