mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:28:11 +00:00
AK+Tests: Make null strings compare less than non-null strings
This behavior regressed in ca58c71faa
.
Fixes #12213
This commit is contained in:
parent
3bb580ba1d
commit
8473f6caee
2 changed files with 8 additions and 5 deletions
|
@ -206,8 +206,14 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] constexpr int compare(StringView other) const
|
[[nodiscard]] constexpr int compare(StringView other) const
|
||||||
{
|
{
|
||||||
size_t rlen = min(length(), other.length());
|
if (m_characters == nullptr)
|
||||||
int c = (rlen != 0) ? __builtin_memcmp(m_characters, other.m_characters, rlen) : 0;
|
return other.m_characters ? -1 : 0;
|
||||||
|
|
||||||
|
if (other.m_characters == nullptr)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
size_t rlen = min(m_length, other.m_length);
|
||||||
|
int c = __builtin_memcmp(m_characters, other.m_characters, rlen);
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
if (length() < other.length())
|
if (length() < other.length())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -42,10 +42,7 @@ TEST_CASE(construct_contents)
|
||||||
|
|
||||||
TEST_CASE(equal)
|
TEST_CASE(equal)
|
||||||
{
|
{
|
||||||
// FIXME: Enable this as soon as it's fixed.
|
|
||||||
#if 0
|
|
||||||
EXPECT_NE(String::empty(), String {});
|
EXPECT_NE(String::empty(), String {});
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(compare)
|
TEST_CASE(compare)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue