Path: blob/master/modules/gapi/test/internal/gapi_int_recompilation_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"8#include "api/gcomputation_priv.hpp"910namespace opencv_test11{1213TEST(GComputationCompile, NoRecompileWithSameMeta)14{15cv::GMat in;16cv::GComputation cc(in, in+in);1718cv::Mat in_mat1 = cv::Mat::eye (32, 32, CV_8UC1);19cv::Mat in_mat2 = cv::Mat::zeros(32, 32, CV_8UC1);20cv::Mat out_mat;2122cc.apply(in_mat1, out_mat);23auto comp1 = cc.priv().m_lastCompiled;2425cc.apply(in_mat2, out_mat);26auto comp2 = cc.priv().m_lastCompiled;2728// Both compiled objects are actually the same unique executable29EXPECT_EQ(&comp1.priv(), &comp2.priv());30}3132TEST(GComputationCompile, NoRecompileWithWrongMeta)33{34cv::GMat in;35cv::GComputation cc(in, in+in);3637cv::Mat in_mat1 = cv::Mat::eye (32, 32, CV_8UC1);38cv::Mat in_mat2 = cv::Mat::zeros(32, 32, CV_8UC1);39cv::Mat out_mat;4041cc.apply(in_mat1, out_mat);42auto comp1 = cc.priv().m_lastCompiled;4344EXPECT_THROW(cc.apply(cv::gin(cv::Scalar(128)), cv::gout(out_mat)), std::logic_error);45auto comp2 = cc.priv().m_lastCompiled;4647// Both compiled objects are actually the same unique executable48EXPECT_EQ(&comp1.priv(), &comp2.priv());49}5051TEST(GComputationCompile, RecompileWithDifferentMeta)52{53cv::GMat in;54cv::GComputation cc(in, in+in);5556cv::Mat in_mat1 = cv::Mat::eye (32, 32, CV_8UC1);57cv::Mat in_mat2 = cv::Mat::zeros(64, 64, CV_32F);58cv::Mat out_mat;5960cc.apply(in_mat1, out_mat);61auto comp1 = cc.priv().m_lastCompiled;6263cc.apply(in_mat2, out_mat);64auto comp2 = cc.priv().m_lastCompiled;6566// Both compiled objects are different67EXPECT_NE(&comp1.priv(), &comp2.priv());68}6970} // opencv_test717273