From 9ab5e52f04eb814a1fd7a7906cf8093e09af38df Mon Sep 17 00:00:00 2001 From: Pinaev Danil <41565593+aDanPin@users.noreply.github.com> Date: Tue, 8 Oct 2019 12:42:49 +0300 Subject: [PATCH] Merge pull request #15632 from aDanPin:dp/any_ref_tests * Add a few more tests on `any` Added tests: - get_ref_to_val_from_any - update_val_via_ref * Style fix --- modules/gapi/test/util/any_tests.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/modules/gapi/test/util/any_tests.cpp b/modules/gapi/test/util/any_tests.cpp index 9d3e9c9..238c6db 100644 --- a/modules/gapi/test/util/any_tests.cpp +++ b/modules/gapi/test/util/any_tests.cpp @@ -118,4 +118,25 @@ TEST(Any, copy_assign) ASSERT_EQ(8 , any_cast(a)); } +TEST(Any, get_ref_to_val_from_any) +{ + using namespace util; + int x = 8; + any a(x); + + int& casted_ref = any_cast(a); + ASSERT_EQ(casted_ref, 8); +} + +TEST(Any, update_val_via_ref) +{ + using namespace util; + int x = 8; + any a(x); + int& casted_ref = any_cast(a); + ASSERT_EQ(casted_ref, 8); + + casted_ref = 7; + ASSERT_EQ(any_cast(a), 7); +} } // namespace opencv_test -- 2.7.4