Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/unit-tests/u-strcmp-offset.c # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / unit-tests / u-strcmp-offset.c` 45 lines ยท 943 bytes Raw Blame History 1 #include "unit-test.h" 2 #include "read-cache-ll.h" 3 4 static void check_strcmp_offset(const char *string1, const char *string2, 5 int expect_result, uintmax_t expect_offset) 6 { 7 size_t offset; 8 int result = strcmp_offset(string1, string2, &offset); 9 10 /* 11 * Because different CRTs behave differently, only rely on signs of the 12 * result values. 13 */ 14 result = (result < 0 ? -1 : 15 result > 0 ? 1 : 16 0); 17 18 cl_assert_equal_i(result, expect_result); 19 cl_assert_equal_i((uintmax_t)offset, expect_offset); 20 } 21 22 void test_strcmp_offset__empty(void) 23 { 24 check_strcmp_offset("", "", 0, 0); 25 } 26 27 void test_strcmp_offset__equal(void) 28 { 29 check_strcmp_offset("abc", "abc", 0, 3); 30 } 31 32 void test_strcmp_offset__different(void) 33 { 34 check_strcmp_offset("abc", "def", -1, 0); 35 } 36 37 void test_strcmp_offset__mismatch(void) 38 { 39 check_strcmp_offset("abc", "abz", -1, 2); 40 } 41 42 void test_strcmp_offset__different_length(void) 43 { 44 check_strcmp_offset("abc", "abcdef", -1, 3); 45 }