mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
AK: Fix busted Trie test
This wasn't testing anything ^^'
This commit is contained in:
parent
ad646420dd
commit
1c9d28d212
Notes:
sideshowbarker
2024-07-19 00:35:20 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/1c9d28d212e Pull-request: https://github.com/SerenityOS/serenity/pull/4546
2 changed files with 22 additions and 0 deletions
|
@ -71,10 +71,17 @@ TEST_CASE(iterate)
|
|||
for (size_t i = 0; i < input.size(); ++i)
|
||||
input[i] = i;
|
||||
|
||||
bunch_of_numbers.insert(input.begin(), input.end());
|
||||
|
||||
// Iteration order is preorder (order between adjacent nodes is not defined, but parents come before children)
|
||||
// in this case, the tree is linear.
|
||||
size_t i = 0;
|
||||
bool is_root = true;
|
||||
for (auto& node : bunch_of_numbers) {
|
||||
if (is_root) {
|
||||
is_root = false;
|
||||
continue;
|
||||
}
|
||||
EXPECT_EQ(input[i], node.value());
|
||||
++i;
|
||||
}
|
||||
|
|
15
AK/Trie.h
15
AK/Trie.h
|
@ -183,6 +183,21 @@ public:
|
|||
return static_cast<BaseType&>(*last_root_node);
|
||||
}
|
||||
|
||||
template<typename It, typename ProvideMetadataFunction>
|
||||
BaseType& insert(
|
||||
const It& begin, const It& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) requires(!IsSame<MetadataType, decltype(nullptr)>::value)
|
||||
{
|
||||
auto it = begin;
|
||||
return insert(it, end, move(metadata), move(provide_missing_metadata));
|
||||
}
|
||||
|
||||
template<typename It>
|
||||
BaseType& insert(const It& begin, const It& end) requires(IsSame<MetadataType, decltype(nullptr)>::value)
|
||||
{
|
||||
auto it = begin;
|
||||
return insert(it, end);
|
||||
}
|
||||
|
||||
ConstIterator begin() const { return ConstIterator(*this); }
|
||||
ConstIterator end() const { return ConstIterator::end(); }
|
||||
|
||||
|
|
Loading…
Reference in a new issue