In it's Weekly Source Code, Scott Hanselman presents a new CodePlex project, NDepend.Helpers.FileDirectoryPath from Patrick Smacchia. Nice, better path handling should have been part of the BCL a while ago.
Path stuff is hard
Path normalization and parsing is not an easy task so when Patrick Smacchia mentions that his code "100% unit-tested", I decided to see if Pex could not find a little bug over there.
A dumb parameterized unit test
So I added wrote the following parameterized unit test, which 'simply' calls the constructor of FilePathRelative. Under the hood, there is some string manipulation done by the library to normalize the path, it should be interresting to see what comes out of this. I also added calls to PexComment.XXX to log the input/output values (Pex will build a table out of this):
[PexMethod]
public void FilePathRelativeCtor(string path) {
PexComment.Parameters(path);
FilePath result = new FilePathRelative(path);
PexComment.Value("result", result.FileName);
}
Ooops
So Pex starts running and soon enough an assert pops up. Pex had just found a neat little path that broke an assertion in the library:
[Test]
public void FilePathRelativeCtor_String_71019_003302_0_05() {
this.FilePathRelativeCtor("/");
}
Popping up the reports, I went for the parameter table (remember the PexComment calls) that shows one row for each generated test. In fact, the 5-th test that Pex generated was triggering the assert:

Note that "//" also triggers the bug which seems to indicate that any path finishing by "/" will have this behavior.
The path condition
Lastly, I took a quick look at the path condition that Pex solved to discover the bug (see red below). Luckily this one is fairly easy and one can clearly see 'path[0] == '/' in there.

What did we learn today?
Handling paths is hard :)
Also, we saw that a dumb parameterized unit test (just calling a ctor), could find a bugs. If you use assertions, it will help Pex look for bugs in your code.