-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed
remove
method to accept nullptr
node.
Also Clang-Tidy & Sonar fixes.
- Loading branch information
Showing
3 changed files
with
89 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,6 @@ __pycache__/ | |
**/.idea/* | ||
!**/.idea/dictionaries | ||
!**/.idea/dictionaries/* | ||
|
||
# Dumb OS crap | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
/// Copyright (c) 2021 Pavel Kirienko <[email protected]> | ||
|
||
#include "cavl.hpp" | ||
#include <unity.h> | ||
|
||
#include <algorithm> | ||
#include <array> | ||
#include <cstdio> | ||
#include <cstdint> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <ctime> | ||
#include <string> | ||
#include <functional> | ||
#include <iostream> | ||
#include <sstream> | ||
#include <limits> | ||
#include <memory> | ||
#include <numeric> | ||
#include <limits> | ||
#include <vector> | ||
#include <sstream> | ||
#include <string> | ||
#include <type_traits> | ||
#include <functional> | ||
#include <unity.h> | ||
#include <vector> | ||
|
||
#if __cplusplus >= 201703L | ||
# define NODISCARD [[nodiscard]] | ||
|
@@ -680,6 +680,19 @@ void testManual(const std::function<N*(std::uint8_t)>& factory) | |
TEST_ASSERT_NULL(static_cast<N*>(tr2)); // NOLINT use after move is intentional. | ||
TEST_ASSERT_EQUAL(1, tr3.size()); | ||
|
||
// Try various methods on empty tree (including `const` one). | ||
// | ||
std::puts("REMOVE 4"); | ||
tr3.remove(t[4]); | ||
tr3.remove(nullptr); | ||
TEST_ASSERT_EQUAL(nullptr, tr3.min()); | ||
TEST_ASSERT_EQUAL(nullptr, tr3.max()); | ||
const TreeType tr4_const{std::move(tr3)}; | ||
TEST_ASSERT_EQUAL(0, tr4_const.size()); | ||
TEST_ASSERT_EQUAL(nullptr, tr4_const.min()); | ||
TEST_ASSERT_EQUAL(nullptr, tr4_const.max()); | ||
TEST_ASSERT_EQUAL(0, tr4_const.traverse([](const N&) { return 13; })); | ||
|
||
// Clean up manually to reduce boilerplate in the tests. This is super sloppy but OK for a basic test suite. | ||
for (auto* const x : t) | ||
{ | ||
|