diff options
| author | Patrick Steinhardt <ps@pks.im> | 2025-12-06 12:47:32 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-12-07 07:25:15 +0900 |
| commit | d5e4aef3586c07c31e3e4d76ce7fdf0f9843314f (patch) | |
| tree | 5477b82e8ace04f4ea6c450afc19adeb8f465f5a /t/unit-tests/clar/test/suites/combined.c | |
| parent | 9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed (diff) | |
| download | git-d5e4aef3586c07c31e3e4d76ce7fdf0f9843314f.tar.xz | |
t/unit-tests: update clar to 39f11fe
Update clar to commit 39f11fe (Merge pull request #131 from
pks-gitlab/pks-integer-double-evaluation, 2025-12-05). This commit
includes the following changes relevant to Git:
- There are now typesafe integer comparison functions. Furthermore,
the range of comparison functions has been included to also have
relative comparisons, like "greater than".
- There is a new `cl_failf()` macro that allows the caller to specify
an error message with formatting directives.
- The TAP format has been fixed to correctly terminate YAML blocks
with "...\n" instead of "---\n".
Note that we already had a `cl_failf()` function declared in our own
sources. This function is equivalent to the upstreamed function, so we
can simply drop it now.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/unit-tests/clar/test/suites/combined.c')
| -rw-r--r-- | t/unit-tests/clar/test/suites/combined.c | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/t/unit-tests/clar/test/suites/combined.c b/t/unit-tests/clar/test/suites/combined.c index e8b41c98c3..9e9dbc2fb1 100644 --- a/t/unit-tests/clar/test/suites/combined.c +++ b/t/unit-tests/clar/test/suites/combined.c @@ -55,7 +55,12 @@ void test_combined__strings_with_length(void) void test_combined__int(void) { int value = 100; - cl_assert_equal_i(100, value); + cl_assert_equal_i(101, value); +} + +void test_combined__int_note(void) +{ + int value = 100; cl_assert_equal_i_(101, value, "extra note on failing test"); } @@ -83,3 +88,61 @@ void test_combined__null_string(void) cl_assert_equal_s(actual, actual); cl_assert_equal_s_("expected", actual, "this one fails"); } + +void test_combined__failf(void) +{ + cl_failf("some reason: %s", "foo"); +} + +void test_combined__compare_i(void) +{ + int one = 1, two = 2; + + cl_assert_equal_i(one, 1); + cl_assert_equal_i(one, 1); + cl_assert_equal_i_(one, 1, "format"); + cl_assert_lt_i(one, 2); + cl_assert_lt_i_(one, 2, "format"); + cl_assert_le_i(one, 2); + cl_assert_le_i(two, 2); + cl_assert_le_i_(two, 2, "format"); + cl_assert_gt_i(two, 1); + cl_assert_gt_i_(two, 1, "format"); + cl_assert_ge_i(two, 2); + cl_assert_ge_i(3, two); + cl_assert_ge_i_(3, two, "format"); + + cl_assert_lt_i(two, 1); /* this one fails */ +} + +void test_combined__compare_i_with_format(void) +{ + int two = 2; + cl_assert_lt_i_(two, 1, "foo: %s", "bar"); +} + +void test_combined__compare_u(void) +{ + unsigned one = 1, two = 2; + + cl_assert_equal_u(one, 1); + cl_assert_equal_u_(one, 1, "format"); + cl_assert_lt_u(one, 2); + cl_assert_lt_u_(one, 2, "format"); + cl_assert_le_u(one, 2); + cl_assert_le_u(two, 2); + cl_assert_le_u_(two, 2, "format"); + cl_assert_gt_u(two, 1); + cl_assert_gt_u_(two, 1, "format"); + cl_assert_ge_u(two, 2); + cl_assert_ge_u(3, two); + cl_assert_ge_u_(3, two, "format"); + + cl_assert_lt_u(two, 1); /* this one fails */ +} + +void test_combined__compare_u_with_format(void) +{ + unsigned two = 2; + cl_assert_lt_u_(two, 1, "foo: %s", "bar"); +} |
