| Index: net/test/gtest_util.h
|
| diff --git a/net/test/gtest_util.h b/net/test/gtest_util.h
|
| index 2769c34d588c8cc3fdb15adc563c5ca6a825be10..f8b4cf573c287648c6e8be25c4e8ba05b304718b 100644
|
| --- a/net/test/gtest_util.h
|
| +++ b/net/test/gtest_util.h
|
| @@ -8,6 +8,7 @@
|
| #define NET_TEST_GTEST_UTIL_H_
|
|
|
| #include "base/test/mock_log.h"
|
| +#include "net/base/net_errors.h"
|
| #include "net/test/scoped_disable_exit_on_dfatal.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| @@ -15,6 +16,26 @@
|
| namespace net {
|
| namespace test {
|
|
|
| +// A GMock matcher that checks whether the argument is the expected net::Error.
|
| +// On failure, the expected and actual net::Error names will be printed.
|
| +// Usage: EXPECT_THAT(foo(), IsError(net::ERR_INVALID_ARGUMENT));
|
| +MATCHER_P(IsError,
|
| + expected,
|
| + std::string(negation ? "not " : "") + net::ErrorToString(expected)) {
|
| + if (arg <= 0)
|
| + *result_listener << net::ErrorToString(arg);
|
| + return arg == expected;
|
| +}
|
| +
|
| +// Shorthand for IsError(net::OK).
|
| +// Usage: EXPECT_THAT(foo(), IsOk());
|
| +MATCHER(IsOk,
|
| + std::string(negation ? "not " : "") + net::ErrorToString(net::OK)) {
|
| + if (arg <= 0)
|
| + *result_listener << net::ErrorToString(arg);
|
| + return arg == net::OK;
|
| +}
|
| +
|
| // Internal implementation for the EXPECT_DFATAL and ASSERT_DFATAL
|
| // macros. Do not use this directly.
|
| #define GTEST_DFATAL_(statement, matcher, fail) \
|
|
|