google / googletest

GoogleTest - Google Testing and Mocking Framework

Home Page:https://google.github.io/googletest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Function `IsEmpty()` doesn't take white-spaces into account.

joshiayush opened this issue · comments

Describe the bug

The current version of IsEmpty() method in FilePath API returns false for white spaces when it should return true.

Steps to reproduce the bug

Just try to add the following test in googletest-filepath-test.cc, you will see it breaking.

TEST(IsEmptyTest, ReturnsTrueForEmptyPath) {
  EXPECT_TRUE(FilePath(" ").IsEmpty());
}

Solution

A solution could be just to trim the pathname_ when IsEmpty() function is called.

Does the bug persist in the most recent commit?

Yes

What operating system and version are you using?

Ubuntu 20.04.4 LTS

What compiler and version are you using?

gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)

What build system are you using?

cmake version 3.22.1

Whitespaces in unix path names are meaningful. We believe the current behavior is WAI.