@Test
  public void testWriteLines_withStandardOptions() throws IOException {
    Path test = path("/test.txt");
    ImmutableList<String> lines = ImmutableList.of("hello", "world");

    try {
      // CREATE and CREATE_NEW not specified
      Files.write(test, lines, UTF_8, WRITE);
      fail();
    } catch (NoSuchFileException expected) {
      assertEquals(test.toString(), expected.getMessage());
    }

    Files.write(test, lines, UTF_8, CREATE_NEW); // succeeds, file does not exist
    assertThatPath(test).containsLines(lines);

    try {
      Files.write(test, lines, UTF_8, CREATE_NEW); // CREATE_NEW requires file not exist
      fail();
    } catch (FileAlreadyExistsException expected) {
    }

    // succeeds, ok for file to already exist
    Files.write(test, ImmutableList.of("foo"), UTF_8, CREATE);
    // did not truncate or append, so overwrote
    if (System.getProperty("line.separator").length() == 2) {
      // on Windows, an extra character is overwritten by the \r\n line separator
      assertThatPath(test).containsLines("foo", "", "world");
    } else {
      assertThatPath(test).containsLines("foo", "o", "world");
    }

    Files.write(test, lines, UTF_8, WRITE, CREATE, TRUNCATE_EXISTING); // default options
    assertThatPath(test).containsLines(lines);

    Files.write(test, lines, UTF_8, WRITE, APPEND);
    assertThatPath(test).containsLines("hello", "world", "hello", "world");

    Files.write(test, lines, UTF_8, WRITE, CREATE, TRUNCATE_EXISTING, APPEND, SPARSE, DSYNC, SYNC);
    assertThatPath(test).containsLines(lines);

    try {
      Files.write(test, lines, UTF_8, READ, WRITE); // READ not allowed
      fail();
    } catch (UnsupportedOperationException expected) {
    }
  }
");
    assertThatPath("foo/bar").doesNotMatch("glob:/**");
    assertThatPath("/foo/bar/baz/stuff").matches("glob:/foo/**");
    assertThatPath("/foo/bar/baz/stuff").matches("glob:/*
jimfs/src/test/java/com/google/common/jimfs/JimfsUnixLikeFileSystemTest.java