23 template <
typename SPtr>
26 auto initialValue = *sptr.rlock();
27 bool rlockedTypeOK{
false};
28 sptr.withRLock([&](
auto&&
value) {
33 bool wlockedTypeOK{
false};
34 sptr.withWLock([&](
auto&&
value) {
39 EXPECT_EQ(initialValue + 1, *sptr.rlock());
42 TEST(SynchronizedPtrTest, Shared) {
47 TEST(SynchronizedPtrTest, UniqueBasic) {
52 TEST(SynchronizedPtrTest, UniqueDeleter) {
53 bool calledDeleter =
false;
54 auto x = [&](
int*
ptr) {
60 std::unique_ptr<int, decltype(x)>(
new int(0),
x)};
63 std::unique_ptr<
int, decltype(
x)>&,
64 decltype(*pInt.wlockPointer())>::
value));
65 pInt.wlockPointer()->reset(
new int(5));
67 calledDeleter =
false;
72 TEST(SynchronizedPtrTest, Replaceable) {
81 decltype(*pcInt.wlockPointer())>::
value));
82 pcInt.withWLockPointer([](
auto&&
ptr) {
90 TEST(SynchronizedPtrTest, Optional) {
97 pInt.withWLockPointer([](
auto&&
ptr) {
104 TEST(SynchronizedPtrTest, Virtual) {
106 virtual void poke(
bool&)
const {}
107 virtual ~
A() =
default;
110 void poke(
bool&
b)
const override {
115 bool itWorks =
false;
116 pA.rlock()->poke(itWorks);
119 pA.wlock()->poke(itWorks);
121 pA.withWLockPointer([](
auto&&
ptr) {
127 auto lockedPtr = pA.wlockPointer();
130 *lockedPtr =
new B();
133 pA.wlock()->poke(itWorks);
135 delete *pA.wlockPointer();
#define EXPECT_EQ(val1, val2)
static const char *const value
#define EXPECT_TRUE(condition)
#define EXPECT_FALSE(condition)
TEST(SynchronizedPtrTest, Shared)