authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-09-12 22:32:15-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-09-12 22:32:15-07:00
log7a941391d86a863ab08b24d161dcad8eb047f1bd
tree57d51469bec3b345857a4e37acb5110b33315da9
parent78729c4939eabe9cdfe85492ca2e2eb43fdc8d46

universal-libc: fix strncmp tests

The specification for this function is that it returns a positive value, zero, or negative value, not that it returns the difference between ascii values.

1 files changed, 4 insertions(+), 4 deletions(-)

lib/c.zig+4-4
...@@ -298,10 +298,10 @@ fn strerror(errnum: c_int) callconv(.C) [*:0]const u8 {...@@ -298,10 +298,10 @@ fn strerror(errnum: c_int) callconv(.C) [*:0]const u8 {
298}298}
299299
300test "strncmp" {300test "strncmp" {
301 try std.testing.expect(strncmp("a", "b", 1) == -1);301 try std.testing.expect(strncmp("a", "b", 1) < 0);
302 try std.testing.expect(strncmp("a", "c", 1) == -2);302 try std.testing.expect(strncmp("a", "c", 1) < 0);
303 try std.testing.expect(strncmp("b", "a", 1) == 1);303 try std.testing.expect(strncmp("b", "a", 1) > 0);
304 try std.testing.expect(strncmp("\xff", "\x02", 1) == 253);304 try std.testing.expect(strncmp("\xff", "\x02", 1) > 0);
305}305}
306306
307// TODO we should be able to put this directly in std/linux/x86_64.zig but307// TODO we should be able to put this directly in std/linux/x86_64.zig but