tesseract v5.3.3.20231005
testing::internal::String Class Reference

#include <gtest-string.h>

Static Public Member Functions

static const char * CloneCString (const char *c_str)
 
static bool CStringEquals (const char *lhs, const char *rhs)
 
static std::string ShowWideCString (const wchar_t *wide_c_str)
 
static bool WideCStringEquals (const wchar_t *lhs, const wchar_t *rhs)
 
static bool CaseInsensitiveCStringEquals (const char *lhs, const char *rhs)
 
static bool CaseInsensitiveWideCStringEquals (const wchar_t *lhs, const wchar_t *rhs)
 
static bool EndsWithCaseInsensitive (const std::string &str, const std::string &suffix)
 
static std::string FormatIntWidth2 (int value)
 
static std::string FormatIntWidthN (int value, int width)
 
static std::string FormatHexInt (int value)
 
static std::string FormatHexUInt32 (uint32_t value)
 
static std::string FormatByte (unsigned char value)
 

Detailed Description

Definition at line 59 of file gtest-string.h.

Member Function Documentation

◆ CaseInsensitiveCStringEquals()

bool testing::internal::String::CaseInsensitiveCStringEquals ( const char *  lhs,
const char *  rhs 
)
static

Definition at line 2079 of file gtest.cc.

2079 {
2080 if (lhs == nullptr) return rhs == nullptr;
2081 if (rhs == nullptr) return false;
2082 return posix::StrCaseCmp(lhs, rhs) == 0;
2083}
int StrCaseCmp(const char *s1, const char *s2)
Definition: gtest-port.h:2043

◆ CaseInsensitiveWideCStringEquals()

bool testing::internal::String::CaseInsensitiveWideCStringEquals ( const wchar_t *  lhs,
const wchar_t *  rhs 
)
static

Definition at line 2097 of file gtest.cc.

2098 {
2099 if (lhs == nullptr) return rhs == nullptr;
2100
2101 if (rhs == nullptr) return false;
2102
2103#if GTEST_OS_WINDOWS
2104 return _wcsicmp(lhs, rhs) == 0;
2105#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID
2106 return wcscasecmp(lhs, rhs) == 0;
2107#else
2108 // Android, Mac OS X and Cygwin don't define wcscasecmp.
2109 // Other unknown OSes may not define it either.
2110 wint_t left, right;
2111 do {
2112 left = towlower(static_cast<wint_t>(*lhs++));
2113 right = towlower(static_cast<wint_t>(*rhs++));
2114 } while (left && left == right);
2115 return left == right;
2116#endif // OS selector
2117}

◆ CloneCString()

static const char * testing::internal::String::CloneCString ( const char *  c_str)
static

◆ CStringEquals()

bool testing::internal::String::CStringEquals ( const char *  lhs,
const char *  rhs 
)
static

Definition at line 1104 of file gtest.cc.

1104 {
1105 if (lhs == nullptr) return rhs == nullptr;
1106
1107 if (rhs == nullptr) return false;
1108
1109 return strcmp(lhs, rhs) == 0;
1110}

◆ EndsWithCaseInsensitive()

bool testing::internal::String::EndsWithCaseInsensitive ( const std::string &  str,
const std::string &  suffix 
)
static

Definition at line 2121 of file gtest.cc.

2122 {
2123 const size_t str_len = str.length();
2124 const size_t suffix_len = suffix.length();
2125 return (str_len >= suffix_len) &&
2126 CaseInsensitiveCStringEquals(str.c_str() + str_len - suffix_len,
2127 suffix.c_str());
2128}
static bool CaseInsensitiveCStringEquals(const char *lhs, const char *rhs)
Definition: gtest.cc:2079

◆ FormatByte()

std::string testing::internal::String::FormatByte ( unsigned char  value)
static

Definition at line 2155 of file gtest.cc.

2155 {
2156 std::stringstream ss;
2157 ss << std::setfill('0') << std::setw(2) << std::hex << std::uppercase
2158 << static_cast<unsigned int>(value);
2159 return ss.str();
2160}
int value

◆ FormatHexInt()

std::string testing::internal::String::FormatHexInt ( int  value)
static

Definition at line 2150 of file gtest.cc.

2150 {
2151 return FormatHexUInt32(static_cast<uint32_t>(value));
2152}
static std::string FormatHexUInt32(uint32_t value)
Definition: gtest.cc:2143

◆ FormatHexUInt32()

std::string testing::internal::String::FormatHexUInt32 ( uint32_t  value)
static

Definition at line 2143 of file gtest.cc.

2143 {
2144 std::stringstream ss;
2145 ss << std::hex << std::uppercase << value;
2146 return ss.str();
2147}

◆ FormatIntWidth2()

std::string testing::internal::String::FormatIntWidth2 ( int  value)
static

Definition at line 2131 of file gtest.cc.

2131 {
2132 return FormatIntWidthN(value, 2);
2133}
static std::string FormatIntWidthN(int value, int width)
Definition: gtest.cc:2136

◆ FormatIntWidthN()

std::string testing::internal::String::FormatIntWidthN ( int  value,
int  width 
)
static

Definition at line 2136 of file gtest.cc.

2136 {
2137 std::stringstream ss;
2138 ss << std::setfill('0') << std::setw(width) << value;
2139 return ss.str();
2140}

◆ ShowWideCString()

std::string testing::internal::String::ShowWideCString ( const wchar_t *  wide_c_str)
static

Definition at line 2022 of file gtest.cc.

2022 {
2023 if (wide_c_str == nullptr) return "(null)";
2024
2025 return internal::WideStringToUtf8(wide_c_str, -1);
2026}
std::string WideStringToUtf8(const wchar_t *str, int num_chars)
Definition: gtest.cc:1997

◆ WideCStringEquals()

bool testing::internal::String::WideCStringEquals ( const wchar_t *  lhs,
const wchar_t *  rhs 
)
static

Definition at line 2034 of file gtest.cc.

2034 {
2035 if (lhs == nullptr) return rhs == nullptr;
2036
2037 if (rhs == nullptr) return false;
2038
2039 return wcscmp(lhs, rhs) == 0;
2040}

The documentation for this class was generated from the following files: