// Copyright 2007, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Google Mock - a framework for writing C++ mock classes. // // This file defines some utilities useful for implementing Google // Mock. They are subject to change without notice, so please DO NOT // USE THEM IN USER CODE. #include "gmock/internal/gmock-internal-utils.h" #include <ctype.h> #include <array> #include <cctype> #include <cstdint> #include <cstring> #include <iostream> #include <ostream> // NOLINT #include <string> #include <vector> #include "gmock/gmock.h" #include "gmock/internal/gmock-port.h" #include "gtest/gtest.h" namespace testing { namespace internal { // Joins a vector of strings as if they are fields of a tuple; returns // the joined string. GTEST_API_ std::string JoinAsKeyValueTuple( const std::vector<const char*>& names, const Strings& values) { … } // Converts an identifier name to a space-separated list of lower-case // words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is // treated as one word. For example, both "FooBar123" and // "foo_bar_123" are converted to "foo bar 123". GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name) { … } // This class reports Google Mock failures as Google Test failures. A // user can define another class in a similar fashion if they intend to // use Google Mock with a testing framework other than Google Test. class GoogleTestFailureReporter : public FailureReporterInterface { … }; // Returns the global failure reporter. Will create a // GoogleTestFailureReporter and return it the first time called. GTEST_API_ FailureReporterInterface* GetFailureReporter() { … } // Protects global resources (stdout in particular) used by Log(). static GTEST_DEFINE_STATIC_MUTEX_(g_log_mutex); // Returns true if and only if a log with the given severity is visible // according to the --gmock_verbose flag. GTEST_API_ bool LogIsVisible(LogSeverity severity) { … } // Prints the given message to stdout if and only if 'severity' >= the level // specified by the --gmock_verbose flag. If stack_frames_to_skip >= // 0, also prints the stack trace excluding the top // stack_frames_to_skip frames. In opt mode, any positive // stack_frames_to_skip is treated as 0, since we don't know which // function calls will be inlined by the compiler and need to be // conservative. GTEST_API_ void Log(LogSeverity severity, const std::string& message, int stack_frames_to_skip) { … } GTEST_API_ WithoutMatchers GetWithoutMatchers() { … } GTEST_API_ void IllegalDoDefault(const char* file, int line) { … } constexpr char UndoWebSafeEncoding(char c) { … } constexpr char UnBase64Impl(char c, const char* const base64, char carry) { … } template <size_t... I> constexpr std::array<char, 256> UnBase64Impl(IndexSequence<I...>, const char* const base64) { … } constexpr std::array<char, 256> UnBase64(const char* const base64) { … } static constexpr char kBase64[] = …; static constexpr std::array<char, 256> kUnBase64 = …; bool Base64Unescape(const std::string& encoded, std::string* decoded) { … } } // namespace internal } // namespace testing