testing.h (1153B)
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 specific macros / wrappers. 10 11 #include "gtest/gtest.h" 12 13 // googletest before 1.10 didn't define INSTANTIATE_TEST_SUITE_P() but instead 14 // used INSTANTIATE_TEST_CASE_P which is now deprecated. 15 #ifdef INSTANTIATE_TEST_SUITE_P 16 #define JPEGLI_INSTANTIATE_TEST_SUITE_P INSTANTIATE_TEST_SUITE_P 17 #else 18 #define JPEGLI_INSTANTIATE_TEST_SUITE_P INSTANTIATE_TEST_CASE_P 19 #endif 20 21 // Replacement for ASSERT_TRUE inside try-catch blocks. 22 #define JPEGLI_TEST_ENSURE_TRUE(C) \ 23 if (!(C)) return false; 24 25 #define QUIT(M) FAIL() << M 26 27 // Ensures that we don't make our test bounds too lax, effectively disabling the 28 // tests. 29 #define EXPECT_SLIGHTLY_BELOW(A, E) \ 30 { \ 31 double _actual = (A); \ 32 double _expected = (E); \ 33 EXPECT_LE(_actual, _expected); \ 34 EXPECT_GE(_actual, 0.75 * _expected); \ 35 } 36 37 #endif // LIB_JPEGLI_TESTING_H_