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

Function test_invoke_r

dlib/test/invoke.cpp:364–414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362 };
363
364 void test_invoke_r()
365 {
366 {
367 static_assert(dlib::is_invocable_r<std::string, decltype(func_return_c_string)>::value, "should be invocable");
368 auto str = dlib::invoke_r<std::string>(func_return_c_string);
369 static_assert(std::is_same<decltype(str), std::string>::value, "bad return type");
370 DLIB_TEST(str == "hello darkness my old friend");
371 }
372
373 {
374 obj_return_c_string obj;
375 static_assert(dlib::is_invocable_r<std::string, decltype(&obj_return_c_string::run), decltype(obj)>::value, "should be invocable");
376 auto str = dlib::invoke_r<std::string>(&obj_return_c_string::run, obj);
377 static_assert(std::is_same<decltype(str), std::string>::value, "bad return type");
378 DLIB_TEST(str == "i've come to talk with you again");
379 }
380
381 {
382 obj_return_c_string obj;
383 static_assert(dlib::is_invocable_r<std::string, decltype(&obj_return_c_string::run), decltype(&obj)>::value, "should be invocable");
384 auto str = dlib::invoke_r<std::string>(&obj_return_c_string::run, &obj);
385 static_assert(std::is_same<decltype(str), std::string>::value, "bad return type");
386 DLIB_TEST(str == "i've come to talk with you again");
387 }
388
389 {
390 auto obj = std::make_shared<obj_return_c_string>();
391 static_assert(dlib::is_invocable_r<std::string, decltype(&obj_return_c_string::run), decltype(obj)>::value, "should be invocable");
392 auto str = dlib::invoke_r<std::string>(&obj_return_c_string::run, obj);
393 static_assert(std::is_same<decltype(str), std::string>::value, "bad return type");
394 DLIB_TEST(str == "i've come to talk with you again");
395 }
396
397 {
398 std::unique_ptr<obj_return_c_string> obj(new obj_return_c_string());
399 static_assert(dlib::is_invocable_r<std::string, decltype(&obj_return_c_string::run), decltype(obj)>::value, "should be invocable");
400 auto str = dlib::invoke_r<std::string>(&obj_return_c_string::run, obj);
401 static_assert(std::is_same<decltype(str), std::string>::value, "bad return type");
402 DLIB_TEST(str == "i've come to talk with you again");
403 }
404
405 {
406 auto lambda_return_c_string = [] {
407 return "because a vision softly creeping";
408 };
409 static_assert(dlib::is_invocable_r<std::string, decltype(lambda_return_c_string)>::value, "should be invocable");
410 auto str = dlib::invoke_r<std::string>(lambda_return_c_string);
411 static_assert(std::is_same<decltype(str), std::string>::value, "bad return type");
412 DLIB_TEST(str == "because a vision softly creeping");
413 }
414 }
415
416 // ----------------------------------------------------------------------------------------
417

Callers 1

perform_testMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected