commit 3ad6f98bbe5a198a435dd175a9785c1e2cdd2bfc
parent dbbc122baeb23ffb63486766014bd45843f68432
Author: Sebastian <sebastian@sebsite.pw>
Date: Tue, 22 Feb 2022 18:46:19 -0500
ascii: improve strcmp tests
In addition to providing tests for eb0d0a9, the tests now only assert
that the return value is less than, greater than, or equal to zero,
rather than asserting that it equals 1 or -1.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/ascii/strcmp.ha b/ascii/strcmp.ha
@@ -98,10 +98,12 @@ export fn strcasecmp(a: str, b: str) (int | void) = {
@test fn strcmp() void = {
assert(strcmp("ABC", "ABC") as int == 0);
- assert(strcmp("ABC", "AB") as int == 1);
- assert(strcmp("AB", "ABC") as int == -1);
- assert(strcmp("BCD", "ABC") as int == 1);
+ assert(strcmp("ABC", "AB") as int > 0);
+ assert(strcmp("AB", "ABC") as int < 0);
+ assert(strcmp("BCD", "ABC") as int > 0);
assert(strcmp("ABC", "こんにちは") is void);
- assert(strcmp("ABC", "abc") as int != 0);
+ assert(strcmp("ABC", "ABCこんにちは") is void);
+ assert(strcmp("ABCこんにちは", "AB") is void);
+ assert(strcmp("ABC", "abc") as int < 0);
assert(strcasecmp("ABC", "abc") as int == 0);
};