1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

GAPI: utils - variant::get_if

adding one more missing function to local version of std::variant
This commit is contained in:
Anton Potapov
2020-04-13 11:17:08 +03:00
committed by Anton Potapov
parent f351653589
commit dd2c7c5140
2 changed files with 49 additions and 9 deletions
+16
View File
@@ -289,6 +289,22 @@ TEST(Variant, Swap_DiffIndex)
EXPECT_EQ(3.14f, util::get<float>(tv1));
}
TEST(Variant, GetIf)
{
const TestVar cv(42);
// Test const& get_if()
EXPECT_EQ(nullptr, util::get_if<std::string>(&cv));
ASSERT_NE(nullptr, util::get_if<int>(&cv));
EXPECT_EQ(42, *util::get_if<int>(&cv));
// Test &get_if
TestVar cv2(std::string("42"));
EXPECT_EQ(nullptr, util::get_if<int>(&cv2));
ASSERT_NE(nullptr, util::get_if<std::string>(&cv2));
EXPECT_EQ("42", *util::get_if<std::string>(&cv2));
}
TEST(Variant, Get)
{
const TestVar cv(42);