2021-12-14 23:37:23 +08:00
/*
2023-12-13 17:17:24 +08:00
* Copyright ( C ) 2021 - 2023 Intel Corporation
2021-12-14 23:37:23 +08:00
*
* SPDX - License - Identifier : MIT
*
*/
# pragma once
# include "gtest/gtest.h"
# include "test_mode.h"
2022-06-30 03:17:47 +08:00
template < typename Fixture >
struct Test
: public Fixture ,
public : : testing : : Test {
2022-08-11 19:28:20 +08:00
void SetUp ( ) override {
Fixture : : setUp ( ) ;
}
void TearDown ( ) override {
Fixture : : tearDown ( ) ;
}
} ;
2021-12-14 23:37:23 +08:00
# define TO_STR2(x) #x
# define TO_STR(x) TO_STR2(x)
# define TEST_MAX_LENGTH 140
# define CHECK_TEST_NAME_LENGTH_WITH_MAX(test_fixture, test_name, max_length) \
2023-12-13 17:17:24 +08:00
static_assert ( ( NEO : : defaultTestMode ! = NEO : : TestMode : : aubTests & & NEO : : defaultTestMode ! = NEO : : TestMode : : aubTestsWithTbx ) | | ( sizeof ( # test_fixture ) + sizeof ( # test_name ) < = max_length ) , " Test and fixture names length exceeds max allowed size: " TO_STR ( max_length ) ) ;
2021-12-14 23:37:23 +08:00
# define CHECK_TEST_NAME_LENGTH(test_fixture, test_name) \
CHECK_TEST_NAME_LENGTH_WITH_MAX ( test_fixture , test_name , TEST_MAX_LENGTH )
# ifdef TEST_F
# undef TEST_F
# endif
// Taken from gtest.h
# define TEST_F(test_fixture, test_name) \
CHECK_TEST_NAME_LENGTH ( test_fixture , test_name ) \
GTEST_TEST_ ( test_fixture , test_name , test_fixture , \
: : testing : : internal : : GetTypeId < test_fixture > ( ) )
# ifdef TEST_P
# undef TEST_P
# endif
// Taken from gtest.h
# define TEST_P(test_suite_name, test_name) \
CHECK_TEST_NAME_LENGTH ( test_fixture , test_name ) \
class GTEST_TEST_CLASS_NAME_ ( test_suite_name , test_name ) \
: public test_suite_name { \
public : \
GTEST_TEST_CLASS_NAME_ ( test_suite_name , test_name ) \
( ) { } \
void TestBody ( ) override ; \
\
private : \
static int AddToRegistry ( ) { \
: : testing : : UnitTest : : GetInstance ( ) - > parameterized_test_registry ( ) . GetTestCasePatternHolder < test_suite_name > ( \
# test_suite_name, ::testing::internal::CodeLocation(__FILE__, __LINE__)) \
- > AddTestPattern ( \
# test_suite_name, \
# test_name, \
new : : testing : : internal : : TestMetaFactory < \
GTEST_TEST_CLASS_NAME_ ( test_suite_name , test_name ) > ( ) ) ; \
return 0 ; \
} \
static int gtest_registering_dummy_ ; \
GTEST_DISALLOW_COPY_AND_ASSIGN_ ( \
GTEST_TEST_CLASS_NAME_ ( test_suite_name , test_name ) ) ; \
} ; \
int GTEST_TEST_CLASS_NAME_ ( test_suite_name , \
test_name ) : : gtest_registering_dummy_ = \
GTEST_TEST_CLASS_NAME_ ( test_suite_name , test_name ) : : AddToRegistry ( ) ; \
void GTEST_TEST_CLASS_NAME_ ( test_suite_name , test_name ) : : TestBody ( )