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 #include "api/gcomputation_priv.hpp"
15 TEST(GMetaArg, Traits_Is_Positive)
17 using namespace cv::detail;
19 static_assert(is_meta_descr<cv::GScalarDesc>::value,
20 "GScalarDesc is a meta description type");
22 static_assert(is_meta_descr<cv::GMatDesc>::value,
23 "GMatDesc is a meta description type");
26 TEST(GMetaArg, Traits_Is_Negative)
28 using namespace cv::detail;
30 static_assert(!is_meta_descr<cv::GCompileArgs>::value,
31 "GCompileArgs is NOT a meta description type");
33 static_assert(!is_meta_descr<int>::value,
34 "int is NOT a meta description type");
36 static_assert(!is_meta_descr<std::string>::value,
37 "str::string is NOT a meta description type");
40 TEST(GMetaArg, Traits_Are_EntireList_Positive)
42 using namespace cv::detail;
44 static_assert(are_meta_descrs<cv::GScalarDesc>::value,
45 "GScalarDesc is a meta description type");
47 static_assert(are_meta_descrs<cv::GMatDesc>::value,
48 "GMatDesc is a meta description type");
50 static_assert(are_meta_descrs<cv::GMatDesc, cv::GScalarDesc>::value,
51 "Both GMatDesc and GScalarDesc are meta types");
54 TEST(GMetaArg, Traits_Are_EntireList_Negative)
56 using namespace cv::detail;
58 static_assert(!are_meta_descrs<cv::GCompileArgs>::value,
59 "GCompileArgs is NOT among meta types");
61 static_assert(!are_meta_descrs<int, std::string>::value,
62 "Both int and std::string is NOT among meta types");
64 static_assert(!are_meta_descrs<cv::GMatDesc, cv::GScalarDesc, int>::value,
65 "List of type is not valid for meta as there\'s int");
67 static_assert(!are_meta_descrs<cv::GMatDesc, cv::GScalarDesc, cv::GCompileArgs>::value,
68 "List of type is not valid for meta as there\'s GCompileArgs");
71 TEST(GMetaArg, Traits_Are_ButLast_Positive)
73 using namespace cv::detail;
75 static_assert(are_meta_descrs_but_last<cv::GScalarDesc, int>::value,
76 "List is valid (int is ommitted)");
78 static_assert(are_meta_descrs_but_last<cv::GMatDesc, cv::GScalarDesc, cv::GCompileArgs>::value,
79 "List is valid (GCompileArgs are omitted)");
82 TEST(GMetaArg, Traits_Are_ButLast_Negative)
84 using namespace cv::detail;
86 static_assert(!are_meta_descrs_but_last<int, std::string>::value,
87 "Both int is NOT among meta types (std::string is omitted)");
89 static_assert(!are_meta_descrs_but_last<cv::GMatDesc, cv::GScalarDesc, int, int>::value,
90 "List of type is not valid for meta as there\'s two ints");
92 static_assert(!are_meta_descrs_but_last<cv::GMatDesc, cv::GScalarDesc, cv::GCompileArgs, float>::value,
93 "List of type is not valid for meta as there\'s GCompileArgs");
96 TEST(GMetaArg, Can_Get_Metas_From_Input_Run_Args)
98 cv::Mat m(3, 3, CV_8UC3);
103 GMetaArgs meta_args = descr_of(cv::gin(m, s, v));
105 EXPECT_EQ(meta_args.size(), 3u);
106 EXPECT_NO_THROW(m_desc = util::get<cv::GMatDesc>(meta_args[0]));
107 EXPECT_NO_THROW(util::get<cv::GScalarDesc>(meta_args[1]));
108 EXPECT_NO_THROW(util::get<cv::GArrayDesc>(meta_args[2]));
110 EXPECT_EQ(CV_8U, m_desc.depth);
111 EXPECT_EQ(3, m_desc.chan);
112 EXPECT_EQ(cv::gapi::own::Size(3, 3), m_desc.size);
115 TEST(GMetaArg, Can_Get_Metas_From_Output_Run_Args)
117 cv::Mat m(3, 3, CV_8UC3);
122 GRunArgsP out_run_args = cv::gout(m, s, v);
123 GMetaArg m_meta = descr_of(out_run_args[0]);
124 GMetaArg s_meta = descr_of(out_run_args[1]);
125 GMetaArg v_meta = descr_of(out_run_args[2]);
127 EXPECT_NO_THROW(m_desc = util::get<cv::GMatDesc>(m_meta));
128 EXPECT_NO_THROW(util::get<cv::GScalarDesc>(s_meta));
129 EXPECT_NO_THROW(util::get<cv::GArrayDesc>(v_meta));
131 EXPECT_EQ(CV_8U, m_desc.depth);
132 EXPECT_EQ(3, m_desc.chan);
133 EXPECT_EQ(cv::Size(3, 3), m_desc.size);
136 } // namespace opencv_test