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.
4 
5 // Copyright (C) 2014, Intel, Inc., all rights reserved.
6 // Third party copyrights are property of their respective owners.
7 
8 #ifndef __OPENCV_TS_EXT_HPP__
9 #define __OPENCV_TS_EXT_HPP__
10 
11 void checkIppStatus();
12 
13 #undef TEST
14 #define TEST(test_case_name, test_name) \
15     class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public ::testing::Test {\
16      public:\
17       GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\
18      private:\
19       virtual void TestBody();\
20       virtual void Body();\
21       static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\
22       GTEST_DISALLOW_COPY_AND_ASSIGN_(\
23           GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\
24     };\
25     \
26     ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\
27       ::test_info_ =\
28         ::testing::internal::MakeAndRegisterTestInfo(\
29             #test_case_name, #test_name, NULL, NULL, \
30             (::testing::internal::GetTestTypeId()), \
31             ::testing::Test::SetUpTestCase, \
32             ::testing::Test::TearDownTestCase, \
33             new ::testing::internal::TestFactoryImpl<\
34                 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\
35     void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() { cv::ipp::setIppStatus(0); Body(); checkIppStatus(); } \
36     void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::Body()
37 
38 #undef TEST_F
39 #define TEST_F(test_fixture, test_name)\
40     class GTEST_TEST_CLASS_NAME_(test_fixture, test_name) : public test_fixture {\
41      public:\
42       GTEST_TEST_CLASS_NAME_(test_fixture, test_name)() {}\
43      private:\
44       virtual void TestBody();\
45       virtual void Body(); \
46       static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\
47       GTEST_DISALLOW_COPY_AND_ASSIGN_(\
48           GTEST_TEST_CLASS_NAME_(test_fixture, test_name));\
49     };\
50     \
51     ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_fixture, test_name)\
52       ::test_info_ =\
53         ::testing::internal::MakeAndRegisterTestInfo(\
54             #test_fixture, #test_name, NULL, NULL, \
55             (::testing::internal::GetTypeId<test_fixture>()), \
56             test_fixture::SetUpTestCase, \
57             test_fixture::TearDownTestCase, \
58             new ::testing::internal::TestFactoryImpl<\
59                 GTEST_TEST_CLASS_NAME_(test_fixture, test_name)>);\
60     void GTEST_TEST_CLASS_NAME_(test_fixture, test_name)::TestBody() { cv::ipp::setIppStatus(0); Body(); checkIppStatus(); } \
61     void GTEST_TEST_CLASS_NAME_(test_fixture, test_name)::Body()
62 
63 #undef TEST_P
64 #define TEST_P(test_case_name, test_name) \
65   class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
66       : public test_case_name { \
67    public: \
68     GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \
69    private: \
70     virtual void Body(); \
71     virtual void TestBody(); \
72     static int AddToRegistry() { \
73       ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
74           GetTestCasePatternHolder<test_case_name>(\
75               #test_case_name, __FILE__, __LINE__)->AddTestPattern(\
76                   #test_case_name, \
77                   #test_name, \
78                   new ::testing::internal::TestMetaFactory< \
79                       GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \
80       return 0; \
81     } \
82     static int gtest_registering_dummy_; \
83     GTEST_DISALLOW_COPY_AND_ASSIGN_(\
84         GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \
85   }; \
86   int GTEST_TEST_CLASS_NAME_(test_case_name, \
87                              test_name)::gtest_registering_dummy_ = \
88       GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \
89     void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() { cv::ipp::setIppStatus(0); Body(); checkIppStatus(); } \
90     void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::Body()
91 
92 #endif  // __OPENCV_TS_EXT_HPP__
93