Home | History | Annotate | Download | only in gtest

Lines Matching defs:String

42 #include <string.h>
58 #include <string>
260 String g_executable_path;
279 String UnitTestOptions::GetOutputFormat() {
281 if (gtest_output_flag == NULL) return String("");
285 String(gtest_output_flag) :
286 String(gtest_output_flag, colon - gtest_output_flag);
291 String UnitTestOptions::GetOutputFile() {
294 return String("");
298 return String(kDefaultOutputFile);
310 // Returns true iff the wildcard pattern matches the string. The
323 case '*': // Matches any string (possibly empty) of characters.
332 bool UnitTestOptions::MatchesFilter(const String& name, const char* filter) {
352 // TODO(keithray): move String function implementations to gtest-string.cc.
356 bool UnitTestOptions::FilterMatchesTest(const String &test_case_name,
357 const String &test_name) {
358 const String& full_name = String::Format("%s.%s",
366 String positive;
367 String negative;
369 positive = GTEST_FLAG(filter).c_str(); // Whole string is a positive filter
370 negative = String("");
373 negative = String(dash+1); // Everything after the dash
515 const String expected(
629 // Returns the current OS stack trace as a String.
639 String UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {
641 return String("");
691 // class String
697 // This is useful for printing a C string in the syntax of a literal.
700 String String::ShowCStringQuoted(const char* c_str) {
701 return c_str ? String::Format("\"%s\"", c_str) : String("(null)");
728 // Clones a 0-terminated C string, allocating memory using new. The
730 // cloned string, or NULL if the input is NULL.
731 const char * String::CloneCString(const char* c_str) {
739 // C string is considered different to any non-NULL C string,
740 // including the empty string.
741 bool String::CStringEquals(const char * lhs, const char * rhs) {
751 // Converts an array of wide chars to a narrow string using the UTF-8
756 // TODO(wan): consider allowing a testing::String object to
757 // contain '\0'. This will make it behave more like std::string,
774 // Converts the given wide string to a narrow string using the UTF-8
783 // Converts the given wide string to a narrow string using the UTF-8
797 String FormatForFailureMessage(char ch) {
799 // A String object cannot contain '\0', so we print "\\0" when ch is
801 return String::Format("'%s' (%u, 0x%X)",
802 ch ? String::Format("%c", ch).c_str() : "\\0",
808 String FormatForFailureMessage(wchar_t wchar) {
821 // A String object cannot contain '\0', so we print "\\0" when wchar is
832 AssertionResult::AssertionResult(const internal::String& failure_message)
863 // *_STRCASEEQ*. When it's true, the string " (ignoring case)" will
867 const String& expected_value,
868 const String& actual_value,
1022 if (String::CStringEquals(expected, actual)) {
1028 String::ShowCStringQuoted(expected),
1029 String::ShowCStringQuoted(actual),
1038 if (String::CaseInsensitiveCStringEquals(expected, actual)) {
1044 String::ShowCStringQuoted(expected),
1045 String::ShowCStringQuoted(actual),
1054 if (!String::CStringEquals(s1, s2)) {
1070 if (!String::CaseInsensitiveCStringEquals(s1, s2)) {
1105 // StringType here can be either ::std::string or ::std::wstring.
1114 // StringType here can be const char*, const wchar_t*, ::std::string,
1168 const ::std::string& needle, const ::std::string& haystack) {
1174 const ::std::string& needle, const ::std::string& haystack) {
1212 const DWORD kBufSize = 4096; // String::Format can't exceed this length.
1213 // Gets the system's human readable message string for this HRESULT.
1229 const String error_hex(String::Format("0x%08X ", hr));
1289 String ToUtf8String(wchar_t wchar) {
1308 return String::Format("(Invalid Unicode 0x%llX)",
1312 return String(str);
1315 // Converts a wide C string to a String using the UTF-8 encoding.
1317 String String::ShowWideCString(const wchar_t * wide_c_str) {
1318 if (wide_c_str == NULL) return String("(null)");
1329 // the converted string in double quotes.
1330 String String::ShowWideCStringQuoted(const wchar_t* wide_c_str) {
1331 if (wide_c_str == NULL) return String("(null)");
1333 return String::Format("L\"%s\"",
1334 String::ShowWideCString(wide_c_str).c_str());
1341 // C string is considered different to any non-NULL C string,
1342 // including the empty string.
1343 bool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) {
1356 if (String::WideCStringEquals(expected, actual)) {
1362 String::ShowWideCStringQuoted(expected),
1363 String::ShowWideCStringQuoted(actual),
1372 if (!String::WideCStringEquals(s1, s2)) {
1379 << String::ShowWideCStringQuoted(s1)
1380 << " vs " << String::ShowWideCStringQuoted(s2);
1388 string is considered different to any non-NULL C string,
1389 // including the empty string.
1390 bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {
1402 // Constructs a String by copying a given number of chars from a
1403 // buffer. E.g. String("hello", 3) will create the string "hel".
1404 String::String(const char * buffer, size_t len) {
1411 // Compares this with another String.
1414 int String::Compare(const String & rhs) const {
1422 // Returns true iff this String ends with the given suffix. *Any*
1423 // String is considered to end with a NULL or empty suffix.
1424 bool String::EndsWith(const char* suffix) const {
1435 // Returns true iff this String ends with the given suffix, ignoring case.
1436 // Any String is considered to end with a NULL or empty suffix.
1437 bool String::EndsWithCaseInsensitive(const char* suffix) const {
1448 // Sets the 0-terminated C string this String object represents. The
1449 // old string in this object is deleted, and this object will own a
1450 // clone of the input string. This function copies only up to length
1456 void String::Set(const char * c_str, size_t length) {
1463 // Assigns a C string to this object. Self-assignment works.
1464 const String& String::operator=(const char* c_str) {
1473 // Formats a list of arguments to a String, using the same format
1474 // spec string as for printf.
1482 String String::Format(const char * format, ...) {
1501 return String(size >= 0 ? buffer : "<buffer exceeded>");
1504 // Converts the buffer in a StrStream to a String, converting NUL
1506 String StrStreamToString(StrStream* ss) {
1508 const ::std::string& str = ss->str();
1517 // because String doesn't support push_back().
1528 return String(helper.str().c_str());
1530 const String str(helper.str(), helper.pcount());
1538 String AppendUserMessage(const String& gtest_msg,
1541 const String user_msg_string = user_msg.GetString();
1603 String key(test_property.key());
1717 internal::String(""));
1932 return test_info && internal::String(test_info->name()).Compare(name_) == 0;
1936 internal::String name_;
2124 static internal::String FormatCountableNoun(int count,
2127 return internal::String::Format("%d %s", count,
2132 static internal::String FormatTestCount(int test_count) {
2137 static internal::String FormatTestCaseCount(int test_case_count) {
2141 // Converts a TestPartResultType enum to human-friendly string
2212 if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) {
2221 String::CStringEquals(term, "xterm") ||
2222 String::CStringEquals(term, "xterm-color") ||
2223 String::CStringEquals(term, "cygwin");
2228 return String::CaseInsensitiveCStringEquals(gtest_color, "yes") ||
2229 String::CaseInsensitiveCStringEquals(gtest_color, "true") ||
2230 String::CaseInsensitiveCStringEquals(gtest_color, "t") ||
2231 String::CStringEquals(gtest_color, "1");
2239 // This routine must actually emit the characters rather than return a string
2305 internal::String test_case_name_;
2315 if (!internal::String::CStringEquals(filter, kUniversalFilter)) {
2337 const internal::String counts =
2535 // Returns an XML-escaped copy of the input string str. If
2539 static internal::String EscapeXml(const char* str,
2543 static internal::String EscapeXmlAttribute(const char* str) {
2548 static internal::String EscapeXmlText(const char* str) {
2563 // Produces a string representing the test properties in a result as space
2565 // When the String is not empty, it includes a space at the beginning,
2567 static internal::String TestPropertiesAsXmlAttributes(
2571 const internal::String output_file_;
2626 // Returns an XML-escaped copy of the input string str. If is_attribute
2638 internal::String XmlUnitTestResultPrinter::EscapeXml(const char* str,
2669 m << internal::String::Format("&#x%02X;", unsigned(*src));
2719 const internal::String message =
2720 internal::String::Format("%s:%d\n%s", part.file_name(),
2780 // Produces a string representing the test properties in a result as space
2782 internal::String XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(
2825 // Returns the current OS stack trace as a String. Parameters:
2834 String OsStackTraceGetter::CurrentStackTrace(int, int) {
2835 return String("");
2901 const internal::String& message,
2902 const internal::String& os_stack_trace) {
3068 explicit TestCaseNameIs(const String& name)
3077 String name_;
3101 if (String(test_case_name).EndsWith("DeathTest")) {
3224 const String &test_case_name = test_case->name();
3232 const String test_name(test_info->name());
3306 const String& output_format = internal::UnitTestOptions::GetOutputFormat();
3358 test_case_name_(String(test_case_name)),
3359 name_(String(name)),
3374 // Parses a string as a command line flag. The string should have
3386 const String flag_str = String::Format("--%s%s", GTEST_FLAG_PREFIX, flag);
3403 // Returns the string after "=".
3407 // Parses a string for a bool flag, in the form of either
3418 // Gets the value of the flag as a string.
3424 // Converts the string value to a bool.
3429 // Parses a string for an Int32 flag, in the form of
3435 // Gets the value of the flag as a string.
3446 // Parses a string for a string flag, in the form of
3451 bool ParseStringFlag(const char* str, const char* flag, String* value) {
3452 // Gets the value of the flag as a string.
3480 const String arg_string = StreamableToString(argv[i]);