50#include "gtest/gtest.h"
58 const std::vector<const char*>& names,
const Strings& values) {
59 GTEST_CHECK_(names.size() == values.size());
63 const auto build_one = [&](
const size_t i) {
64 return std::string(names[i]) +
": " + values[i];
66 std::string result =
"(" + build_one(0);
67 for (
size_t i = 1; i < values.size(); i++) {
69 result += build_one(i);
81 char prev_char =
'\0';
82 for (
const char* p = id_name; *p !=
'\0'; prev_char = *(p++)) {
85 const bool starts_new_word = IsUpper(*p) ||
86 (!IsAlpha(prev_char) && IsLower(*p)) ||
87 (!IsDigit(prev_char) && IsDigit(*p));
90 if (starts_new_word && result !=
"") result +=
' ';
91 result += ToLower(*p);
103 const std::string& message)
override {
104 AssertHelper(type ==
kFatal ? TestPartResult::kFatalFailure
105 : TestPartResult::kNonFatalFailure,
106 file, line, message.c_str()) = Message();
123 return failure_reporter;
153 int stack_frames_to_skip) {
157 MutexLock l(&g_log_mutex);
161 std::cout <<
"\nGMOCK WARNING:";
164 if (message.empty() || message[0] !=
'\n') {
167 std::cout << message;
168 if (stack_frames_to_skip >= 0) {
171 const int actual_to_skip = 0;
175 const int actual_to_skip = stack_frames_to_skip + 1;
179 if (!message.empty() && *message.rbegin() !=
'\n') {
182 std::cout <<
"Stack trace:\n"
184 ::testing::UnitTest::GetInstance(), actual_to_skip);
186 std::cout << ::std::flush;
194 "You are using DoDefault() inside a composite action like "
195 "DoAll() or WithArgs(). This is not supported for technical "
196 "reasons. Please instead spell out the default action, or "
197 "assign the default action to an Action variable and use "
198 "the variable in various places.");
201constexpr char UnBase64Impl(
char c,
const char*
const base64,
char carry) {
202 return *base64 == 0 ?
static_cast<char>(65)
203 : *base64 == c ? carry
201constexpr char UnBase64Impl(
char c,
const char*
const base64,
char carry) {
…}
207template <
size_t... I>
209 const char*
const base64) {
210 return {{
UnBase64Impl(
static_cast<char>(I), base64, 0)...}};
213constexpr std::array<char, 256>
UnBase64(
const char*
const base64) {
213constexpr std::array<char, 256>
UnBase64(
const char*
const base64) {
…}
218 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
223 size_t encoded_len = encoded.size();
224 decoded->reserve(3 * (encoded_len / 4) + (encoded_len % 4));
227 for (
int src : encoded) {
228 if (std::isspace(src) || src ==
'=') {
231 char src_bin =
kUnBase64[
static_cast<size_t>(src)];
237 dst |=
static_cast<char>(src_bin << 2);
240 dst |=
static_cast<char>(src_bin >> (bit_pos - 2));
241 decoded->push_back(dst);
242 dst =
static_cast<char>(src_bin << (10 - bit_pos));
243 bit_pos = (bit_pos + 6) % 8;
void ReportFailure(FailureType type, const char *file, int line, const std::string &message) override
#define GMOCK_FLAG_GET(name)
GTEST_API_ std::string ConvertIdentifierNameToWords(const char *id_name)
const char kErrorVerbosity[]
static GTEST_DEFINE_STATIC_MUTEX_(g_log_mutex)
GTEST_API_ bool LogIsVisible(LogSeverity severity)
static constexpr char kBase64[]
static constexpr std::array< char, 256 > kUnBase64
bool Base64Unescape(const std::string &encoded, std::string *decoded)
GTEST_API_ void Log(LogSeverity severity, const std::string &message, int stack_frames_to_skip)
GTEST_API_ FailureReporterInterface * GetFailureReporter()
const char kInfoVerbosity[]
void Assert(bool condition, const char *file, int line, const std::string &msg)
GTEST_API_ void IllegalDoDefault(const char *file, int line)
constexpr std::array< char, 256 > UnBase64(const char *const base64)
GTEST_API_ std::string JoinAsKeyValueTuple(const std::vector< const char * > &names, const Strings &values)
GTEST_API_ WithoutMatchers GetWithoutMatchers()
constexpr char UnBase64Impl(char c, const char *const base64, char carry)
GTEST_NO_INLINE_ GTEST_NO_TAIL_CALL_ std::string GetCurrentOsStackTraceExceptTop(UnitTest *, int skip_count)