Skip to content

Commit

Permalink
Implement Verify.assertNotInstanceOf. #28
Browse files Browse the repository at this point in the history
Signed-off-by: Bhavana <bhavana.hindupur@gmail.com>
  • Loading branch information
superhindupur committed Feb 1, 2016
1 parent 4feb5bd commit a010174
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Expand Up @@ -785,6 +785,39 @@ public static void assertInstanceOf(String objectName, Class<?> expectedClassTyp
}
}

/**
* Assert that the given object is not an instanceof expectedClassType.
*/
public static void assertNotInstanceOf(Class<?> expectedClassType, Object actualObject)
{
try
{
Verify.assertNotInstanceOf(actualObject.getClass().getName(), expectedClassType, actualObject);
}
catch (AssertionError e)
{
Verify.throwMangledException(e);
}
}

/**
* Assert that the given object is not an instanceof expectedClassType.
*/
public static void assertNotInstanceOf(String objectName, Class<?> expectedClassType, Object actualObject)
{
try
{
if (expectedClassType.isInstance(actualObject))
{
Assert.fail(objectName + " is an instance of " + expectedClassType.getName());
}
}
catch (AssertionError e)
{
Verify.throwMangledException(e);
}
}

/**
* Assert that the given {@link Map} is empty.
*/
Expand Down
Expand Up @@ -672,6 +672,22 @@ public void assertInstanceOf()
}
}

@Test
public void assertNotInstanceOf()
{
Verify.assertNotInstanceOf(Integer.class, 1L);

try
{
Verify.assertNotInstanceOf(Integer.class, 1);
Assert.fail();
}
catch (AssertionError e)
{
Verify.assertContains(VerifyTest.class.getName(), e.getStackTrace()[0].toString());
}
}

@Test
public void assertSortedSetsEqual()
{
Expand Down

0 comments on commit a010174

Please sign in to comment.