1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
5 // Copyright (C) 2018-2019 Intel Corporation
8 #include "test_precomp.hpp"
10 namespace opencv_test {
11 // Tests on T/Kind matching ////////////////////////////////////////////////////
14 template<class T, cv::detail::ArgKind Exp>
18 static const constexpr cv::detail::ArgKind kind = Exp;
22 struct GArgKind: public ::testing::Test
24 using Type = typename T::type;
25 const cv::detail::ArgKind Kind = T::kind;
28 // The reason here is to _manually_ list types and their kinds
29 // (and NOT reuse cv::detail::ArgKind::Traits<>, since it is a subject of testing)
30 using GArg_Test_Types = ::testing::Types
33 Expected<cv::GMat, cv::detail::ArgKind::GMAT>
34 , Expected<cv::GScalar, cv::detail::ArgKind::GSCALAR>
35 , Expected<cv::GArray<int>, cv::detail::ArgKind::GARRAY>
36 , Expected<cv::GArray<float>, cv::detail::ArgKind::GARRAY>
37 , Expected<cv::GArray<cv::Point>, cv::detail::ArgKind::GARRAY>
38 , Expected<cv::GArray<cv::Rect>, cv::detail::ArgKind::GARRAY>
41 , Expected<int, cv::detail::ArgKind::OPAQUE>
42 , Expected<float, cv::detail::ArgKind::OPAQUE>
43 , Expected<int*, cv::detail::ArgKind::OPAQUE>
44 , Expected<cv::Point, cv::detail::ArgKind::OPAQUE>
45 , Expected<std::string, cv::detail::ArgKind::OPAQUE>
46 , Expected<cv::Mat, cv::detail::ArgKind::OPAQUE>
47 , Expected<std::vector<int>, cv::detail::ArgKind::OPAQUE>
48 , Expected<std::vector<cv::Point>, cv::detail::ArgKind::OPAQUE>
51 TYPED_TEST_CASE(GArgKind, GArg_Test_Types);
53 TYPED_TEST(GArgKind, LocalVar)
55 typename TestFixture::Type val{};
57 EXPECT_EQ(TestFixture::Kind, arg.kind);
60 TYPED_TEST(GArgKind, ConstLocalVar)
62 const typename TestFixture::Type val{};
64 EXPECT_EQ(TestFixture::Kind, arg.kind);
67 TYPED_TEST(GArgKind, RValue)
69 cv::GArg arg = cv::GArg(typename TestFixture::Type());
70 EXPECT_EQ(TestFixture::Kind, arg.kind);
74 ////////////////////////////////////////////////////////////////////////////////
78 static_assert(!cv::detail::has_custom_wrap<cv::GMat>::value,
79 "GMat has no custom marshalling logic");
80 static_assert(!cv::detail::has_custom_wrap<cv::GScalar>::value,
81 "GScalar has no custom marshalling logic");
83 static_assert(cv::detail::has_custom_wrap<cv::GArray<int> >::value,
84 "GArray<int> has custom marshalling logic");
85 static_assert(cv::detail::has_custom_wrap<cv::GArray<std::string> >::value,
86 "GArray<int> has custom marshalling logic");
91 // Placing a GArray<T> into GArg automatically strips it to GArrayU
92 cv::GArg arg1 = cv::GArg(cv::GArray<int>());
93 EXPECT_NO_THROW(arg1.get<cv::detail::GArrayU>());
95 cv::GArg arg2 = cv::GArg(cv::GArray<cv::Point>());
96 EXPECT_NO_THROW(arg2.get<cv::detail::GArrayU>());
100 } // namespace opencv_test