Skip to content

Commit

Permalink
fix: Add a virtual destructor to DependencyProvider (#50)
Browse files Browse the repository at this point in the history
* fix: Add a virtual destructor to `DependencyProvider`

Signed-off-by: Julien Jerphanion <[email protected]>

* lint: Format file

Signed-off-by: Julien Jerphanion <[email protected]>

---------

Signed-off-by: Julien Jerphanion <[email protected]>
  • Loading branch information
jjerphan authored Jun 24, 2024
1 parent d90bc3a commit 0a0ea92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cpp/include/resolvo_dependency_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ using cbindgen_private::VersionSetId;
* An interface that implements ecosystem specific logic.
*/
struct DependencyProvider {
virtual ~DependencyProvider() = default;

/**
* Returns a user-friendly string representation of the specified solvable.
*
Expand Down
5 changes: 5 additions & 0 deletions cpp/tests/solve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ SCENARIO("Solve") {
/// Construct a database with packages a, b, and c.
PackageDatabase db;

// Check that PackageDatabase correctly implements the DependencyProvider interface
static_assert(std::has_virtual_destructor_v<PackageDatabase>);
static_assert(std::is_polymorphic_v<PackageDatabase>);
static_assert(std::is_base_of_v<resolvo::DependencyProvider, PackageDatabase>);

auto a_1 = db.alloc_candidate("a", 1, {{db.alloc_requirement("b", 1, 4)}, {}});
auto a_2 = db.alloc_candidate("a", 2, {{db.alloc_requirement("b", 1, 4)}, {}});
auto a_3 = db.alloc_candidate("a", 3, {{db.alloc_requirement("b", 4, 7)}, {}});
Expand Down

0 comments on commit 0a0ea92

Please sign in to comment.