mirror of
https://github.com/opencv/opencv.git
synced 2024-12-02 16:00:17 +08:00
29e88e50ff
* G-API Initial code upload * Update G-API code base to Sep-24-2018 * The majority of OpenCV buildbot problems was addressed * Update G-API code base to 24-Sep-18 EOD * G-API code base update 25-Sep-2018 * Linux warnings should be resolved * Documentation build should become green * Number of Windows warnings should be reduced * Update G-API code base to 25-Sep-18 EOD * ARMv7 build issue should be resolved * ADE is bumped to latest version and should fix Clang builds for macOS/iOS * Remaining Windows warnings should be resolved * New Linux32 / ARMv7 warnings should be resolved * G-API code base update 25-Sep-2018-EOD2 * Final Windows warnings should be resolved now * G-API code base update 26-Sep-2018 * Fixed issues with precompiled headers in module and its tests
122 lines
2.2 KiB
C++
122 lines
2.2 KiB
C++
// This file is part of OpenCV project.
|
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
// of this distribution and at http://opencv.org/license.html.
|
|
//
|
|
// Copyright (C) 2018 Intel Corporation
|
|
|
|
|
|
#include "test_precomp.hpp"
|
|
#include "opencv2/gapi/util/any.hpp"
|
|
|
|
namespace opencv_test
|
|
{
|
|
|
|
TEST(Any, basic)
|
|
{
|
|
using namespace util;
|
|
any a(8);
|
|
auto casted_pointer = any_cast<int>(&a);
|
|
ASSERT_NE(nullptr, casted_pointer);
|
|
ASSERT_EQ(*casted_pointer, 8);
|
|
|
|
*casted_pointer = 7;
|
|
ASSERT_EQ(any_cast<int>(a), 7);
|
|
}
|
|
|
|
TEST(Any, any_cast_ref_throws_on_empty)
|
|
{
|
|
using namespace util;
|
|
any a;
|
|
|
|
ASSERT_THROW(util::any_cast<int>(a), bad_any_cast);
|
|
}
|
|
|
|
TEST(Any, copy)
|
|
{
|
|
using namespace util;
|
|
any a(8);
|
|
|
|
ASSERT_EQ(any_cast<int>(a), 8);
|
|
|
|
any b (a);
|
|
|
|
ASSERT_NE(nullptr, any_cast<int>(&b));
|
|
ASSERT_EQ(8 , any_cast<int>(b));
|
|
ASSERT_EQ(8 , any_cast<int>(a));
|
|
}
|
|
|
|
TEST(Any, copy_empty)
|
|
{
|
|
using namespace util;
|
|
any a;
|
|
|
|
ASSERT_EQ(nullptr, any_cast<int>(&a));
|
|
|
|
any b (a);
|
|
|
|
ASSERT_EQ(nullptr, any_cast<int>(&a));
|
|
ASSERT_EQ(nullptr, any_cast<int>(&b));
|
|
}
|
|
|
|
TEST(Any, move)
|
|
{
|
|
using namespace util;
|
|
any a(8);
|
|
|
|
ASSERT_EQ(any_cast<int>(a), 8);
|
|
|
|
any b (std::move(a));
|
|
|
|
ASSERT_NE(nullptr, any_cast<int>(&b));
|
|
ASSERT_EQ(8 , any_cast<int>(b));
|
|
ASSERT_EQ(nullptr, any_cast<int>(&a));
|
|
}
|
|
|
|
TEST(Any, swap)
|
|
{
|
|
using namespace util;
|
|
any a(8);
|
|
any b(7);
|
|
|
|
ASSERT_EQ(7, any_cast<int>(b));
|
|
ASSERT_EQ(8, any_cast<int>(a));
|
|
|
|
swap(a,b);
|
|
|
|
ASSERT_EQ(8, any_cast<int>(b));
|
|
ASSERT_EQ(7, any_cast<int>(a));
|
|
}
|
|
|
|
TEST(Any, move_assign)
|
|
{
|
|
using namespace util;
|
|
any a(8);
|
|
any b;
|
|
|
|
ASSERT_EQ(any_cast<int>(a), 8);
|
|
|
|
b = (std::move(a));
|
|
|
|
ASSERT_NE(nullptr, any_cast<int>(&b));
|
|
ASSERT_EQ(8 , any_cast<int>(b));
|
|
ASSERT_EQ(nullptr, any_cast<int>(&a));
|
|
}
|
|
|
|
TEST(Any, copy_assign)
|
|
{
|
|
using namespace util;
|
|
any a(8);
|
|
any b;
|
|
|
|
ASSERT_EQ(any_cast<int>(a), 8);
|
|
ASSERT_EQ(nullptr, any_cast<int>(&b));
|
|
|
|
b = a;
|
|
|
|
ASSERT_NE(nullptr, any_cast<int>(&b));
|
|
ASSERT_EQ(8 , any_cast<int>(b));
|
|
ASSERT_EQ(8 , any_cast<int>(a));
|
|
}
|
|
|
|
} // namespace opencv_test
|