MCPcopy Create free account
hub / github.com/davisking/dlib / test_make_from_tuple

Function test_make_from_tuple

dlib/test/invoke.cpp:313–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311 // ----------------------------------------------------------------------------------------
312
313 void test_make_from_tuple()
314 {
315 struct multi_args_object
316 {
317 multi_args_object(int i_, int j_) : i(i_), j(j_) {}
318 int i = 0;
319 int j = 0;
320 };
321
322 {
323 auto obj = dlib::make_from_tuple<multi_args_object>(std::make_tuple(1, 2));
324 static_assert(std::is_same<decltype(obj), multi_args_object>::value, "bad type");
325 DLIB_TEST(obj.i == 1);
326 DLIB_TEST(obj.j == 2);
327 }
328
329 {
330 std::array<int,2> a = {3, 4};
331 auto obj = dlib::make_from_tuple<multi_args_object>(a);
332 static_assert(std::is_same<decltype(obj), multi_args_object>::value, "bad type");
333 DLIB_TEST(obj.i == 3);
334 DLIB_TEST(obj.j == 4);
335 }
336
337 {
338 auto obj = dlib::make_from_tuple<multi_args_object>(std::make_pair(5, 6));
339 static_assert(std::is_same<decltype(obj), multi_args_object>::value, "bad type");
340 DLIB_TEST(obj.i == 5);
341 DLIB_TEST(obj.j == 6);
342 }
343 }
344
345 // ----------------------------------------------------------------------------------------
346

Callers 1

perform_testMethod · 0.85

Calls 1

make_tupleFunction · 0.85

Tested by

no test coverage detected