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
12 changes: 6 additions & 6 deletions CxxReflectionTests/src/ClassMethodsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ namespace rtl_tests

TEST(ReflectionMethodCall, wrong_args)
{
EXPECT_TRUE(book::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -47,12 +46,12 @@ namespace rtl_tests
EXPECT_FALSE(book::test_method_setAuthor(bookObj.get()));
}
EXPECT_TRUE(book::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(ClassBookMethod, args_void)
{
EXPECT_TRUE(book::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -78,12 +77,12 @@ namespace rtl_tests
EXPECT_TRUE(book::test_method_getPublishedOn_return(retStr));
}
EXPECT_TRUE(book::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(ClassBookMethod, args_string)
{
EXPECT_TRUE(book::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -107,12 +106,12 @@ namespace rtl_tests
EXPECT_TRUE(book::test_method_setAuthor(bookObj.get()));
}
EXPECT_TRUE(book::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(ClassBookMethodOverload, args_void)
{
EXPECT_TRUE(book::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -135,12 +134,12 @@ namespace rtl_tests
EXPECT_TRUE(book::test_method_updateBookInfo(bookObj.get()));
}
EXPECT_TRUE(book::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(ClassBookMethodOverload, args_string_double_charPtr)
{
EXPECT_TRUE(book::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -165,12 +164,12 @@ namespace rtl_tests
EXPECT_TRUE(isSuccess);
}
EXPECT_TRUE(book::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(ClassBookMethodOverload, args_charPtr_double_string)
{
EXPECT_TRUE(book::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -195,5 +194,6 @@ namespace rtl_tests
EXPECT_TRUE(isSuccess);
}
EXPECT_TRUE(book::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}
}
48 changes: 42 additions & 6 deletions CxxReflectionTests/src/ConstMethodOverloadTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace rtl_tests
{
TEST(ConstMethodOverload, const_method_no_overload_call_on_non_const_target)
{
EXPECT_TRUE(person::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -35,12 +34,12 @@ namespace rtl_tests
EXPECT_TRUE(person::test_method_updateLastName(personObj.get()));
}
EXPECT_TRUE(person::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(ConstMethodOverload, const_method_no_overload_call_on_const_target)
{
EXPECT_TRUE(person::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -66,12 +65,48 @@ namespace rtl_tests
EXPECT_TRUE(person::test_method_updateLastName_const(personObj.get()));
}
EXPECT_TRUE(person::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(ConstMethodOverload, const_method_string_call_on_const_target)
TEST(ConstMethodOverload, const_method_no_overload_call_on_const_target_returns_string)
{
{
CxxMirror& cxxMirror = MyReflection::instance();

optional<Record> recOpt = cxxMirror.getRecord(person::class_);
ASSERT_TRUE(recOpt.has_value());

const Record& classPerson = recOpt.value();
optional<Method> updateLastName = classPerson.getMethod(person::str_updateLastName);
ASSERT_TRUE(updateLastName);

const std::string firstName = person::FIRST_NAME;
auto [status, personObj] = classPerson.instance(firstName);

ASSERT_TRUE(status);
ASSERT_FALSE(personObj.isEmpty());

personObj.makeConst();
ASSERT_TRUE(personObj.isConst());

optional<Method> getFirstName = classPerson.getMethod(person::str_getFirstName);
ASSERT_TRUE(getFirstName);

const RStatus& rstatus = getFirstName->on(personObj).call();
ASSERT_TRUE(rstatus);
ASSERT_TRUE(rstatus.isOfType<std::string>());

const std::string retStr = std::any_cast<std::string>(rstatus.getReturn());
ASSERT_EQ(retStr, firstName);
}
EXPECT_TRUE(person::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(ConstMethodOverload, const_method_string_call_on_const_target)
{
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -97,12 +132,12 @@ namespace rtl_tests
EXPECT_TRUE(person::test_method_updateAddress_const<string>(personObj.get()));
}
EXPECT_TRUE(person::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(ConstMethodOverload, const_method_string_call_on_non_const_target)
{
EXPECT_TRUE(person::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -125,12 +160,12 @@ namespace rtl_tests
EXPECT_TRUE(person::test_method_updateAddress<string>(personObj.get()));
}
EXPECT_TRUE(person::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(ConstMethodOverload, const_method_no_args_call_on_const_target)
{
EXPECT_TRUE(person::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -157,12 +192,12 @@ namespace rtl_tests
EXPECT_TRUE(person::test_method_updateAddress_const(personObj.get()));
}
EXPECT_TRUE(person::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(ConstMethodOverload, const_method_no_args_call_on_non_const_target)
{
EXPECT_TRUE(person::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -186,5 +221,6 @@ namespace rtl_tests
EXPECT_TRUE(person::test_method_updateAddress(personObj.get()));
}
EXPECT_TRUE(person::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}
}
18 changes: 9 additions & 9 deletions CxxReflectionTests/src/ConstructorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace rtl_tests

TEST(DynamicAllocConstructorDate, wrong_args)
{
EXPECT_TRUE(date::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -38,12 +37,12 @@ namespace rtl_tests
ASSERT_TRUE(instance.isEmpty());
}
EXPECT_TRUE(date::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(DynamicAllocConstructorDate, args_void)
{
EXPECT_TRUE(date::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -57,12 +56,12 @@ namespace rtl_tests
EXPECT_TRUE(date::test_dynamic_alloc_instance_ctor<>(instance.get()));
}
EXPECT_TRUE(date::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(DynamicAllocConstructorDate, args_string)
{
EXPECT_TRUE(date::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -77,12 +76,12 @@ namespace rtl_tests
EXPECT_TRUE(date::test_dynamic_alloc_instance_ctor<string>(instance.get()));
}
EXPECT_TRUE(date::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(DynamicAllocConstructorDate, args_unsigned_unsigned_unsigned)
{
EXPECT_TRUE(date::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -98,12 +97,12 @@ namespace rtl_tests
EXPECT_TRUE(isPassed);
}
EXPECT_TRUE(date::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(DestructorDate, non_virtual)
{
EXPECT_TRUE(date::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -117,12 +116,12 @@ namespace rtl_tests
EXPECT_TRUE(date::test_dynamic_alloc_instance_ctor<>(instance.get()));
}
EXPECT_TRUE(date::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(DynamicAllocConstructorBook, wrong_args)
{
EXPECT_TRUE(book::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -135,12 +134,12 @@ namespace rtl_tests
ASSERT_TRUE(instance.isEmpty());
}
EXPECT_TRUE(book::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(DynamicAllocConstructorBook, args_default)
{
EXPECT_TRUE(book::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -154,12 +153,12 @@ namespace rtl_tests
EXPECT_TRUE(book::test_dynamic_alloc_instance_ctor(instance.get()));
}
EXPECT_TRUE(book::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(DynamicAllocConstructorBook, args_double_string)
{
EXPECT_TRUE(book::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -177,12 +176,12 @@ namespace rtl_tests
EXPECT_TRUE(isPassed);
}
EXPECT_TRUE(book::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}


TEST(DestructorBook, non_virtual)
{
EXPECT_TRUE(book::assert_zero_instance_count());
{
CxxMirror& cxxMirror = MyReflection::instance();

Expand All @@ -196,5 +195,6 @@ namespace rtl_tests
EXPECT_TRUE(book::test_dynamic_alloc_instance_ctor(instance.get()));
}
EXPECT_TRUE(book::assert_zero_instance_count());
EXPECT_TRUE(Instance::getInstanceCount() == 0);
}
}
Loading