testing.h (1088B)
1 // Copyright (c) the JPEG XL Project Authors. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 #ifndef LIB_JPEGLI_TESTING_H_ 7 #define LIB_JPEGLI_TESTING_H_ 8 9 // GTest/GMock specific macros / wrappers. 10 11 // gmock unconditionally redefines those macros (to wrong values). 12 // Lets include it only here and mitigate the problem. 13 #pragma push_macro("PRIdS") 14 #pragma push_macro("PRIuS") 15 #include "gmock/gmock.h" 16 #pragma pop_macro("PRIuS") 17 #pragma pop_macro("PRIdS") 18 19 #include "gtest/gtest.h" 20 21 // googletest before 1.10 didn't define INSTANTIATE_TEST_SUITE_P() but instead 22 // used INSTANTIATE_TEST_CASE_P which is now deprecated. 23 #ifdef INSTANTIATE_TEST_SUITE_P 24 #define JPEGLI_INSTANTIATE_TEST_SUITE_P INSTANTIATE_TEST_SUITE_P 25 #else 26 #define JPEGLI_INSTANTIATE_TEST_SUITE_P INSTANTIATE_TEST_CASE_P 27 #endif 28 29 // Ensures that we don't make our test bounds too lax, effectively disabling the 30 // tests. 31 MATCHER_P(IsSlightlyBelow, max, "") { 32 return max * 0.75 <= arg && arg <= max * 1.0; 33 } 34 35 #endif // LIB_JPEGLI_TESTING_H_