@Test
  public void testWriteFile_withStandardOptions() throws IOException {
    Path test = path("/test");
    byte[] bytes = {0, 1, 2, 3};

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

    Files.write(test, bytes, CREATE_NEW); // succeeds, file does not exist
    assertThatPath("/test").containsBytes(bytes);

    try {
      Files.write(test, bytes, CREATE_NEW); // CREATE_NEW requires file not exist
      fail();
    } catch (FileAlreadyExistsException expected) {
      assertEquals(test.toString(), expected.getMessage());
    }

    Files.write(test, new byte[] {4, 5}, CREATE); // succeeds, ok for file to already exist
    assertThatPath("/test").containsBytes(4, 5, 2, 3); // did not truncate or append, so overwrote

    Files.write(test, bytes, WRITE, CREATE, TRUNCATE_EXISTING); // default options
    assertThatPath("/test").containsBytes(bytes);

    Files.write(test, bytes, WRITE, APPEND);
    assertThatPath("/test").containsBytes(0, 1, 2, 3, 0, 1, 2, 3);

    Files.write(test, bytes, WRITE, CREATE, TRUNCATE_EXISTING, APPEND, SPARSE, DSYNC, SYNC);
    assertThatPath("/test").containsBytes(bytes);

    try {
      Files.write(test, bytes, 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