Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
testing::internal::UnitTestOptions Class Reference

#include <gtest-internal-inl.h>

Static Public Member Functions

static std::string GetOutputFormat ()
 
static std::string GetAbsolutePathToOutputFile ()
 
static bool PatternMatchesString (const char *pattern, const char *str)
 
static bool FilterMatchesTest (const std::string &test_case_name, const std::string &test_name)
 
static bool MatchesFilter (const std::string &name, const char *filter)
 

Detailed Description

Definition at line 369 of file gtest-internal-inl.h.

Member Function Documentation

◆ FilterMatchesTest()

bool testing::internal::UnitTestOptions::FilterMatchesTest ( const std::string & test_case_name,
const std::string & test_name )
static

Definition at line 519 of file gtest.cc.

520 {
521 const std::string& full_name = test_case_name + "." + test_name.c_str();
522
523 // Split --gtest_filter at '-', if there is one, to separate into
524 // positive filter and negative filter portions
525 const char* const p = GTEST_FLAG(filter).c_str();
526 const char* const dash = strchr(p, '-');
527 std::string positive;
528 std::string negative;
529 if (dash == NULL) {
530 positive = GTEST_FLAG(filter).c_str(); // Whole string is a positive filter
531 negative = "";
532 } else {
533 positive = std::string(p, dash); // Everything up to the dash
534 negative = std::string(dash + 1); // Everything after the dash
535 if (positive.empty()) {
536 // Treat '-test1' as the same as '*-test1'
537 positive = kUniversalFilter;
538 }
539 }
540
541 // A filter is a colon-separated list of patterns. It matches a
542 // test if any pattern in it matches the test.
543 return (MatchesFilter(full_name, positive.c_str()) &&
544 !MatchesFilter(full_name, negative.c_str()));
545}
const mie::Vuint & p
Definition bn.cpp:27
static bool MatchesFilter(const std::string &name, const char *filter)
Definition gtest.cc:496
#define GTEST_FLAG(name)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAbsolutePathToOutputFile()

std::string testing::internal::UnitTestOptions::GetAbsolutePathToOutputFile ( )
static

Definition at line 438 of file gtest.cc.

438 {
439 const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
440 if (gtest_output_flag == NULL)
441 return "";
442
443 std::string format = GetOutputFormat();
444 if (format.empty())
445 format = std::string(kDefaultOutputFormat);
446
447 const char* const colon = strchr(gtest_output_flag, ':');
448 if (colon == NULL)
450 internal::FilePath(
451 UnitTest::GetInstance()->original_working_dir()),
452 internal::FilePath(kDefaultOutputFile), 0,
453 format.c_str()).string();
454
455 internal::FilePath output_name(colon + 1);
456 if (!output_name.IsAbsolutePath())
457 // TODO(wan@google.com): on Windows \some\path is not an absolute
458 // path (as its meaning depends on the current drive), yet the
459 // following logic for turning it into an absolute path is wrong.
460 // Fix it.
462 internal::FilePath(UnitTest::GetInstance()->original_working_dir()),
463 internal::FilePath(colon + 1));
464
465 if (!output_name.IsDirectory())
466 return output_name.string();
467
468 internal::FilePath result(internal::FilePath::GenerateUniqueFileName(
470 GetOutputFormat().c_str()));
471 return result.string();
472}
static UnitTest * GetInstance()
Definition gtest.cc:4374
static FilePath GenerateUniqueFileName(const FilePath &directory, const FilePath &base_name, const char *extension)
const std::string & string() const
static FilePath MakeFileName(const FilePath &directory, const FilePath &base_name, int number, const char *extension)
static FilePath ConcatPaths(const FilePath &directory, const FilePath &relative_path)
static std::string GetOutputFormat()
Definition gtest.cc:426
void output_name(std::ostream &s, const string_view &str, bool shorten, size_t max_length=64)
GTEST_API_ FilePath GetCurrentExecutableName()
Definition gtest.cc:411
cmd_format format
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetOutputFormat()

std::string testing::internal::UnitTestOptions::GetOutputFormat ( )
static

Definition at line 426 of file gtest.cc.

426 {
427 const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
428 if (gtest_output_flag == NULL) return std::string("");
429
430 const char* const colon = strchr(gtest_output_flag, ':');
431 return (colon == NULL) ?
432 std::string(gtest_output_flag) :
433 std::string(gtest_output_flag, colon - gtest_output_flag);
434}
Definition name.hpp:106
Here is the caller graph for this function:

◆ MatchesFilter()

bool testing::internal::UnitTestOptions::MatchesFilter ( const std::string & name,
const char * filter )
static

Definition at line 496 of file gtest.cc.

497 {
498 const char *cur_pattern = filter;
499 for (;;) {
500 if (PatternMatchesString(cur_pattern, name.c_str())) {
501 return true;
502 }
503
504 // Finds the next pattern in the filter.
505 cur_pattern = strchr(cur_pattern, ':');
506
507 // Returns if no more pattern can be found.
508 if (cur_pattern == NULL) {
509 return false;
510 }
511
512 // Skips the pattern separater (the ':' character).
513 cur_pattern++;
514 }
515}
std::string name
static bool PatternMatchesString(const char *pattern, const char *str)
Definition gtest.cc:479
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PatternMatchesString()

bool testing::internal::UnitTestOptions::PatternMatchesString ( const char * pattern,
const char * str )
static

Definition at line 479 of file gtest.cc.

480 {
481 switch (*pattern) {
482 case '\0':
483 case ':': // Either ':' or '\0' marks the end of the pattern.
484 return *str == '\0';
485 case '?': // Matches any single character.
486 return *str != '\0' && PatternMatchesString(pattern + 1, str + 1);
487 case '*': // Matches any string (possibly empty) of characters.
488 return (*str != '\0' && PatternMatchesString(pattern, str + 1)) ||
489 PatternMatchesString(pattern + 1, str);
490 default: // Non-special character. Matches itself.
491 return *pattern == *str &&
492 PatternMatchesString(pattern + 1, str + 1);
493 }
494}
return str
Definition CLI11.hpp:1359
Here is the call graph for this function:
Here is the caller graph for this function:

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