-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
152 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
io7m-jsycamore-tests/src/test/java/com/io7m/jsycamore/tests/core/SyThemeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright © 2016 <[email protected]> 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); | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
io7m-jsycamore-tests/src/test/java/com/io7m/jsycamore/tests/core/SyUnreachableTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright © 2016 <[email protected]> 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"); | ||
} | ||
} |