Merge branch 'rs/t-example-simplify'

Unit test simplification.

* rs/t-example-simplify:
  t-example-decorate: remove test messages
This commit is contained in:
Junio C Hamano
2024-08-15 13:22:11 -07:00

View File

@ -15,36 +15,29 @@ static void t_add(struct test_vars *vars)
{ {
void *ret = add_decoration(&vars->n, vars->one, &vars->decoration_a); void *ret = add_decoration(&vars->n, vars->one, &vars->decoration_a);
if (!check(ret == NULL)) check(ret == NULL);
test_msg("when adding a brand-new object, NULL should be returned");
ret = add_decoration(&vars->n, vars->two, NULL); ret = add_decoration(&vars->n, vars->two, NULL);
if (!check(ret == NULL)) check(ret == NULL);
test_msg("when adding a brand-new object, NULL should be returned");
} }
static void t_readd(struct test_vars *vars) static void t_readd(struct test_vars *vars)
{ {
void *ret = add_decoration(&vars->n, vars->one, NULL); void *ret = add_decoration(&vars->n, vars->one, NULL);
if (!check(ret == &vars->decoration_a)) check(ret == &vars->decoration_a);
test_msg("when readding an already existing object, existing decoration should be returned");
ret = add_decoration(&vars->n, vars->two, &vars->decoration_b); ret = add_decoration(&vars->n, vars->two, &vars->decoration_b);
if (!check(ret == NULL)) check(ret == NULL);
test_msg("when readding an already existing object, existing decoration should be returned");
} }
static void t_lookup(struct test_vars *vars) static void t_lookup(struct test_vars *vars)
{ {
void *ret = lookup_decoration(&vars->n, vars->one); void *ret = lookup_decoration(&vars->n, vars->one);
if (!check(ret == NULL)) check(ret == NULL);
test_msg("lookup should return added declaration");
ret = lookup_decoration(&vars->n, vars->two); ret = lookup_decoration(&vars->n, vars->two);
if (!check(ret == &vars->decoration_b)) check(ret == &vars->decoration_b);
test_msg("lookup should return added declaration");
ret = lookup_decoration(&vars->n, vars->three); ret = lookup_decoration(&vars->n, vars->three);
if (!check(ret == NULL)) check(ret == NULL);
test_msg("lookup for unknown object should return NULL");
} }
static void t_loop(struct test_vars *vars) static void t_loop(struct test_vars *vars)
@ -55,8 +48,7 @@ static void t_loop(struct test_vars *vars)
if (vars->n.entries[i].base) if (vars->n.entries[i].base)
objects_noticed++; objects_noticed++;
} }
if (!check_int(objects_noticed, ==, 2)) check_int(objects_noticed, ==, 2);
test_msg("should have 2 objects");
} }
int cmd_main(int argc UNUSED, const char **argv UNUSED) int cmd_main(int argc UNUSED, const char **argv UNUSED)