Esempio n. 1
0
 @Test
 public void toString_A$() throws Exception {
   Either<String, Integer> target = Left.apply("foo");
   String actual = target.toString();
   String expected = "Left(foo)";
   assertThat(actual, is(equalTo(expected)));
 }
Esempio n. 2
0
 @Test
 public void right_A$() throws Exception {
   Either<String, Integer> target = Left.apply("foo");
   Option<Integer> actual = target.right();
   assertThat(actual.isDefined(), is(false));
   assertThat(actual.getOrNull(), is(nullValue()));
 }
Esempio n. 3
0
 @Test
 public void left_A$() throws Exception {
   Either<String, Integer> target = Left.apply("foo");
   Option<String> actual = target.left();
   assertThat(actual.isDefined(), is(true));
   assertThat(actual.getOrNull(), is(equalTo("foo")));
 }
Esempio n. 4
0
 @Test
 public void isRight_A$() throws Exception {
   Either<String, Integer> target = Left.apply("foo");
   boolean actual = target.isRight();
   boolean expected = false;
   assertThat(actual, is(equalTo(expected)));
 }
Esempio n. 5
0
 @Test
 public void swap_A$() throws Exception {
   Either<String, Integer> target = Left.apply("foo");
   Either<Integer, String> swapped = target.swap();
   Option<String> right = swapped.right();
   assertThat(right.isDefined(), is(true));
   assertThat(right.getOrNull(), is(equalTo("foo")));
 }
Esempio n. 6
0
 @Test
 public void mergeToLeft_A$Function1() throws Exception {
   String value = "xxx";
   Either<String, Integer> target = Left.apply(value);
   Function1<Integer, String> rightToLeft =
       new F1<Integer, String>() {
         public String apply(Integer v) {
           return v.toString();
         }
       };
   String actual = target.mergeToLeft(rightToLeft);
   String expected = "xxx";
   assertThat(actual, is(equalTo(expected)));
 }
Esempio n. 7
0
 @Test
 public void mergeToRight_A$Function1() throws Exception {
   String value = "xxx";
   Either<String, Integer> target = Left.apply(value);
   Function1<String, Integer> leftToRight =
       new F1<String, Integer>() {
         public Integer apply(String v) throws Exception {
           return v.length();
         }
       };
   Integer actual = target.mergeToRight(leftToRight);
   Integer expected = 3;
   assertThat(actual, is(equalTo(expected)));
 }