Refactor tests to use modern assertions

This commit is contained in:
Mike Cifelli 2017-11-12 17:19:30 -05:00
parent efb0329fda
commit 4ccdf9c959
2 changed files with 14 additions and 9 deletions

View File

@ -69,6 +69,12 @@
<version>1.16.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
<version>1.3</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -2,10 +2,10 @@ package testutil;
import static error.ErrorManager.Severity.ERROR;
import static function.builtin.EVAL.eval;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static sexpression.Nil.NIL;
import java.io.ByteArrayInputStream;
@ -85,17 +85,16 @@ public final class TestUtilities {
}
public static void assertSExpressionsMatch(SExpression one, SExpression two) {
assertEquals(one.toString(), two.toString());
assertThat(one.toString(), is(two.toString()));
}
public static void assertSExpressionsDoNotMatch(SExpression one, SExpression two) {
assertNotEquals(one.toString(), two.toString());
assertThat(one.toString(), not(two.toString()));
}
public static void assertIsErrorWithMessage(LispException e) {
assertEquals(ERROR, e.getSeverity());
assertNotNull(e.getMessage());
assertTrue(e.getMessage().length() > 0);
assertThat(e.getSeverity(), is(ERROR));
assertThat(e.getMessage(), not(isEmptyOrNullString()));
}
}