Skip to content

Commit

Permalink
Fixed tests and forwarding ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriele A. Ron committed Aug 30, 2022
1 parent 04729f7 commit 1035741
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/GRon/FibonacciHeap/FibonacciHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace GRon {

FibonacciHeap() = default;

template<class... Args, typename = std::enable_if_t<(!std::is_base_of_v<FibonacciHeap, Args> && ...)>>
template<class... Args, typename = std::enable_if_t<(!std::is_base_of_v<FibonacciHeap, std::decay_t<Args>> && ...)>>
explicit FibonacciHeap(Args&&... args) : _size(0), _clean(false), _top(nullptr),
_nodes(std::forward<Args...>(args...)), _removed(), root_list() {};

Expand Down
13 changes: 12 additions & 1 deletion tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ TEST_CASE("heap basic functions", "[heap]") {
test.insert(0);
test.insert(15);

GRon::FibonacciHeap<int> copied(std::move(test));
GRon::FibonacciHeap<int> copied(test);

REQUIRE(copied.size() == 4);
auto iter = copied.root_list.begin();
Expand All @@ -119,6 +119,17 @@ TEST_CASE("heap basic functions", "[heap]") {
REQUIRE((*iter)->key.value() == 0);
iter = std::next(iter);
REQUIRE((*iter)->key.value() == 15);

REQUIRE(test.size() == 4);
iter = test.root_list.begin();

REQUIRE((*iter)->key == 5);
iter = std::next(iter);
REQUIRE((*iter)->key.value() == -1);
iter = std::next(iter);
REQUIRE((*iter)->key.value() == 0);
iter = std::next(iter);
REQUIRE((*iter)->key.value() == 15);
}

SECTION("move ctor") {
Expand Down

0 comments on commit 1035741

Please sign in to comment.