| 12345678910111213141516171819202122232425262728293031323334353637 |
- //
- // const_propogating_ptr.t.h
- // pointers
- //
- // Created by Sam Jaffe on 1/5/17.
- //
- #include "pointers/const_propogating_ptr.hpp"
- #include <memory>
- #include <gmock/gmock.h>
- #include "test_stubs.h"
- using namespace pointers;
- TEST(ConstPropogatingPtrTest, NonConstCPPCallsNonConstMethods) {
- std::shared_ptr<const_tracking_stub> p{new const_tracking_stub};
- const_propogating_ptr<std::shared_ptr<const_tracking_stub>> cp{p};
- EXPECT_FALSE(cp->is_const());
- }
- TEST(ConstPropogatingPtrTest, ConstCPPCallsConstMethods) {
- std::shared_ptr<const_tracking_stub> p{new const_tracking_stub};
- const_propogating_ptr<std::shared_ptr<const_tracking_stub>> const cp{p};
- EXPECT_TRUE(cp->is_const());
- }
- TEST(ConstPropogatingPtrTest, DoesNotDeleteRawPtr) {
- bool has_delete{false};
- destructor_sentinal * test_struct = new destructor_sentinal{has_delete};
- const_propogating_ptr<destructor_sentinal *>{test_struct};
- EXPECT_FALSE(has_delete);
- delete test_struct;
- EXPECT_TRUE(has_delete);
- }
|