Skip to content

Commit 098be29

Browse files
rscharfegitster
authored andcommitted
t-example-decorate: remove test messages
The test_msg() calls only repeat information already present in test descriptions and check definitions, which are shown automatically if the checks fail. Remove the redundant messages to simplify the tests and their output. Here it is with all of them failing before: # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:18 # when adding a brand-new object, NULL should be returned # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:21 # when adding a brand-new object, NULL should be returned not ok 1 - Add 2 objects, one with a non-NULL decoration and one with a NULL decoration. # check "ret == &vars->decoration_a" failed at t/unit-tests/t-example-decorate.c:29 # when readding an already existing object, existing decoration should be returned # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:32 # when readding an already existing object, existing decoration should be returned not ok 2 - When re-adding an already existing object, the old decoration is returned. # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:40 # lookup should return added declaration # check "ret == &vars->decoration_b" failed at t/unit-tests/t-example-decorate.c:43 # lookup should return added declaration # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:46 # lookup for unknown object should return NULL not ok 3 - Lookup returns the added declarations, or NULL if the object was never added. # check "objects_noticed == 2" failed at t/unit-tests/t-example-decorate.c:58 # left: 1 # right: 2 # should have 2 objects not ok 4 - The user can also loop through all entries. 1..4 ... and here with the patch applied: # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:18 # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:20 not ok 1 - Add 2 objects, one with a non-NULL decoration and one with a NULL decoration. # check "ret == &vars->decoration_a" failed at t/unit-tests/t-example-decorate.c:27 # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:29 not ok 2 - When re-adding an already existing object, the old decoration is returned. # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:36 # check "ret == &vars->decoration_b" failed at t/unit-tests/t-example-decorate.c:38 # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:40 not ok 3 - Lookup returns the added declarations, or NULL if the object was never added. # check "objects_noticed == 2" failed at t/unit-tests/t-example-decorate.c:51 # left: 1 # right: 2 not ok 4 - The user can also loop through all entries. 1..4 Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 39bf06a commit 098be29

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

t/unit-tests/t-example-decorate.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,29 @@ static void t_add(struct test_vars *vars)
1515
{
1616
void *ret = add_decoration(&vars->n, vars->one, &vars->decoration_a);
1717

18-
if (!check(ret == NULL))
19-
test_msg("when adding a brand-new object, NULL should be returned");
18+
check(ret == NULL);
2019
ret = add_decoration(&vars->n, vars->two, NULL);
21-
if (!check(ret == NULL))
22-
test_msg("when adding a brand-new object, NULL should be returned");
20+
check(ret == NULL);
2321
}
2422

2523
static void t_readd(struct test_vars *vars)
2624
{
2725
void *ret = add_decoration(&vars->n, vars->one, NULL);
2826

29-
if (!check(ret == &vars->decoration_a))
30-
test_msg("when readding an already existing object, existing decoration should be returned");
27+
check(ret == &vars->decoration_a);
3128
ret = add_decoration(&vars->n, vars->two, &vars->decoration_b);
32-
if (!check(ret == NULL))
33-
test_msg("when readding an already existing object, existing decoration should be returned");
29+
check(ret == NULL);
3430
}
3531

3632
static void t_lookup(struct test_vars *vars)
3733
{
3834
void *ret = lookup_decoration(&vars->n, vars->one);
3935

40-
if (!check(ret == NULL))
41-
test_msg("lookup should return added declaration");
36+
check(ret == NULL);
4237
ret = lookup_decoration(&vars->n, vars->two);
43-
if (!check(ret == &vars->decoration_b))
44-
test_msg("lookup should return added declaration");
38+
check(ret == &vars->decoration_b);
4539
ret = lookup_decoration(&vars->n, vars->three);
46-
if (!check(ret == NULL))
47-
test_msg("lookup for unknown object should return NULL");
40+
check(ret == NULL);
4841
}
4942

5043
static void t_loop(struct test_vars *vars)
@@ -55,8 +48,7 @@ static void t_loop(struct test_vars *vars)
5548
if (vars->n.entries[i].base)
5649
objects_noticed++;
5750
}
58-
if (!check_int(objects_noticed, ==, 2))
59-
test_msg("should have 2 objects");
51+
check_int(objects_noticed, ==, 2);
6052
}
6153

6254
int cmd_main(int argc UNUSED, const char **argv UNUSED)

0 commit comments

Comments
 (0)