mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-24 14:22:28 +00:00
Improve backwards compatibility with GNU Make
This commit is contained in:
parent
fabf7f9f02
commit
1f2288be6e
18 changed files with 412 additions and 96 deletions
|
@ -19,34 +19,101 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
#define T(NAME) NAME
|
||||
#define S(S) S
|
||||
#define C(C) C
|
||||
#include "test/libc/str/strrchr_test.inc"
|
||||
#undef C
|
||||
#undef S
|
||||
#undef T
|
||||
TEST(strrchr, test) {
|
||||
EXPECT_EQ(NULL, strrchr("hello", 'z'));
|
||||
EXPECT_STREQ("lo", strrchr("hello", 'l'));
|
||||
EXPECT_STREQ("llo", strchr("hello", 'l'));
|
||||
EXPECT_STREQ("hello", strrchr("hello", 'h'));
|
||||
EXPECT_STREQ("ello", strrchr("hello", 'e'));
|
||||
EXPECT_STREQ("o", strrchr("hello", 'o'));
|
||||
}
|
||||
|
||||
#define T(NAME) NAME##16
|
||||
#define S(S) u##S
|
||||
#define C(C) u##C
|
||||
#define strrchr(x, y) strrchr16(x, y)
|
||||
#define strchr(x, y) strchr16(x, y)
|
||||
#include "test/libc/str/strrchr_test.inc"
|
||||
#undef strchr
|
||||
#undef strrchr
|
||||
#undef C
|
||||
#undef S
|
||||
#undef T
|
||||
TEST(strrchr, simdVectorStuffIsntBroken) {
|
||||
EXPECT_EQ(NULL, strrchr("--------------------------------", 'x'));
|
||||
EXPECT_STREQ("x", strrchr("-------------------------------x", 'x'));
|
||||
EXPECT_STREQ("x-------------------------------",
|
||||
strrchr("x-------------------------------", 'x'));
|
||||
EXPECT_STREQ("x"
|
||||
"z-------------------------------",
|
||||
strrchr("x"
|
||||
"z-------------------------------",
|
||||
'x'));
|
||||
EXPECT_STREQ("x-------------------------------"
|
||||
"y-------------------------------",
|
||||
strrchr("x-------------------------------"
|
||||
"y-------------------------------",
|
||||
'x'));
|
||||
EXPECT_STREQ("x"
|
||||
"z-------------------------------"
|
||||
"y-------------------------------",
|
||||
strrchr("x"
|
||||
"z-------------------------------"
|
||||
"y-------------------------------",
|
||||
'x'));
|
||||
}
|
||||
|
||||
#define T(NAME) NAME##32
|
||||
#define S(S) L##S
|
||||
#define C(C) L##C
|
||||
#define strchr(x, y) wcschr(x, y)
|
||||
#define strrchr(x, y) wcsrchr(x, y)
|
||||
#include "test/libc/str/strrchr_test.inc"
|
||||
#undef strchr
|
||||
#undef strrchr
|
||||
#undef C
|
||||
#undef S
|
||||
#undef T
|
||||
TEST(strrchr16, test) {
|
||||
EXPECT_EQ(NULL, strrchr16(u"hello", 'z'));
|
||||
EXPECT_STREQ(u"lo", strrchr16(u"hello", 'l'));
|
||||
EXPECT_STREQ(u"llo", strchr16(u"hello", 'l'));
|
||||
EXPECT_STREQ(u"hello", strrchr16(u"hello", 'h'));
|
||||
EXPECT_STREQ(u"ello", strrchr16(u"hello", 'e'));
|
||||
EXPECT_STREQ(u"o", strrchr16(u"hello", 'o'));
|
||||
}
|
||||
|
||||
TEST(strrchr16, simdVectorStuffIsntBroken) {
|
||||
EXPECT_EQ(NULL, strrchr16(u"--------------------------------", 'x'));
|
||||
EXPECT_STREQ(u"x", strrchr16(u"-------------------------------x", 'x'));
|
||||
EXPECT_STREQ(u"x-------------------------------",
|
||||
strrchr16(u"x-------------------------------", 'x'));
|
||||
EXPECT_STREQ(u"x"
|
||||
u"z-------------------------------",
|
||||
strrchr16(u"x"
|
||||
u"z-------------------------------",
|
||||
'x'));
|
||||
EXPECT_STREQ(u"x-------------------------------"
|
||||
u"y-------------------------------",
|
||||
strrchr16(u"x-------------------------------"
|
||||
u"y-------------------------------",
|
||||
'x'));
|
||||
EXPECT_STREQ(u"x"
|
||||
u"z-------------------------------"
|
||||
u"y-------------------------------",
|
||||
strrchr16(u"x"
|
||||
u"z-------------------------------"
|
||||
u"y-------------------------------",
|
||||
'x'));
|
||||
}
|
||||
|
||||
TEST(wcsrchr, test) {
|
||||
EXPECT_EQ(NULL, wcsrchr(L"hello", 'z'));
|
||||
EXPECT_STREQ(L"lo", wcsrchr(L"hello", 'l'));
|
||||
EXPECT_STREQ(L"llo", wcschr(L"hello", 'l'));
|
||||
EXPECT_STREQ(L"hello", wcsrchr(L"hello", 'h'));
|
||||
EXPECT_STREQ(L"ello", wcsrchr(L"hello", 'e'));
|
||||
EXPECT_STREQ(L"o", wcsrchr(L"hello", 'o'));
|
||||
}
|
||||
|
||||
TEST(wcsrchr, simdVectorStuffIsntBroken) {
|
||||
EXPECT_EQ(NULL, wcsrchr(L"--------------------------------", 'x'));
|
||||
EXPECT_STREQ(L"x", wcsrchr(L"-------------------------------x", 'x'));
|
||||
EXPECT_STREQ(L"x-------------------------------",
|
||||
wcsrchr(L"x-------------------------------", 'x'));
|
||||
EXPECT_STREQ(L"x"
|
||||
L"z-------------------------------",
|
||||
wcsrchr(L"x"
|
||||
L"z-------------------------------",
|
||||
'x'));
|
||||
EXPECT_STREQ(L"x-------------------------------"
|
||||
L"y-------------------------------",
|
||||
wcsrchr(L"x-------------------------------"
|
||||
L"y-------------------------------",
|
||||
'x'));
|
||||
EXPECT_STREQ(L"x"
|
||||
L"z-------------------------------"
|
||||
L"y-------------------------------",
|
||||
wcsrchr(L"x"
|
||||
L"z-------------------------------"
|
||||
L"y-------------------------------",
|
||||
'x'));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue