Increase test coverage.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 30 Jul 2014 12:59:34 +0000 (14:59 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 30 Jul 2014 12:59:34 +0000 (14:59 +0200)
src/test/java/net/pterodactylus/sone/core/DefaultOptionTest.java

index d7ca110..8a1f8d5 100644 (file)
@@ -103,4 +103,23 @@ public class DefaultOptionTest {
                assertThat(defaultOption.validate(new Object()), is(false));
        }
 
+       @Test
+       public void settingToNullWillRestoreDefaultValue() {
+               DefaultOption<Object> defaultOption = new DefaultOption<Object>(defaultValue);
+               defaultOption.set(null);
+               assertThat(defaultOption.get(), is(defaultValue));
+       }
+
+       @Test
+       public void validateWithoutValidatorWillValidateNull() {
+               DefaultOption<Object> defaultOption = new DefaultOption<Object>(defaultValue);
+               assertThat(defaultOption.validate(null), is(true));
+       }
+
+       @Test
+       public void validateWithValidatorWillValidateNull() {
+               DefaultOption<Object> defaultOption = new DefaultOption<Object>(defaultValue, matchesAcceptedValue);
+               assertThat(defaultOption.validate(null), is(true));
+       }
+
 }