diff options
Diffstat (limited to 'cc/test/mock_helper.h')
-rw-r--r-- | cc/test/mock_helper.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/cc/test/mock_helper.h b/cc/test/mock_helper.h new file mode 100644 index 0000000..9ca9afb --- /dev/null +++ b/cc/test/mock_helper.h @@ -0,0 +1,29 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_TEST_MOCK_HELPER_H_ +#define CC_TEST_MOCK_HELPER_H_ + +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest-spi.h" +#include "testing/gtest/include/gtest/gtest.h" + +#define EXPECT_MOCK_FAILURE(statement) \ + do { \ + class GTestExpectMockFailureHelper { \ + public: \ + static void Execute() { statement; } \ + }; \ + ::testing::TestPartResultArray gtest_failures; \ + { \ + ::testing::ScopedFakeTestPartResultReporter gtest_reporter( \ + ::testing::ScopedFakeTestPartResultReporter:: \ + INTERCEPT_ONLY_CURRENT_THREAD, \ + >est_failures); \ + GTestExpectMockFailureHelper::Execute(); \ + } \ + EXPECT_GT(gtest_failures.size(), 0); \ + } while (::testing::internal::AlwaysFalse()) + +#endif // CC_TEST_MOCK_HELPER_H_ |