mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +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
Notes:
sideshowbarker
2024-07-17 19:59:24 +09:00
Author: https://github.com/BertalanD Commit: https://github.com/SerenityOS/serenity/commit/8473f6caeec Pull-request: https://github.com/SerenityOS/serenity/pull/12216 Issue: https://github.com/SerenityOS/serenity/issues/12213 Reviewed-by: https://github.com/linusg ✅
2 changed files with 8 additions and 5 deletions
|
@ -206,8 +206,14 @@ public:
|
|||
|
||||
[[nodiscard]] constexpr int compare(StringView other) const
|
||||
{
|
||||
size_t rlen = min(length(), other.length());
|
||||
int c = (rlen != 0) ? __builtin_memcmp(m_characters, other.m_characters, rlen) : 0;
|
||||
if (m_characters == nullptr)
|
||||
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 (length() < other.length())
|
||||
return -1;
|
||||
|
|
|
@ -42,10 +42,7 @@ TEST_CASE(construct_contents)
|
|||
|
||||
TEST_CASE(equal)
|
||||
{
|
||||
// FIXME: Enable this as soon as it's fixed.
|
||||
#if 0
|
||||
EXPECT_NE(String::empty(), String {});
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE(compare)
|
||||
|
|
Loading…
Reference in a new issue