Added a nice toString to IntegerArgumentType
This commit is contained in:
parent
fb92c2f3c8
commit
f91bc15e19
2 changed files with 20 additions and 0 deletions
|
@ -67,4 +67,15 @@ public class IntegerArgumentType implements CommandArgumentType<Integer> {
|
|||
public int hashCode() {
|
||||
return 31 * minimum + maximum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (minimum == Integer.MIN_VALUE && maximum == Integer.MAX_VALUE) {
|
||||
return "integer()";
|
||||
} else if (maximum == Integer.MAX_VALUE) {
|
||||
return "integer(" + minimum + ")";
|
||||
} else {
|
||||
return "integer(" + minimum + ", " + maximum + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
|
||||
import static net.minecraft.commands.arguments.IntegerArgumentType.integer;
|
||||
import static org.hamcrest.Matchers.hasToString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
|
@ -76,4 +77,12 @@ public class IntegerArgumentTypeTest {
|
|||
.addEqualityGroup(integer(-50, 100), integer(-50, 100))
|
||||
.testEquals();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() throws Exception {
|
||||
assertThat(integer(), hasToString("integer()"));
|
||||
assertThat(integer(-100), hasToString("integer(-100)"));
|
||||
assertThat(integer(-100, 100), hasToString("integer(-100, 100)"));
|
||||
assertThat(integer(Integer.MIN_VALUE, 100), hasToString("integer(-2147483648, 100)"));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue