Andreas Wundsam | 19dfc1e | 2014-04-24 19:00:27 -0700 | [diff] [blame] | 1 | package org.projectfloodlight.openflow.types; |
| 2 | |
| 3 | import static org.hamcrest.CoreMatchers.equalTo; |
| 4 | import static org.junit.Assert.assertThat; |
| 5 | |
| 6 | import org.junit.Test; |
| 7 | |
| 8 | public class HashValueUtilsTest { |
| 9 | @Test |
| 10 | public void testBasic() { |
| 11 | long key = 0x1234_5678_1234_5678L; |
| 12 | long value = 0x8765_4321_8765_4321L; |
| 13 | long firstword = 0xFFFF_FFFF_0000_0000L; |
| 14 | long secondword = 0x0000_0000_FFFF_FFFFL; |
| 15 | long xor = key ^ value; |
| 16 | |
| 17 | assertThat(HashValueUtils.combineWithValue(key, value, 0), equalTo(xor)); |
| 18 | assertThat(HashValueUtils.combineWithValue(key, value, 64), equalTo(key)); |
| 19 | assertThat(HashValueUtils.combineWithValue(key, value, 32), equalTo(key & firstword | xor & secondword )); |
| 20 | assertThat(HashValueUtils.combineWithValue(key, value, 8), equalTo(0x1251_1559_9551_1559L)); |
| 21 | } |
| 22 | |
| 23 | } |