diff --git a/build.gradle b/build.gradle index 3b6d22d..f778a99 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,7 @@ dependencies { testCompile 'junit:junit-dep:4.10' testCompile 'org.hamcrest:hamcrest-library:1.2.1' testCompile 'org.mockito:mockito-core:1.8.5' + testCompile 'com.google.guava:guava-testlib:17.0' } task sourcesJar(type: Jar) { @@ -37,6 +38,14 @@ task sourcesJar(type: Jar) { from sourceSets.main.allSource } +test { + testLogging { + events "failed", "skipped" + showStandardStreams true + showExceptions true + } +} + artifacts { archives jar archives sourcesJar diff --git a/src/main/java/net/minecraft/commands/arguments/IntegerArgumentType.java b/src/main/java/net/minecraft/commands/arguments/IntegerArgumentType.java index cc1850f..e1559b6 100644 --- a/src/main/java/net/minecraft/commands/arguments/IntegerArgumentType.java +++ b/src/main/java/net/minecraft/commands/arguments/IntegerArgumentType.java @@ -53,4 +53,18 @@ public class IntegerArgumentType implements CommandArgumentType { throw new IllegalArgumentSyntaxException(); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof IntegerArgumentType)) return false; + + IntegerArgumentType that = (IntegerArgumentType) o; + return maximum == that.maximum && minimum == that.minimum; + } + + @Override + public int hashCode() { + return 31 * minimum + maximum; + } } diff --git a/src/test/java/net/minecraft/commands/arguments/IntegerArgumentTypeTest.java b/src/test/java/net/minecraft/commands/arguments/IntegerArgumentTypeTest.java index a61e085..c64dc3c 100644 --- a/src/test/java/net/minecraft/commands/arguments/IntegerArgumentTypeTest.java +++ b/src/test/java/net/minecraft/commands/arguments/IntegerArgumentTypeTest.java @@ -5,6 +5,7 @@ import net.minecraft.commands.context.CommandContextBuilder; import net.minecraft.commands.context.ParsedArgument; import net.minecraft.commands.exceptions.ArgumentValidationException; import net.minecraft.commands.exceptions.IllegalArgumentSyntaxException; +import com.google.common.testing.EqualsTester; import org.junit.Before; import org.junit.Test; @@ -65,4 +66,14 @@ public class IntegerArgumentTypeTest { assertThat(IntegerArgumentType.getInteger(context, "foo"), is(100)); } + + @Test + public void testEquals() throws Exception { + new EqualsTester() + .addEqualityGroup(integer(), integer()) + .addEqualityGroup(integer(-100, 100), integer(-100, 100)) + .addEqualityGroup(integer(-100, 50), integer(-100, 50)) + .addEqualityGroup(integer(-50, 100), integer(-50, 100)) + .testEquals(); + } } \ No newline at end of file