Re: [PATCH 4/4] t/unit-tests: convert strcmp-offset test to clar framework
From: Patrick Steinhardt <hidden>
Date: 2025-01-31 11:44:06
On Thu, Jan 30, 2025 at 10:13:34AM +0100, Seyi Kuforiji wrote:
Adapt strcmp-offset test script to clar framework by using clar assertions where necessary. Test functions are created as standalone to test different test cases.
Same comment here regarding the message.
quoted hunk ↗ jump to hunk
diff --git a/t/unit-tests/u-strcmp-offset.c b/t/unit-tests/u-strcmp-offset.c new file mode 100644 index 0000000000..7e8e9acf3c --- /dev/null +++ b/t/unit-tests/u-strcmp-offset.c@@ -0,0 +1,45 @@ +#include "unit-test.h" +#include "read-cache-ll.h" + +static void check_strcmp_offset(const char *string1, const char *string2, + int expect_result, uintmax_t expect_offset) +{ + size_t offset; + int result = strcmp_offset(string1, string2, &offset); + + /* + * Because different CRTs behave differently, only rely on signs of the + * result values. + */ + result = (result < 0 ? -1 : + result > 0 ? 1 : + 0); + + cl_assert_equal_i(result, expect_result); + cl_assert_equal_i((uintmax_t)offset, expect_offset); +} + +void test_strcmp_offset__empty(void) +{ + check_strcmp_offset("", "", 0, 0);
This test didn't exist in the preimage, right? I don't mind adding it, but it is somewhat surprising as the commit message does not mention this at all. Patrick