MCPcopy Create free account
hub / github.com/OAID/Tengine / test_creator

Function test_creator

internal/tests/core/test/test_factory.cpp:127–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127void test_creator(void)
128{
129 SpecificFactory<base> fc;
130
131 /* creator test */
132
133 fc.RegisterCreator("A", std::function<decltype(create_a)>(create_a));
134 fc.RegisterCreator("B", std::function<base*()>([]() { return new B(); }));
135 fc.RegisterCreator("C", create_a);
136
137 base* p = fc.Create("A");
138
139 p->f();
140
141 p = fc.Create("B");
142
143 p->f();
144
145 p = fc.Create("C");
146
147 p->f();
148
149 /* creator with argument */
150
151 fc.RegisterCreator("D", create_b);
152 fc.RegisterCreator("E", std::function<base*(const std::string&)>(create_b));
153
154 const std::string& hello = "hello";
155
156 p = fc.Create<const std::string&>("D", hello);
157 p->f();
158
159 p = fc.Create<const std::string&>("E", "world");
160 p->f();
161
162 fc.RegisterCreator("E", create_b2);
163 p = fc.Create("E", 1000);
164
165 p->g();
166
167 std::cout << "retrieval creator type info: \n";
168
169 std::vector<std::string> info = fc.CreatorInfo("E");
170
171 for(auto str : info)
172 {
173 std::cout << str << std::endl;
174 }
175}
176
177struct G
178{

Callers 1

mainFunction · 0.85

Calls 5

RegisterCreatorMethod · 0.80
CreatorInfoMethod · 0.80
CreateMethod · 0.45
fMethod · 0.45
gMethod · 0.45

Tested by

no test coverage detected