Path: blob/master/modules/gapi/test/internal/gapi_int_garg_test.cpp
16344 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"89namespace opencv_test {10// Tests on T/Kind matching ////////////////////////////////////////////////////11// {{1213template<class T, cv::detail::ArgKind Exp>14struct Expected15{16using type = T;17static const constexpr cv::detail::ArgKind kind = Exp;18};1920template<typename T>21struct GArgKind: public ::testing::Test22{23using Type = typename T::type;24const cv::detail::ArgKind Kind = T::kind;25};2627// The reason here is to _manually_ list types and their kinds28// (and NOT reuse cv::detail::ArgKind::Traits<>, since it is a subject of testing)29using GArg_Test_Types = ::testing::Types30<31// G-API types32Expected<cv::GMat, cv::detail::ArgKind::GMAT>33, Expected<cv::GScalar, cv::detail::ArgKind::GSCALAR>34, Expected<cv::GArray<int>, cv::detail::ArgKind::GARRAY>35, Expected<cv::GArray<float>, cv::detail::ArgKind::GARRAY>36, Expected<cv::GArray<cv::Point>, cv::detail::ArgKind::GARRAY>37, Expected<cv::GArray<cv::Rect>, cv::detail::ArgKind::GARRAY>3839// Built-in types40, Expected<int, cv::detail::ArgKind::OPAQUE>41, Expected<float, cv::detail::ArgKind::OPAQUE>42, Expected<int*, cv::detail::ArgKind::OPAQUE>43, Expected<cv::Point, cv::detail::ArgKind::OPAQUE>44, Expected<std::string, cv::detail::ArgKind::OPAQUE>45, Expected<cv::Mat, cv::detail::ArgKind::OPAQUE>46, Expected<std::vector<int>, cv::detail::ArgKind::OPAQUE>47, Expected<std::vector<cv::Point>, cv::detail::ArgKind::OPAQUE>48>;4950TYPED_TEST_CASE(GArgKind, GArg_Test_Types);5152TYPED_TEST(GArgKind, LocalVar)53{54typename TestFixture::Type val{};55cv::GArg arg(val);56EXPECT_EQ(TestFixture::Kind, arg.kind);57}5859TYPED_TEST(GArgKind, ConstLocalVar)60{61const typename TestFixture::Type val{};62cv::GArg arg(val);63EXPECT_EQ(TestFixture::Kind, arg.kind);64}6566TYPED_TEST(GArgKind, RValue)67{68cv::GArg arg = cv::GArg(typename TestFixture::Type());69EXPECT_EQ(TestFixture::Kind, arg.kind);70}7172// }}73////////////////////////////////////////////////////////////////////////////////7475TEST(GArg, HasWrap)76{77static_assert(!cv::detail::has_custom_wrap<cv::GMat>::value,78"GMat has no custom marshalling logic");79static_assert(!cv::detail::has_custom_wrap<cv::GScalar>::value,80"GScalar has no custom marshalling logic");8182static_assert(cv::detail::has_custom_wrap<cv::GArray<int> >::value,83"GArray<int> has custom marshalling logic");84static_assert(cv::detail::has_custom_wrap<cv::GArray<std::string> >::value,85"GArray<int> has custom marshalling logic");86}8788TEST(GArg, GArrayU)89{90// Placing a GArray<T> into GArg automatically strips it to GArrayU91cv::GArg arg1 = cv::GArg(cv::GArray<int>());92EXPECT_NO_THROW(arg1.get<cv::detail::GArrayU>());9394cv::GArg arg2 = cv::GArg(cv::GArray<cv::Point>());95EXPECT_NO_THROW(arg2.get<cv::detail::GArrayU>());96}979899} // namespace opencv_test100101102