Browse Source

Adding header encode/decode test

Armon Dadgar 10 years ago
parent
commit
0b771b2e59
1 changed files with 21 additions and 0 deletions
  1. 21 0
      const_test.go

+ 21 - 0
const_test.go

@@ -52,3 +52,24 @@ func TestConst(t *testing.T) {
 		t.Fatalf("bad header size")
 	}
 }
+
+func TestEncodeDecode(t *testing.T) {
+	hdr := header(make([]byte, headerSize))
+	hdr.encode(typeWindowUpdate, flagACK|flagLZW, 1234, 4321)
+
+	if hdr.Version() != protoVersion {
+		t.Fatalf("bad: %v", hdr)
+	}
+	if hdr.MsgType() != typeWindowUpdate {
+		t.Fatalf("bad: %v", hdr)
+	}
+	if hdr.Flags() != flagACK|flagLZW {
+		t.Fatalf("bad: %v", hdr)
+	}
+	if hdr.StreamID() != 1234 {
+		t.Fatalf("bad: %v", hdr)
+	}
+	if hdr.Length() != 4321 {
+		t.Fatalf("bad: %v", hdr)
+	}
+}