blob: ce6e7a2264612d81642bd5ddb6c446c37b655f65 [file] [log] [blame]
alshabib1f44e8e2014-08-14 15:19:57 -07001package org.projectfloodlight.openflow.types;
2
3import static org.hamcrest.CoreMatchers.equalTo;
4import static org.junit.Assert.assertThat;
5
6import org.hamcrest.CoreMatchers;
7import org.junit.Test;
8
9public class OFVlanVidMatchTest {
10 @Test
11 public void testofVlanVid() {
12 assertThat(
13 (int) OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(1)).getRawVid(),
14 equalTo(0x1001));
15 assertThat(
16 (int) OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(0xFFF)).getRawVid(),
17 equalTo(0x1FFF));
18 assertThat(OFVlanVidMatch.ofVlanVid(null), equalTo(OFVlanVidMatch.UNTAGGED));
19 assertThat(OFVlanVidMatch.ofVlanVid(VlanVid.NO_MASK),
20 equalTo(OFVlanVidMatch.NO_MASK));
21 // a fully masked VlanVid means "PRESENT" in OFVlanVid
22 // (because a VlanVid always specifies a Vlan)
23 assertThat(OFVlanVidMatch.ofVlanVid(VlanVid.FULL_MASK),
24 equalTo(OFVlanVidMatch.PRESENT));
25 }
26 @Test
27 public void testtoVlanVid() {
28 assertThat(
29 OFVlanVidMatch.ofRawVid((short)0x1001).getVlanVid(),
30 equalTo(VlanVid.ofVlan(1)));
31 assertThat(
32 OFVlanVidMatch.ofRawVid((short)0x1FFF).getVlanVid(),
33 equalTo(VlanVid.ofVlan(0xFFF)));
34 assertThat(OFVlanVidMatch.UNTAGGED.getVlanVid(), CoreMatchers.nullValue());
35 assertThat(
36 OFVlanVidMatch.NO_MASK.getVlanVid(),
37 equalTo(VlanVid.NO_MASK));
38 assertThat(
39 OFVlanVidMatch.PRESENT.getVlanVid(),
40 equalTo(VlanVid.FULL_MASK));
41 }
42
43
44}