Formatting
This commit is contained in:
parent
67d3c0f6d7
commit
78d3bfeb44
@ -32,12 +32,14 @@
|
|||||||
// This header file declares functions and macros used internally by
|
// This header file declares functions and macros used internally by
|
||||||
// Google Test. They are subject to change without notice.
|
// Google Test. They are subject to change without notice.
|
||||||
|
|
||||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
// IWYU pragma: private, include "testing/base/public/gunit.h"
|
||||||
|
// IWYU pragma: friend third_party/googletest/googletest/.*
|
||||||
|
// IWYU pragma: friend third_party/googletest/googlemock/.*
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
|
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
|
||||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
|
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
|
||||||
|
|
||||||
#include "gtest/internal/gtest-port.h"
|
#include "third_party/googletest/googletest/include/gtest/internal/gtest-port.h"
|
||||||
|
|
||||||
#if GTEST_OS_LINUX
|
#if GTEST_OS_LINUX
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
@ -60,10 +62,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "gtest/gtest-message.h"
|
#include "third_party/googletest/googletest/include/gtest/gtest-message.h"
|
||||||
#include "gtest/internal/gtest-filepath.h"
|
#include "third_party/googletest/googletest/include/gtest/internal/gtest-filepath.h"
|
||||||
#include "gtest/internal/gtest-string.h"
|
#include "third_party/googletest/googletest/include/gtest/internal/gtest-string.h"
|
||||||
#include "gtest/internal/gtest-type-util.h"
|
#include "third_party/googletest/googletest/include/gtest/internal/gtest-type-util.h"
|
||||||
|
|
||||||
// Due to C++ preprocessor weirdness, we need double indirection to
|
// Due to C++ preprocessor weirdness, we need double indirection to
|
||||||
// concatenate two tokens when one of them is __LINE__. Writing
|
// concatenate two tokens when one of them is __LINE__. Writing
|
||||||
@ -752,7 +754,7 @@ class TypeParameterizedTestCase<Fixture, Templates0, Types> {
|
|||||||
// Returns the current OS stack trace as an std::string.
|
// Returns the current OS stack trace as an std::string.
|
||||||
//
|
//
|
||||||
// The maximum number of stack frames to be included is specified by
|
// The maximum number of stack frames to be included is specified by
|
||||||
// the gtest_stack_trace_depth flag. The skip_count parameter
|
// the gunit_stack_trace_depth flag. The skip_count parameter
|
||||||
// specifies the number of top frames to be skipped, which doesn't
|
// specifies the number of top frames to be skipped, which doesn't
|
||||||
// count against the number of frames to be included.
|
// count against the number of frames to be included.
|
||||||
//
|
//
|
||||||
@ -1189,16 +1191,15 @@ class NativeArray {
|
|||||||
GTEST_DISALLOW_ASSIGN_(NativeArray);
|
GTEST_DISALLOW_ASSIGN_(NativeArray);
|
||||||
};
|
};
|
||||||
|
|
||||||
class AdditionalMessage
|
class AdditionalMessage {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
AdditionalMessage(const char* message) : msg(message) {}
|
AdditionalMessage(const char* message) : msg(message) {}
|
||||||
void set(const std::string& message) { msg = message; }
|
void set(const std::string& message) { msg = message; }
|
||||||
operator bool() const { return true; }
|
operator bool() const { return true; }
|
||||||
|
|
||||||
const std::string& get() const { return msg; }
|
const std::string& get() const { return msg; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string msg;
|
std::string msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1227,58 +1228,60 @@ private:
|
|||||||
#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
|
#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
|
||||||
if (::testing::internal::AlwaysTrue()) { statement; }
|
if (::testing::internal::AlwaysTrue()) { statement; }
|
||||||
|
|
||||||
#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
|
#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
|
||||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||||
if (::testing::internal::AdditionalMessage message = "") { \
|
if (::testing::internal::AdditionalMessage message = "") { \
|
||||||
bool gtest_caught_expected = false; \
|
bool gtest_caught_expected = false; \
|
||||||
try { \
|
try { \
|
||||||
try { \
|
try { \
|
||||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
||||||
} \
|
} catch (expected_exception const&) { \
|
||||||
catch (expected_exception const&) { \
|
gtest_caught_expected = true; \
|
||||||
gtest_caught_expected = true; \
|
throw; \
|
||||||
throw; \
|
} \
|
||||||
} \
|
} catch (const std::exception& e) { \
|
||||||
} \
|
if (!gtest_caught_expected) { \
|
||||||
catch (const std::exception& e) { \
|
message.set( \
|
||||||
if (!gtest_caught_expected) { \
|
"it throws a different type " \
|
||||||
message.set("it throws a different type " \
|
"with message: " + \
|
||||||
"with message: " + std::string(e.what())); \
|
std::string(e.what())); \
|
||||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
|
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
|
||||||
} \
|
} \
|
||||||
} \
|
} catch (...) { \
|
||||||
catch (...) { \
|
if (!gtest_caught_expected) { \
|
||||||
if (!gtest_caught_expected) { \
|
message.set("it throws a different type."); \
|
||||||
message.set("it throws a different type."); \
|
|
||||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
|
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
if (!gtest_caught_expected) { \
|
if (!gtest_caught_expected) { \
|
||||||
message.set("it throws nothing."); \
|
message.set("it throws nothing."); \
|
||||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
|
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
|
||||||
} \
|
} \
|
||||||
} else \
|
} else \
|
||||||
GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
|
GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__) \
|
||||||
fail(("Expected: " #statement " throws an exception of type " \
|
: fail(("Expected: " #statement \
|
||||||
#expected_exception ".\n Actual: " + message.get()).c_str())
|
" throws an exception of type " #expected_exception \
|
||||||
|
".\n Actual: " + \
|
||||||
|
message.get()) \
|
||||||
|
.c_str())
|
||||||
|
|
||||||
#define GTEST_TEST_NO_THROW_(statement, fail) \
|
#define GTEST_TEST_NO_THROW_(statement, fail) \
|
||||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||||
if (::testing::internal::AdditionalMessage message = ".") { \
|
if (::testing::internal::AdditionalMessage message = ".") { \
|
||||||
try { \
|
try { \
|
||||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
||||||
} \
|
} catch (const std::exception& e) { \
|
||||||
catch (const std::exception& e) { \
|
message.set(std::string(": ") + e.what()); \
|
||||||
message.set(std::string(": ") + e.what()); \
|
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
|
||||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
|
} catch (...) { \
|
||||||
} \
|
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
|
||||||
catch (...) { \
|
} \
|
||||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
|
} else \
|
||||||
} \
|
GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__) \
|
||||||
} else \
|
: fail(("Expected: " #statement " doesn't throw an exception.\n" \
|
||||||
GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
|
" Actual: it throws" + \
|
||||||
fail(("Expected: " #statement " doesn't throw an exception.\n" \
|
message.get()) \
|
||||||
" Actual: it throws" + message.get()).c_str())
|
.c_str())
|
||||||
|
|
||||||
#define GTEST_TEST_ANY_THROW_(statement, fail) \
|
#define GTEST_TEST_ANY_THROW_(statement, fail) \
|
||||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||||
|
Loading…
Reference in New Issue
Block a user