mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:27:35 +00:00
AK: Ensure string types are actually considered hash-compatible
The AnyString concept is currently broken because it checks whether a StringView is constructible from a type T. The StringView constructors, however, only accept constant rvalue references - i.e. `T const&`. This also adds a test to ensure this continues to work.
This commit is contained in:
parent
2f67f2ba3d
commit
f31bd190b0
2 changed files with 25 additions and 1 deletions
|
@ -6,9 +6,33 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Concepts.h>
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringUtils.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
TEST_CASE(hash_compatible)
|
||||
{
|
||||
static_assert(AK::Concepts::HashCompatible<String, StringView>);
|
||||
static_assert(AK::Concepts::HashCompatible<String, FlyString>);
|
||||
static_assert(AK::Concepts::HashCompatible<StringView, String>);
|
||||
static_assert(AK::Concepts::HashCompatible<StringView, FlyString>);
|
||||
static_assert(AK::Concepts::HashCompatible<FlyString, String>);
|
||||
static_assert(AK::Concepts::HashCompatible<FlyString, StringView>);
|
||||
|
||||
static_assert(AK::Concepts::HashCompatible<DeprecatedString, StringView>);
|
||||
static_assert(AK::Concepts::HashCompatible<DeprecatedString, DeprecatedFlyString>);
|
||||
static_assert(AK::Concepts::HashCompatible<StringView, DeprecatedString>);
|
||||
static_assert(AK::Concepts::HashCompatible<StringView, DeprecatedFlyString>);
|
||||
static_assert(AK::Concepts::HashCompatible<DeprecatedFlyString, DeprecatedString>);
|
||||
static_assert(AK::Concepts::HashCompatible<DeprecatedFlyString, StringView>);
|
||||
|
||||
static_assert(AK::Concepts::HashCompatible<StringView, ByteBuffer>);
|
||||
static_assert(AK::Concepts::HashCompatible<ByteBuffer, StringView>);
|
||||
}
|
||||
|
||||
TEST_CASE(matches_null)
|
||||
{
|
||||
EXPECT(AK::StringUtils::matches(StringView(), StringView()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue