Andreas Wundsam | 16b9d87 | 2013-07-18 19:58:10 -0700 | [diff] [blame] | 1 | package org.openflow.types; |
| 2 | |
| 3 | import static org.junit.Assert.assertEquals; |
| 4 | |
| 5 | import java.math.BigInteger; |
| 6 | |
| 7 | import org.junit.Test; |
| 8 | |
| 9 | public class U64Test { |
| 10 | |
| 11 | @Test |
| 12 | public void testPositiveRaws() { |
| 13 | for(long positive: new long[] { 0, 1, 100, Long.MAX_VALUE }) { |
| 14 | assertEquals(positive, U64.of(positive).getValue()); |
| 15 | assertEquals(BigInteger.valueOf(positive), U64.of(positive).getBigInteger()); |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | @Test |
| 20 | public void testNegativeRaws() { |
| 21 | long minus_1 = 0xFFffFFffFFffFFffL; |
| 22 | assertEquals(minus_1, U64.of(minus_1).getValue()); |
| 23 | assertEquals(new BigInteger("FFffFFffFFffFFff", 16), U64.of(minus_1).getBigInteger()); |
| 24 | assertEquals(new BigInteger("18446744073709551615"), U64.of(minus_1).getBigInteger()); |
| 25 | } |
| 26 | } |