Path: blob/master/modules/gapi/test/internal/gapi_int_gmetaarg_test.cpp
16339 views
// This file is part of OpenCV project.1// It is subject to the license terms in the LICENSE file found in the top-level directory2// of this distribution and at http://opencv.org/license.html.3//4// Copyright (C) 2018 Intel Corporation567#include "test_precomp.hpp"89#include "api/gcomputation_priv.hpp"1011namespace opencv_test12{1314TEST(GMetaArg, Traits_Is_Positive)15{16using namespace cv::detail;1718static_assert(is_meta_descr<cv::GScalarDesc>::value,19"GScalarDesc is a meta description type");2021static_assert(is_meta_descr<cv::GMatDesc>::value,22"GMatDesc is a meta description type");23}2425TEST(GMetaArg, Traits_Is_Negative)26{27using namespace cv::detail;2829static_assert(!is_meta_descr<cv::GCompileArgs>::value,30"GCompileArgs is NOT a meta description type");3132static_assert(!is_meta_descr<int>::value,33"int is NOT a meta description type");3435static_assert(!is_meta_descr<std::string>::value,36"str::string is NOT a meta description type");37}3839TEST(GMetaArg, Traits_Are_EntireList_Positive)40{41using namespace cv::detail;4243static_assert(are_meta_descrs<cv::GScalarDesc>::value,44"GScalarDesc is a meta description type");4546static_assert(are_meta_descrs<cv::GMatDesc>::value,47"GMatDesc is a meta description type");4849static_assert(are_meta_descrs<cv::GMatDesc, cv::GScalarDesc>::value,50"Both GMatDesc and GScalarDesc are meta types");51}5253TEST(GMetaArg, Traits_Are_EntireList_Negative)54{55using namespace cv::detail;5657static_assert(!are_meta_descrs<cv::GCompileArgs>::value,58"GCompileArgs is NOT among meta types");5960static_assert(!are_meta_descrs<int, std::string>::value,61"Both int and std::string is NOT among meta types");6263static_assert(!are_meta_descrs<cv::GMatDesc, cv::GScalarDesc, int>::value,64"List of type is not valid for meta as there\'s int");6566static_assert(!are_meta_descrs<cv::GMatDesc, cv::GScalarDesc, cv::GCompileArgs>::value,67"List of type is not valid for meta as there\'s GCompileArgs");68}6970TEST(GMetaArg, Traits_Are_ButLast_Positive)71{72using namespace cv::detail;7374static_assert(are_meta_descrs_but_last<cv::GScalarDesc, int>::value,75"List is valid (int is ommitted)");7677static_assert(are_meta_descrs_but_last<cv::GMatDesc, cv::GScalarDesc, cv::GCompileArgs>::value,78"List is valid (GCompileArgs are omitted)");79}8081TEST(GMetaArg, Traits_Are_ButLast_Negative)82{83using namespace cv::detail;8485static_assert(!are_meta_descrs_but_last<int, std::string>::value,86"Both int is NOT among meta types (std::string is omitted)");8788static_assert(!are_meta_descrs_but_last<cv::GMatDesc, cv::GScalarDesc, int, int>::value,89"List of type is not valid for meta as there\'s two ints");9091static_assert(!are_meta_descrs_but_last<cv::GMatDesc, cv::GScalarDesc, cv::GCompileArgs, float>::value,92"List of type is not valid for meta as there\'s GCompileArgs");93}9495TEST(GMetaArg, Can_Get_Metas_From_Input_Run_Args)96{97cv::Mat m(3, 3, CV_8UC3);98cv::Scalar s;99std::vector<int> v;100101GMatDesc m_desc;102GMetaArgs meta_args = descr_of(cv::gin(m, s, v));103104EXPECT_EQ(meta_args.size(), 3u);105EXPECT_NO_THROW(m_desc = util::get<cv::GMatDesc>(meta_args[0]));106EXPECT_NO_THROW(util::get<cv::GScalarDesc>(meta_args[1]));107EXPECT_NO_THROW(util::get<cv::GArrayDesc>(meta_args[2]));108109EXPECT_EQ(CV_8U, m_desc.depth);110EXPECT_EQ(3, m_desc.chan);111EXPECT_EQ(cv::gapi::own::Size(3, 3), m_desc.size);112}113114TEST(GMetaArg, Can_Get_Metas_From_Output_Run_Args)115{116cv::Mat m(3, 3, CV_8UC3);117cv::Scalar s;118std::vector<int> v;119120GMatDesc m_desc;121GRunArgsP out_run_args = cv::gout(m, s, v);122GMetaArg m_meta = descr_of(out_run_args[0]);123GMetaArg s_meta = descr_of(out_run_args[1]);124GMetaArg v_meta = descr_of(out_run_args[2]);125126EXPECT_NO_THROW(m_desc = util::get<cv::GMatDesc>(m_meta));127EXPECT_NO_THROW(util::get<cv::GScalarDesc>(s_meta));128EXPECT_NO_THROW(util::get<cv::GArrayDesc>(v_meta));129130EXPECT_EQ(CV_8U, m_desc.depth);131EXPECT_EQ(3, m_desc.chan);132EXPECT_EQ(cv::Size(3, 3), m_desc.size);133}134135} // namespace opencv_test136137138