Skip to content

Commit f57f135

Browse files
authored
Merge pull request #30 from ReflectCxx/release-2.0.Comments
comments.
2 parents 3f1ba3c + df419e9 commit f57f135

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2970
-1953
lines changed

CxxReflectionTests/src/ClassMethodsTests.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ namespace rtl_tests
2424

2525
TEST(ReflectionMethodCall, wrong_args)
2626
{
27-
EXPECT_TRUE(book::assert_zero_instance_count());
2827
{
2928
CxxMirror& cxxMirror = MyReflection::instance();
3029

@@ -47,12 +46,12 @@ namespace rtl_tests
4746
EXPECT_FALSE(book::test_method_setAuthor(bookObj.get()));
4847
}
4948
EXPECT_TRUE(book::assert_zero_instance_count());
49+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
5050
}
5151

5252

5353
TEST(ClassBookMethod, args_void)
5454
{
55-
EXPECT_TRUE(book::assert_zero_instance_count());
5655
{
5756
CxxMirror& cxxMirror = MyReflection::instance();
5857

@@ -78,12 +77,12 @@ namespace rtl_tests
7877
EXPECT_TRUE(book::test_method_getPublishedOn_return(retStr));
7978
}
8079
EXPECT_TRUE(book::assert_zero_instance_count());
80+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
8181
}
8282

8383

8484
TEST(ClassBookMethod, args_string)
8585
{
86-
EXPECT_TRUE(book::assert_zero_instance_count());
8786
{
8887
CxxMirror& cxxMirror = MyReflection::instance();
8988

@@ -107,12 +106,12 @@ namespace rtl_tests
107106
EXPECT_TRUE(book::test_method_setAuthor(bookObj.get()));
108107
}
109108
EXPECT_TRUE(book::assert_zero_instance_count());
109+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
110110
}
111111

112112

113113
TEST(ClassBookMethodOverload, args_void)
114114
{
115-
EXPECT_TRUE(book::assert_zero_instance_count());
116115
{
117116
CxxMirror& cxxMirror = MyReflection::instance();
118117

@@ -135,12 +134,12 @@ namespace rtl_tests
135134
EXPECT_TRUE(book::test_method_updateBookInfo(bookObj.get()));
136135
}
137136
EXPECT_TRUE(book::assert_zero_instance_count());
137+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
138138
}
139139

140140

141141
TEST(ClassBookMethodOverload, args_string_double_charPtr)
142142
{
143-
EXPECT_TRUE(book::assert_zero_instance_count());
144143
{
145144
CxxMirror& cxxMirror = MyReflection::instance();
146145

@@ -165,12 +164,12 @@ namespace rtl_tests
165164
EXPECT_TRUE(isSuccess);
166165
}
167166
EXPECT_TRUE(book::assert_zero_instance_count());
167+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
168168
}
169169

170170

171171
TEST(ClassBookMethodOverload, args_charPtr_double_string)
172172
{
173-
EXPECT_TRUE(book::assert_zero_instance_count());
174173
{
175174
CxxMirror& cxxMirror = MyReflection::instance();
176175

@@ -195,5 +194,6 @@ namespace rtl_tests
195194
EXPECT_TRUE(isSuccess);
196195
}
197196
EXPECT_TRUE(book::assert_zero_instance_count());
197+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
198198
}
199199
}

CxxReflectionTests/src/ConstMethodOverloadTests.cpp

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ namespace rtl_tests
1111
{
1212
TEST(ConstMethodOverload, const_method_no_overload_call_on_non_const_target)
1313
{
14-
EXPECT_TRUE(person::assert_zero_instance_count());
1514
{
1615
CxxMirror& cxxMirror = MyReflection::instance();
1716

@@ -35,12 +34,12 @@ namespace rtl_tests
3534
EXPECT_TRUE(person::test_method_updateLastName(personObj.get()));
3635
}
3736
EXPECT_TRUE(person::assert_zero_instance_count());
37+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
3838
}
3939

4040

4141
TEST(ConstMethodOverload, const_method_no_overload_call_on_const_target)
4242
{
43-
EXPECT_TRUE(person::assert_zero_instance_count());
4443
{
4544
CxxMirror& cxxMirror = MyReflection::instance();
4645

@@ -66,12 +65,48 @@ namespace rtl_tests
6665
EXPECT_TRUE(person::test_method_updateLastName_const(personObj.get()));
6766
}
6867
EXPECT_TRUE(person::assert_zero_instance_count());
68+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
6969
}
7070

7171

72-
TEST(ConstMethodOverload, const_method_string_call_on_const_target)
72+
TEST(ConstMethodOverload, const_method_no_overload_call_on_const_target_returns_string)
7373
{
74+
{
75+
CxxMirror& cxxMirror = MyReflection::instance();
76+
77+
optional<Record> recOpt = cxxMirror.getRecord(person::class_);
78+
ASSERT_TRUE(recOpt.has_value());
79+
80+
const Record& classPerson = recOpt.value();
81+
optional<Method> updateLastName = classPerson.getMethod(person::str_updateLastName);
82+
ASSERT_TRUE(updateLastName);
83+
84+
const std::string firstName = person::FIRST_NAME;
85+
auto [status, personObj] = classPerson.instance(firstName);
86+
87+
ASSERT_TRUE(status);
88+
ASSERT_FALSE(personObj.isEmpty());
89+
90+
personObj.makeConst();
91+
ASSERT_TRUE(personObj.isConst());
92+
93+
optional<Method> getFirstName = classPerson.getMethod(person::str_getFirstName);
94+
ASSERT_TRUE(getFirstName);
95+
96+
const RStatus& rstatus = getFirstName->on(personObj).call();
97+
ASSERT_TRUE(rstatus);
98+
ASSERT_TRUE(rstatus.isOfType<std::string>());
99+
100+
const std::string retStr = std::any_cast<std::string>(rstatus.getReturn());
101+
ASSERT_EQ(retStr, firstName);
102+
}
74103
EXPECT_TRUE(person::assert_zero_instance_count());
104+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
105+
}
106+
107+
108+
TEST(ConstMethodOverload, const_method_string_call_on_const_target)
109+
{
75110
{
76111
CxxMirror& cxxMirror = MyReflection::instance();
77112

@@ -97,12 +132,12 @@ namespace rtl_tests
97132
EXPECT_TRUE(person::test_method_updateAddress_const<string>(personObj.get()));
98133
}
99134
EXPECT_TRUE(person::assert_zero_instance_count());
135+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
100136
}
101137

102138

103139
TEST(ConstMethodOverload, const_method_string_call_on_non_const_target)
104140
{
105-
EXPECT_TRUE(person::assert_zero_instance_count());
106141
{
107142
CxxMirror& cxxMirror = MyReflection::instance();
108143

@@ -125,12 +160,12 @@ namespace rtl_tests
125160
EXPECT_TRUE(person::test_method_updateAddress<string>(personObj.get()));
126161
}
127162
EXPECT_TRUE(person::assert_zero_instance_count());
163+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
128164
}
129165

130166

131167
TEST(ConstMethodOverload, const_method_no_args_call_on_const_target)
132168
{
133-
EXPECT_TRUE(person::assert_zero_instance_count());
134169
{
135170
CxxMirror& cxxMirror = MyReflection::instance();
136171

@@ -157,12 +192,12 @@ namespace rtl_tests
157192
EXPECT_TRUE(person::test_method_updateAddress_const(personObj.get()));
158193
}
159194
EXPECT_TRUE(person::assert_zero_instance_count());
195+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
160196
}
161197

162198

163199
TEST(ConstMethodOverload, const_method_no_args_call_on_non_const_target)
164200
{
165-
EXPECT_TRUE(person::assert_zero_instance_count());
166201
{
167202
CxxMirror& cxxMirror = MyReflection::instance();
168203

@@ -186,5 +221,6 @@ namespace rtl_tests
186221
EXPECT_TRUE(person::test_method_updateAddress(personObj.get()));
187222
}
188223
EXPECT_TRUE(person::assert_zero_instance_count());
224+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
189225
}
190226
}

CxxReflectionTests/src/ConstructorTests.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ namespace rtl_tests
2525

2626
TEST(DynamicAllocConstructorDate, wrong_args)
2727
{
28-
EXPECT_TRUE(date::assert_zero_instance_count());
2928
{
3029
CxxMirror& cxxMirror = MyReflection::instance();
3130

@@ -38,12 +37,12 @@ namespace rtl_tests
3837
ASSERT_TRUE(instance.isEmpty());
3938
}
4039
EXPECT_TRUE(date::assert_zero_instance_count());
40+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
4141
}
4242

4343

4444
TEST(DynamicAllocConstructorDate, args_void)
4545
{
46-
EXPECT_TRUE(date::assert_zero_instance_count());
4746
{
4847
CxxMirror& cxxMirror = MyReflection::instance();
4948

@@ -57,12 +56,12 @@ namespace rtl_tests
5756
EXPECT_TRUE(date::test_dynamic_alloc_instance_ctor<>(instance.get()));
5857
}
5958
EXPECT_TRUE(date::assert_zero_instance_count());
59+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
6060
}
6161

6262

6363
TEST(DynamicAllocConstructorDate, args_string)
6464
{
65-
EXPECT_TRUE(date::assert_zero_instance_count());
6665
{
6766
CxxMirror& cxxMirror = MyReflection::instance();
6867

@@ -77,12 +76,12 @@ namespace rtl_tests
7776
EXPECT_TRUE(date::test_dynamic_alloc_instance_ctor<string>(instance.get()));
7877
}
7978
EXPECT_TRUE(date::assert_zero_instance_count());
79+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
8080
}
8181

8282

8383
TEST(DynamicAllocConstructorDate, args_unsigned_unsigned_unsigned)
8484
{
85-
EXPECT_TRUE(date::assert_zero_instance_count());
8685
{
8786
CxxMirror& cxxMirror = MyReflection::instance();
8887

@@ -98,12 +97,12 @@ namespace rtl_tests
9897
EXPECT_TRUE(isPassed);
9998
}
10099
EXPECT_TRUE(date::assert_zero_instance_count());
100+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
101101
}
102102

103103

104104
TEST(DestructorDate, non_virtual)
105105
{
106-
EXPECT_TRUE(date::assert_zero_instance_count());
107106
{
108107
CxxMirror& cxxMirror = MyReflection::instance();
109108

@@ -117,12 +116,12 @@ namespace rtl_tests
117116
EXPECT_TRUE(date::test_dynamic_alloc_instance_ctor<>(instance.get()));
118117
}
119118
EXPECT_TRUE(date::assert_zero_instance_count());
119+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
120120
}
121121

122122

123123
TEST(DynamicAllocConstructorBook, wrong_args)
124124
{
125-
EXPECT_TRUE(book::assert_zero_instance_count());
126125
{
127126
CxxMirror& cxxMirror = MyReflection::instance();
128127

@@ -135,12 +134,12 @@ namespace rtl_tests
135134
ASSERT_TRUE(instance.isEmpty());
136135
}
137136
EXPECT_TRUE(book::assert_zero_instance_count());
137+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
138138
}
139139

140140

141141
TEST(DynamicAllocConstructorBook, args_default)
142142
{
143-
EXPECT_TRUE(book::assert_zero_instance_count());
144143
{
145144
CxxMirror& cxxMirror = MyReflection::instance();
146145

@@ -154,12 +153,12 @@ namespace rtl_tests
154153
EXPECT_TRUE(book::test_dynamic_alloc_instance_ctor(instance.get()));
155154
}
156155
EXPECT_TRUE(book::assert_zero_instance_count());
156+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
157157
}
158158

159159

160160
TEST(DynamicAllocConstructorBook, args_double_string)
161161
{
162-
EXPECT_TRUE(book::assert_zero_instance_count());
163162
{
164163
CxxMirror& cxxMirror = MyReflection::instance();
165164

@@ -177,12 +176,12 @@ namespace rtl_tests
177176
EXPECT_TRUE(isPassed);
178177
}
179178
EXPECT_TRUE(book::assert_zero_instance_count());
179+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
180180
}
181181

182182

183183
TEST(DestructorBook, non_virtual)
184184
{
185-
EXPECT_TRUE(book::assert_zero_instance_count());
186185
{
187186
CxxMirror& cxxMirror = MyReflection::instance();
188187

@@ -196,5 +195,6 @@ namespace rtl_tests
196195
EXPECT_TRUE(book::test_dynamic_alloc_instance_ctor(instance.get()));
197196
}
198197
EXPECT_TRUE(book::assert_zero_instance_count());
198+
EXPECT_TRUE(Instance::getInstanceCount() == 0);
199199
}
200200
}

0 commit comments

Comments
 (0)