mirror of
https://github.com/git/git.git
synced 2026-01-28 11:32:24 +00:00
fixup! test-strcmp-offset: created test for strcmp_offset
The return value of strcmp() is actually not defined apart from the sign... So while MSVC's strcmp() returns -1, 0 or +1 (which is perfectly legal), GNU libc's strcmp() returns the difference of the differing byte, if any. Let's adjust our test to account for that. While at it, also fix white-space issues and mark the test script as executable. With this patch, the tests pass on Linux, too. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
@@ -23,23 +23,28 @@ int try_pair(const char *sa, const char *sb, int first_change)
|
||||
{
|
||||
int failed = 0;
|
||||
int offset, r_exp, r_tst;
|
||||
|
||||
|
||||
r_exp = strcmp(sa, sb);
|
||||
r_tst = strcmp_offset(sa, sb, &offset);
|
||||
if (r_tst != r_exp) {
|
||||
error("FAIL: '%s' vs '%s', result expect %d, observed %d\n",
|
||||
sa, sb, r_exp, r_tst);
|
||||
failed = 1;
|
||||
if ((r_tst < 0 && r_exp < 0) || (r_tst > 0 && r_exp > 0))
|
||||
warning("'%s' vs '%s', imprecise result: %d != %d",
|
||||
sa, sb, r_exp, r_tst);
|
||||
else {
|
||||
error("'%s' vs '%s', result expect %d, observed %d",
|
||||
sa, sb, r_exp, r_tst);
|
||||
failed = 1;
|
||||
}
|
||||
}
|
||||
if (offset != first_change) {
|
||||
error("FAIL: '%s' vs '%s', offset expect %d, observed %d\n",
|
||||
sa, sb, first_change, offset);
|
||||
error("'%s' vs '%s', offset expect %d, observed %d",
|
||||
sa, sb, first_change, offset);
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
return failed;
|
||||
}
|
||||
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
{
|
||||
int failed = 0;
|
||||
|
||||
0
t/t0065-strcmp-offset.sh
Normal file → Executable file
0
t/t0065-strcmp-offset.sh
Normal file → Executable file
Reference in New Issue
Block a user