diff --git a/io7m-jsycamore-core/src/main/java/com/io7m/jsycamore/core/components/SyErrors.java b/io7m-jsycamore-core/src/main/java/com/io7m/jsycamore/core/components/SyErrors.java index 0d63bf22..fdde9fde 100644 --- a/io7m-jsycamore-core/src/main/java/com/io7m/jsycamore/core/components/SyErrors.java +++ b/io7m-jsycamore-core/src/main/java/com/io7m/jsycamore/core/components/SyErrors.java @@ -17,6 +17,7 @@ package com.io7m.jsycamore.core.components; import com.io7m.jnull.NullCheck; +import com.io7m.junreachable.UnreachableCodeException; import org.slf4j.Logger; /** @@ -27,7 +28,7 @@ public final class SyErrors { private SyErrors() { - + throw new UnreachableCodeException(); } /** diff --git a/io7m-jsycamore-tests/src/test/java/com/io7m/jsycamore/tests/core/SyThemeTest.java b/io7m-jsycamore-tests/src/test/java/com/io7m/jsycamore/tests/core/SyThemeTest.java new file mode 100644 index 00000000..a9130668 --- /dev/null +++ b/io7m-jsycamore-tests/src/test/java/com/io7m/jsycamore/tests/core/SyThemeTest.java @@ -0,0 +1,60 @@ +/* + * Copyright © 2016 http://io7m.com + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package com.io7m.jsycamore.tests.core; + +import com.io7m.jsycamore.core.themes.SyTheme; +import com.io7m.jsycamore.core.themes.provided.SyThemeBee; +import com.io7m.jsycamore.core.themes.provided.SyThemeBeeSpecification; +import com.io7m.jsycamore.core.themes.provided.SyThemeMotive; +import com.io7m.jsycamore.core.themes.provided.SyThemeMotiveSpecification; +import com.io7m.jsycamore.core.themes.provided.SyThemeStride; +import com.io7m.jsycamore.core.themes.provided.SyThemeStrideSpecification; +import org.junit.Assert; +import org.junit.Test; + +public final class SyThemeTest +{ + @Test + public void testInstantiateMotive() + { + final SyTheme t = + SyThemeMotive.builder().build(); + final SyTheme u = + SyThemeMotive.builderFrom(SyThemeMotiveSpecification.builder().build()).build(); + Assert.assertEquals(t, u); + } + + @Test + public void testInstantiateStride() + { + final SyTheme t = + SyThemeStride.builder().build(); + final SyTheme u = + SyThemeStride.builderFrom(SyThemeStrideSpecification.builder().build()).build(); + Assert.assertEquals(t, u); + } + + @Test + public void testInstantiateBee() + { + final SyTheme t = + SyThemeBee.builder().build(); + final SyTheme u = + SyThemeBee.builderFrom(SyThemeBeeSpecification.builder().build()).build(); + Assert.assertEquals(t, u); + } +} diff --git a/io7m-jsycamore-tests/src/test/java/com/io7m/jsycamore/tests/core/SyUnreachableTest.java b/io7m-jsycamore-tests/src/test/java/com/io7m/jsycamore/tests/core/SyUnreachableTest.java new file mode 100644 index 00000000..9a69eaa9 --- /dev/null +++ b/io7m-jsycamore-tests/src/test/java/com/io7m/jsycamore/tests/core/SyUnreachableTest.java @@ -0,0 +1,90 @@ +/* + * Copyright © 2016 http://io7m.com + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package com.io7m.jsycamore.tests.core; + +import com.io7m.junreachable.UnreachableCodeException; +import org.junit.Test; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +public final class SyUnreachableTest +{ + private static void execNoArgPrivateConstructor(final String name) + throws + ClassNotFoundException, + InstantiationException, + IllegalAccessException + { + try { + final Class c = Class.forName(name); + final Constructor[] cons = c.getDeclaredConstructors(); + cons[0].setAccessible(true); + cons[0].newInstance(); + } catch (final InvocationTargetException e) { + throw (UnreachableCodeException) e.getCause(); + } + } + + @Test(expected = UnreachableCodeException.class) + public void testImageAWT() + throws Exception + { + SyUnreachableTest.execNoArgPrivateConstructor( + "com.io7m.jsycamore.core.images.SyImageAWT"); + } + + @Test(expected = UnreachableCodeException.class) + public void testThemeBee() + throws Exception + { + SyUnreachableTest.execNoArgPrivateConstructor( + "com.io7m.jsycamore.core.themes.provided.SyThemeBee"); + } + + @Test(expected = UnreachableCodeException.class) + public void testThemeMotive() + throws Exception + { + SyUnreachableTest.execNoArgPrivateConstructor( + "com.io7m.jsycamore.core.themes.provided.SyThemeMotive"); + } + + @Test(expected = UnreachableCodeException.class) + public void testThemeStride() + throws Exception + { + SyUnreachableTest.execNoArgPrivateConstructor( + "com.io7m.jsycamore.core.themes.provided.SyThemeStride"); + } + + @Test(expected = UnreachableCodeException.class) + public void testThemeDefault() + throws Exception + { + SyUnreachableTest.execNoArgPrivateConstructor( + "com.io7m.jsycamore.core.themes.provided.SyThemeDefault"); + } + + @Test(expected = UnreachableCodeException.class) + public void testErrors() + throws Exception + { + SyUnreachableTest.execNoArgPrivateConstructor( + "com.io7m.jsycamore.core.components.SyErrors"); + } +}