Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ namespace rtl_tests
// 'Event' has a unique_ptr<Date> and two 'Event' instances exists, So-
EXPECT_TRUE(date::get_instance_count() == 2);

// Sets Calender's move operation counter to zero
calender::reset_move_ops_counter();

// Moving a RObject created via alloc::Stack, invokes Calender's move constructor.
RObject calender1 = std::move(calender0);

// Calender's move-constructor called once.
EXPECT_TRUE(calender::get_move_ops_count() == 1);

ASSERT_FALSE(calender1.isEmpty());
EXPECT_TRUE(calender1.isConstCastSafe());
Expand Down Expand Up @@ -91,10 +97,16 @@ namespace rtl_tests
// 'Event' has a unique_ptr<Date> and two 'Event' instances exists, So-
EXPECT_TRUE(date::get_instance_count() == 2);

// Sets Calender's move operation counter to zero
calender::reset_move_ops_counter();

// RObject created via alloc::HEAP, contains pointer to reflected type internally, So just the
// address wrapped in std::any inside Robject is moved. Calender's move constructor is not called.
RObject calender1 = std::move(calender0);

// Calender's move constructor isn't called.
EXPECT_TRUE(calender::get_move_ops_count() == 0);

ASSERT_FALSE(calender1.isEmpty());
EXPECT_TRUE(calender1.isConstCastSafe());
EXPECT_TRUE(calender1.isOnHeap());
Expand Down Expand Up @@ -228,9 +240,15 @@ namespace rtl_tests
// 'Event' has a unique_ptr<Date> and two 'Event' instances exists, So-
EXPECT_TRUE(date::get_instance_count() == 2);

// Sets Calender's move operation counter to zero
calender::reset_move_ops_counter();

// Moving a RObject created via alloc::Stack, invokes Calender's move constructor.
RObject calender1 = std::move(calender0);

// Calender's move-constructor called once.
EXPECT_TRUE(calender::get_move_ops_count() == 1);

ASSERT_FALSE(calender1.isEmpty());
EXPECT_TRUE(calender1.isConstCastSafe());
EXPECT_FALSE(calender1.isOnHeap());
Expand Down
4 changes: 2 additions & 2 deletions CxxRTLTypeRegistration/src/TestMirrorProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ namespace test_mirror
static const auto _ = [&]()
{
const std::string pathStr = std::filesystem::current_path().string() + "/MyReflection.json";
std::cout << "\n[ OUTPUT] test_mirror::cxx::mirror()==> dumping metadata as JSON."
<< "\n file path: " << pathStr << std::endl;
std::cout << "\n[ OUTPUT] test_mirror::cxx::mirror() ==> dumping 'CxxMirror' as JSON."
<< "\n file path: " << pathStr << "\n" << std::endl;
rtl::CxxMirrorToJson::dump(cxx_mirror, pathStr);
return 0;
}();
Expand Down
4 changes: 4 additions & 0 deletions CxxTestProps/inc/Date.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ namespace nsdate
const Event& getTheEvent();
const Event& getSavedEvent();

static void resetMoveOpsCounter();
static std::size_t instanceCount();
static std::size_t getMoveOpsCount();

static Calender create();

Expand All @@ -65,6 +67,8 @@ namespace nsdate
std::unique_ptr<Event> m_savedEvent;

static std::size_t m_instanceCount;

static std::size_t m_moveOpsCount;
};


Expand Down
12 changes: 12 additions & 0 deletions CxxTestProps/src/Date.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace nsdate
std::size_t Date::m_instanceCount = 0;
std::size_t Event::m_instanceCount = 0;
std::size_t Calender::m_instanceCount = 0;
std::size_t Calender::m_moveOpsCount = 0;

Calender::~Calender()
{
Expand All @@ -34,6 +35,7 @@ namespace nsdate
: m_theEvent(std::move(pOther.m_theEvent))
, m_savedEvent(std::move(pOther.m_savedEvent))
{
m_moveOpsCount++;
m_instanceCount++;
}

Expand Down Expand Up @@ -66,6 +68,16 @@ namespace nsdate
{
return m_instanceCount;
}

std::size_t Calender::getMoveOpsCount()
{
return m_moveOpsCount;
}

void Calender::resetMoveOpsCounter()
{
m_moveOpsCount = 0;
}
}

namespace nsdate
Expand Down
2 changes: 2 additions & 0 deletions CxxTestUtils/inc/TestUtilsDate.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ namespace test_utils
static constexpr const char* str_getTheEvent = "getTheEvent";
static constexpr const char* str_getSavedEvent = "getSavedEvent";

static void reset_move_ops_counter();
static const bool assert_zero_instance_count();
static const std::size_t get_instance_count();
static const std::size_t get_move_ops_count();
};

struct date
Expand Down
10 changes: 10 additions & 0 deletions CxxTestUtils/src/TestUtilsDate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ namespace test_utils
return Calender::instanceCount();
}

void calender::reset_move_ops_counter()
{
Calender::resetMoveOpsCounter();
}

const std::size_t calender::get_move_ops_count()
{
return Calender::getMoveOpsCount();
}

const bool event::assert_zero_instance_count()
{
return (Event::instanceCount() == 0);
Expand Down
Loading