Created
February 6, 2012 02:00
-
-
Save rhiguchi/1748919 to your computer and use it in GitHub Desktop.
MIN_VALUEの値のテスト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LimitValueTest { | |
@Test | |
public void limitOfInteger() { | |
assertEquals(2147483647, Integer.MAX_VALUE); | |
assertEquals(0x7fffffff, Integer.MAX_VALUE); | |
assertEquals(-2147483648, Integer.MIN_VALUE); | |
assertEquals(-0x80000000, Integer.MIN_VALUE); | |
} | |
@Test | |
public void limitOfLong() { | |
assertEquals(9223372036854775807L, Long.MAX_VALUE); | |
assertEquals(0x7fffffffffffffffL, Long.MAX_VALUE); | |
assertEquals(-9223372036854775808L, Long.MIN_VALUE); | |
assertEquals(-0x8000000000000000L, Long.MIN_VALUE); | |
} | |
@Test | |
public void limitOfFloatingPointTypes() { | |
assertTrue("MIN_VALUE is not a negative", 0 < Double.MIN_VALUE); | |
assertTrue("MIN_VALUE is not a negative", 0 < Float.MIN_VALUE); | |
assertEquals(Double.longBitsToDouble(0x1), Double.MIN_VALUE, 0); | |
assertEquals(Float.intBitsToFloat(0x1), Float.MIN_VALUE, 0); | |
} | |
@Test | |
public void absoluteValueOfMinimumValue() { | |
assertEquals(Integer.MIN_VALUE, -Integer.MIN_VALUE); | |
assertEquals(Long.MIN_VALUE, -Long.MIN_VALUE); | |
assertEquals(0x80000000, -0x80000000); | |
assertEquals(0x8000000000000000L, -0x8000000000000000L); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment