mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibC: Implement wctrans
This commit is contained in:
parent
7b17230d7a
commit
ff0ab8b9a9
Notes:
sideshowbarker
2024-07-18 03:44:54 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/ff0ab8b9a96 Pull-request: https://github.com/SerenityOS/serenity/pull/10097 Reviewed-by: https://github.com/bgianfo ✅
2 changed files with 25 additions and 3 deletions
|
@ -28,3 +28,14 @@ TEST_CASE(wctype)
|
|||
EXPECT(wctype("") == 0);
|
||||
EXPECT(wctype("abc") == 0);
|
||||
}
|
||||
|
||||
TEST_CASE(wctrans)
|
||||
{
|
||||
// Test that existing character mappings return non-zero wctrans values.
|
||||
EXPECT(wctrans("tolower") != 0);
|
||||
EXPECT(wctrans("toupper") != 0);
|
||||
|
||||
// Test that invalid character mappings return the "invalid" wctrans value (0).
|
||||
EXPECT(wctrans("") == 0);
|
||||
EXPECT(wctrans("abc") == 0);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,12 @@ enum {
|
|||
WCTYPE_XDIGIT,
|
||||
};
|
||||
|
||||
enum {
|
||||
WCTRANS_INVALID = 0,
|
||||
WCTRANS_TOLOWER,
|
||||
WCTRANS_TOUPPER,
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
|
||||
int iswalnum(wint_t wc)
|
||||
|
@ -149,9 +155,14 @@ wint_t towctrans(wint_t, wctrans_t)
|
|||
TODO();
|
||||
}
|
||||
|
||||
wctrans_t wctrans(const char*)
|
||||
wctrans_t wctrans(const char* charclass)
|
||||
{
|
||||
dbgln("FIXME: Implement wctrans()");
|
||||
TODO();
|
||||
if (strcmp(charclass, "tolower") == 0)
|
||||
return WCTRANS_TOLOWER;
|
||||
|
||||
if (strcmp(charclass, "toupper") == 0)
|
||||
return WCTRANS_TOUPPER;
|
||||
|
||||
return WCTRANS_INVALID;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue