@@ -31,30 +31,46 @@ public void optionalDefault() {
3131 check (ImmutableOptionalDefault .builder ().build ().text ()).is (Optional .of ("foo" ));
3232 check (ImmutableOptionalDefault .builder ().text (Optional .empty ()).build ().text ()).is (Optional .empty ());
3333 check (ImmutableOptionalDefault .builder ().text (Optional .of ("bar" )).build ().text ()).is (Optional .of ("bar" ));
34- check (ImmutableOptionalDefault .builder ().text ("bar" ).build ().text ()).is (Optional .of ("bar" ));
34+ ImmutableOptionalDefault value = ImmutableOptionalDefault .builder ().text ("bar" ).build ();
35+ check (value .text ()).is (Optional .of ("bar" ));
36+ check (value .withText ("blah" ).text ()).is (Optional .of ("blah" ));
37+ check (value .withText (Optional .of ("blah" )).text ()).is (Optional .of ("blah" ));
38+ check (value .withText (Optional .empty ()).text ()).is (Optional .empty ());
3539 }
3640
3741 @ Test
3842 public void optionalIntDefault () {
3943 check (ImmutableOptionalIntDefault .builder ().build ().magic ()).is (OptionalInt .of (42 ));
4044 check (ImmutableOptionalIntDefault .builder ().magic (OptionalInt .empty ()).build ().magic ()).is (OptionalInt .empty ());
4145 check (ImmutableOptionalIntDefault .builder ().magic (OptionalInt .of (17 )).build ().magic ()).is (OptionalInt .of (17 ));
42- check (ImmutableOptionalIntDefault .builder ().magic (17 ).build ().magic ()).is (OptionalInt .of (17 ));
46+ ImmutableOptionalIntDefault value = ImmutableOptionalIntDefault .builder ().magic (17 ).build ();
47+ check (value .magic ()).is (OptionalInt .of (17 ));
48+ check (value .withMagic (99 ).magic ()).is (OptionalInt .of (99 ));
49+ check (value .withMagic (OptionalInt .of (99 )).magic ()).is (OptionalInt .of (99 ));
50+ check (value .withMagic (OptionalInt .empty ()).magic ()).is (OptionalInt .empty ());
4351 }
4452
4553 @ Test
4654 public void optionalLongDefault () {
4755 check (ImmutableOptionalLongDefault .builder ().build ().magic ()).is (OptionalLong .of (42 ));
4856 check (ImmutableOptionalLongDefault .builder ().magic (OptionalLong .empty ()).build ().magic ()).is (OptionalLong .empty ());
4957 check (ImmutableOptionalLongDefault .builder ().magic (OptionalLong .of (17 )).build ().magic ()).is (OptionalLong .of (17 ));
50- check (ImmutableOptionalLongDefault .builder ().magic (17 ).build ().magic ()).is (OptionalLong .of (17 ));
58+ ImmutableOptionalLongDefault value = ImmutableOptionalLongDefault .builder ().magic (17 ).build ();
59+ check (value .magic ()).is (OptionalLong .of (17 ));
60+ check (value .withMagic (99 ).magic ()).is (OptionalLong .of (99 ));
61+ check (value .withMagic (OptionalLong .of (99 )).magic ()).is (OptionalLong .of (99 ));
62+ check (value .withMagic (OptionalLong .empty ()).magic ()).is (OptionalLong .empty ());
5163 }
5264
5365 @ Test
5466 public void optionalDoubleDefault () {
5567 check (ImmutableOptionalDoubleDefault .builder ().build ().magic ()).is (OptionalDouble .of (42 ));
5668 check (ImmutableOptionalDoubleDefault .builder ().magic (OptionalDouble .empty ()).build ().magic ()).is (OptionalDouble .empty ());
5769 check (ImmutableOptionalDoubleDefault .builder ().magic (OptionalDouble .of (17 )).build ().magic ()).is (OptionalDouble .of (17 ));
58- check (ImmutableOptionalDoubleDefault .builder ().magic (17 ).build ().magic ()).is (OptionalDouble .of (17 ));
70+ ImmutableOptionalDoubleDefault value = ImmutableOptionalDoubleDefault .builder ().magic (17 ).build ();
71+ check (value .magic ()).is (OptionalDouble .of (17 ));
72+ check (value .withMagic (99 ).magic ()).is (OptionalDouble .of (99 ));
73+ check (value .withMagic (OptionalDouble .of (99 )).magic ()).is (OptionalDouble .of (99 ));
74+ check (value .withMagic (OptionalDouble .empty ()).magic ()).is (OptionalDouble .empty ());
5975 }
6076}
0 commit comments