Skip to content

Commit

Permalink
Add low hanging fruit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Jul 13, 2016
1 parent cf6e76d commit fa056e5
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.io7m.jsycamore.core.components;

import com.io7m.jnull.NullCheck;
import com.io7m.junreachable.UnreachableCodeException;
import org.slf4j.Logger;

/**
Expand All @@ -27,7 +28,7 @@ public final class SyErrors
{
private SyErrors()
{

throw new UnreachableCodeException();
}

/**
Expand Down
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);
}
}
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");
}
}

0 comments on commit fa056e5

Please sign in to comment.