Skip to content

Commit

Permalink
fix bug in comparing default tensor (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmrichard authored Oct 14, 2024
1 parent 2098831 commit 68f1fd0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/tensorwrapper/tensor/tensor_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void Tensor::swap(Tensor& other) noexcept { m_pimpl_.swap(other.m_pimpl_); }

bool Tensor::operator==(const Tensor& rhs) const noexcept {
if(has_pimpl_() != rhs.has_pimpl_()) return false;
if(!has_pimpl_()) return true; // Both don't have a PIMPL
return (*m_pimpl_) == (*rhs.m_pimpl_);
}

Expand Down
2 changes: 2 additions & 0 deletions tests/cxx/unit_tests/tensorwrapper/tensor/tensor_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ TEST_CASE("Tensor") {
}

SECTION("operator==") {
REQUIRE(defaulted == Tensor{});

Tensor other_scalar(testing::smooth_scalar());
Tensor other_vector(testing::smooth_vector());
REQUIRE(scalar == other_scalar);
Expand Down

0 comments on commit 68f1fd0

Please sign in to comment.