mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:07:35 +00:00
LibC: Implement towctrans
This commit is contained in:
parent
8c7b566629
commit
42031f026a
2 changed files with 28 additions and 3 deletions
|
@ -66,3 +66,20 @@ TEST_CASE(iswctype)
|
|||
EXPECT(iswctype(test_chars[i], -1) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(towctrans)
|
||||
{
|
||||
const wint_t test_chars[] = { L'A', L'a', L'F', L'f', L'Z', L'z', L'0', L'\n', L'.', L'\x00' };
|
||||
|
||||
// Test that valid mappings are wired to the correct implementation.
|
||||
for (unsigned int i = 0; i < sizeof(test_chars) / sizeof(test_chars[0]); i++) {
|
||||
EXPECT(towctrans(test_chars[i], wctrans("tolower")) == towlower(test_chars[i]));
|
||||
EXPECT(towctrans(test_chars[i], wctrans("toupper")) == towupper(test_chars[i]));
|
||||
}
|
||||
|
||||
// Test that invalid mappings always return the character unchanged.
|
||||
for (unsigned int i = 0; i < sizeof(test_chars) / sizeof(test_chars[0]); i++) {
|
||||
EXPECT(towctrans(test_chars[i], 0) == test_chars[i]);
|
||||
EXPECT(towctrans(test_chars[i], -1) == test_chars[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,10 +187,18 @@ wint_t towupper(wint_t wc)
|
|||
return __inline_toupper(wc);
|
||||
}
|
||||
|
||||
wint_t towctrans(wint_t, wctrans_t)
|
||||
wint_t towctrans(wint_t wc, wctrans_t desc)
|
||||
{
|
||||
dbgln("FIXME: Implement towctrans()");
|
||||
TODO();
|
||||
switch (desc) {
|
||||
case WCTRANS_TOLOWER:
|
||||
return towlower(wc);
|
||||
|
||||
case WCTRANS_TOUPPER:
|
||||
return towupper(wc);
|
||||
|
||||
default:
|
||||
return wc;
|
||||
}
|
||||
}
|
||||
|
||||
wctrans_t wctrans(const char* charclass)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue