mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:37:35 +00:00
AK: Add HashMap(std::initializer_list<Entry>) constructor
This allows us to construct a HashMap from an initializer list like so: HashMap<K, V> hash_map = { { K, V }, { K, V } { K, V } };
This commit is contained in:
parent
1dbd264239
commit
1ed72cc580
2 changed files with 31 additions and 1 deletions
|
@ -36,6 +36,17 @@ TEST_CASE(construct)
|
|||
EXPECT_EQ(IntIntMap().size(), 0u);
|
||||
}
|
||||
|
||||
TEST_CASE(construct_from_initializer_list)
|
||||
{
|
||||
HashMap<int, String> number_to_string {
|
||||
{ 1, "One" },
|
||||
{ 2, "Two" },
|
||||
{ 3, "Three" },
|
||||
};
|
||||
EXPECT_EQ(number_to_string.is_empty(), false);
|
||||
EXPECT_EQ(number_to_string.size(), 3u);
|
||||
}
|
||||
|
||||
TEST_CASE(populate)
|
||||
{
|
||||
HashMap<int, String> number_to_string;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue