36#include "gmock/internal/gmock-internal-utils.h"
48#include "gmock/gmock.h"
49#include "gmock/internal/gmock-port.h"
50#include "gtest/gtest.h"
57GTEST_API_ std::string JoinAsKeyValueTuple(
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);
79GTEST_API_ std::string ConvertIdentifierNameToWords(
const char* id_name) {
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);
102 void ReportFailure(FailureType type,
const char* file,
int line,
103 const std::string& message)
override {
104 AssertHelper(type == kFatal ? TestPartResult::kFatalFailure
105 : TestPartResult::kNonFatalFailure,
106 file, line, message.c_str()) =
Message();
107 if (type == kFatal) {
123 return failure_reporter;
127static GTEST_DEFINE_STATIC_MUTEX_(g_log_mutex);
131GTEST_API_
bool LogIsVisible(LogSeverity severity) {
132 if (GMOCK_FLAG_GET(verbose) == kInfoVerbosity) {
135 }
else if (GMOCK_FLAG_GET(verbose) == kErrorVerbosity) {
141 return severity == kWarning;
152GTEST_API_
void Log(LogSeverity severity,
const std::string& message,
153 int stack_frames_to_skip) {
154 if (!LogIsVisible(severity))
return;
157 MutexLock l(&g_log_mutex);
159 if (severity == kWarning) {
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"
183 << ::testing::internal::GetCurrentOsStackTraceExceptTop(
186 std::cout << ::std::flush;
189GTEST_API_ WithoutMatchers GetWithoutMatchers() {
return WithoutMatchers(); }
191GTEST_API_
void IllegalDoDefault(
const char* file,
int line) {
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)
205 : UnBase64Impl(c, base64 + 1, static_cast<char>(carry + 1));
208template <
size_t... I>
209constexpr std::array<char, 256> UnBase64Impl(IndexSequence<I...>,
210 const char*
const base64) {
211 return {{UnBase64Impl(
static_cast<char>(I), base64, 0)...}};
214constexpr std::array<char, 256> UnBase64(
const char*
const base64) {
215 return UnBase64Impl(MakeIndexSequence<256>{}, base64);
218static constexpr char kBase64[] =
219 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
220static constexpr std::array<char, 256> kUnBase64 = UnBase64(kBase64);
222bool Base64Unescape(
const std::string& encoded, std::string* decoded) {
224 size_t encoded_len = encoded.size();
225 decoded->reserve(3 * (encoded_len / 4) + (encoded_len % 4));
228 for (
int src : encoded) {
229 if (std::isspace(src) || src ==
'=') {
232 char src_bin = kUnBase64[
static_cast<size_t>(src)];
238 dst |=
static_cast<char>(src_bin << 2);
241 dst |=
static_cast<char>(src_bin >> (bit_pos - 2));
242 decoded->push_back(dst);
243 dst =
static_cast<char>(src_bin << (10 - bit_pos));
244 bit_pos = (bit_pos + 6) % 8;
Definition gtest-message.h:92
Definition gmock-internal-utils.h:208
Definition gmock-internal-utils.cc:100