Example
test dirnameWindows {
try testDirnameWindows("c:\\", null);
try testDirnameWindows("c:\\foo", "c:\\");
try testDirnameWindows("c:\\foo\\", "c:\\");
try testDirnameWindows("c:\\foo\\bar", "c:\\foo");
try testDirnameWindows("c:\\foo\\bar\\", "c:\\foo");
try testDirnameWindows("c:\\foo\\bar\\baz", "c:\\foo\\bar");
try testDirnameWindows("\\", null);
try testDirnameWindows("\\foo", "\\");
try testDirnameWindows("\\foo\\", "\\");
try testDirnameWindows("\\foo\\bar", "\\foo");
try testDirnameWindows("\\foo\\bar\\", "\\foo");
try testDirnameWindows("\\foo\\bar\\baz", "\\foo\\bar");
try testDirnameWindows("c:", null);
try testDirnameWindows("c:foo", null);
try testDirnameWindows("c:foo\\", null);
try testDirnameWindows("c:foo\\bar", "c:foo");
try testDirnameWindows("c:foo\\bar\\", "c:foo");
try testDirnameWindows("c:foo\\bar\\baz", "c:foo\\bar");
try testDirnameWindows("file:stream", null);
try testDirnameWindows("dir\\file:stream", "dir");
try testDirnameWindows("\\\\unc\\share", null);
try testDirnameWindows("\\\\unc\\share\\foo", "\\\\unc\\share\\");
try testDirnameWindows("\\\\unc\\share\\foo\\", "\\\\unc\\share\\");
try testDirnameWindows("\\\\unc\\share\\foo\\bar", "\\\\unc\\share\\foo");
try testDirnameWindows("\\\\unc\\share\\foo\\bar\\", "\\\\unc\\share\\foo");
try testDirnameWindows("\\\\unc\\share\\foo\\bar\\baz", "\\\\unc\\share\\foo\\bar");
try testDirnameWindows("/a/b/", "/a");
try testDirnameWindows("/a/b", "/a");
try testDirnameWindows("/a", "/");
try testDirnameWindows("", null);
try testDirnameWindows("/", null);
try testDirnameWindows("////", null);
try testDirnameWindows("foo", null);
}