@Test
public void testOption() {

  Option<String> s = some("test");
  Option<String> n = none();
  assertTrue(s.isSome());
  assertTrue(n.isNone());
  assertEquals("a test", s.fold(new Match<String, String>() {
    public String some(String s) {
      return "a " + s;
    }
    public String none() {
      return "";
    }
  }));
  assertEquals("none", n.fold(new Match<String, String>() {
    public String some(String s) {
      return s;
    }
    public String none() {
      return "none";
    }
  }));
  for (String x : n) {
    fail("should not happen");
  }
  String r = null;
  for (String x : s) {
    r = x;
  }
  assertEquals("test", r);
  assertEquals("test", s.getOrElse(""));
  assertEquals("", n.getOrElse(""));
  Function<String, Integer> len = new Function<String, Integer>() {
    @Override
    public Integer apply(String s) {
      return s.length();
    }
  };
  assertTrue(s.map(len).getOrElse(-1) == 4);
  assertTrue(n.map(len).getOrElse(-1) == -1);
}