blob: 1fe36ac004e74e30eae86b7250fbd405ede3b980 [file] [log] [blame]
tom0eb04ca2014-08-25 14:34:51 -07001package org.projectfloodlight.openflow.types;
2
3import static org.hamcrest.CoreMatchers.equalTo;
4import static org.junit.Assert.assertThat;
5
6import org.junit.Test;
7
8public 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}