### Question:
WindowsPathType extends PathType { @Override public ParseResult parsePath(String path) { String original = path; path = path.replace('/', '\\'); if (WORKING_DIR_WITH_DRIVE.matcher(path).matches()) { throw new InvalidPathException( original, "Jimfs does not currently support the Windows syntax for a relative path " + "on a specific drive (e.g. \"C:foo\\bar\")"); } String root; if (path.startsWith("\\\\")) { root = parseUncRoot(path, original); } else if (path.startsWith("\\")) { throw new InvalidPathException( original, "Jimfs does not currently support the Windows syntax for an absolute path " + "on the current drive (e.g. \"\\foo\\bar\")"); } else { root = parseDriveRoot(path); } int startIndex = root == null || root.length() > 3 ? 0 : root.length(); for (int i = startIndex; i < path.length(); i++) { char c = path.charAt(i); if (isReserved(c)) { throw new InvalidPathException(original, "Illegal char <" + c + ">", i); } } Matcher trailingSpaceMatcher = TRAILING_SPACES.matcher(path); if (trailingSpaceMatcher.find()) { throw new InvalidPathException(original, "Trailing char < >", trailingSpaceMatcher.start()); } if (root != null) { path = path.substring(root.length()); if (!root.endsWith("\\")) { root = root + "\\"; } } return new ParseResult(root, splitter().split(path)); } private  WindowsPathType(); @Override ParseResult parsePath(String path); @Override String toString(@NullableDecl String root, Iterable<String> names); @Override String toUriPath(String root, Iterable<String> names, boolean directory); @Override ParseResult parseUriPath(String uriPath);  }### Answer:
@Test public void testWindows_relativePathsWithDriveRoot_unsupported() { try { windows().parsePath("C:"); fail(); } catch (InvalidPathException expected) { } try { windows().parsePath("C:foo\\bar"); fail(); } catch (InvalidPathException expected) { } }
@Test public void testWindows_absolutePathOnCurrentDrive_unsupported() { try { windows().parsePath("\\foo\\bar"); fail(); } catch (InvalidPathException expected) { } try { windows().parsePath("\\"); fail(); } catch (InvalidPathException expected) { } }
@Test public void testWindows_uncPaths() { PathType windows = PathType.windows(); PathType.ParseResult path = windows.parsePath("\\\\host\\share"); assertParseResult(path, "\\\\host\\share\\"); path = windows.parsePath("\\\\HOST\\share\\foo\\bar"); assertParseResult(path, "\\\\HOST\\share\\", "foo", "bar"); try { windows.parsePath("\\\\"); fail(); } catch (InvalidPathException expected) { assertThat(expected.getInput()).isEqualTo("\\\\"); assertThat(expected.getReason()).isEqualTo("UNC path is missing hostname"); } try { windows.parsePath("\\\\host"); fail(); } catch (InvalidPathException expected) { assertThat(expected.getInput()).isEqualTo("\\\\host"); assertThat(expected.getReason()).isEqualTo("UNC path is missing sharename"); } try { windows.parsePath("\\\\host\\"); fail(); } catch (InvalidPathException expected) { assertThat(expected.getInput()).isEqualTo("\\\\host\\"); assertThat(expected.getReason()).isEqualTo("UNC path is missing sharename"); } try { windows.parsePath(" fail(); } catch (InvalidPathException expected) { assertThat(expected.getInput()).isEqualTo(" assertThat(expected.getReason()).isEqualTo("UNC path is missing sharename"); } }
@Test public void testWindows_illegalNames() { try { windows().parsePath("foo<bar"); fail(); } catch (InvalidPathException expected) { } try { windows().parsePath("foo?"); fail(); } catch (InvalidPathException expected) { } try { windows().parsePath("foo "); fail(); } catch (InvalidPathException expected) { } try { windows().parsePath("foo \\bar"); fail(); } catch (InvalidPathException expected) { } }