[tf.data] Preparation of using GMock matchers in tensorflow tests.

PiperOrigin-RevId: 322865558
Change-Id: Ie8d7af71fec5933f371a8bc4a16133e2d7728566
This commit is contained in:
Jay Shi 2020-07-23 14:23:28 -07:00 committed by TensorFlower Gardener
parent 18b810a970
commit 5a58103a7d

View File

@ -23,13 +23,30 @@ limitations under the License.
#include "tensorflow/core/platform/platform.h"
#include "tensorflow/core/platform/types.h"
// As of September 2016, we continue to attempt to avoid the use of gmock aka
// googlemock included in the test framework
// (https://github.com/google/googletest) to discourage over-eager use of mocks
// that lead to cumbersome class hierarchies and tests that might end up not
// testing real code in important ways.
#include <gtest/gtest.h> // IWYU pragma: export
// Includes gmock.h and enables the use of gmock matchers in tensorflow tests.
//
// Test including this header can use the macros EXPECT_THAT(...) and
// ASSERT_THAT(...) in combination with gmock matchers.
// Example:
// std::vector<int> vec = Foo();
// EXPECT_THAT(vec, ::testing::ElementsAre(1,2,3));
// EXPECT_THAT(vec, ::testing::UnorderedElementsAre(2,3,1));
//
// For more details on gmock matchers see:
// https://github.com/google/googletest/blob/master/googlemock/docs/CheatSheet.md#matchers
//
// The advantages of using gmock matchers instead of self defined matchers are
// better error messages, more maintainable tests and more test coverage.
#if defined(PLATFORM_GOOGLE) || defined(PLATFORM_GOOGLE_ANDROID)
#include "testing/base/public/gmock.h"
#else
#include <gmock/gmock-generated-matchers.h>
#include <gmock/gmock-matchers.h>
#include <gmock/gmock-more-matchers.h>
#endif
namespace tensorflow {
namespace testing {