Browse Source

Testing more states when socket closed.

Steve Thielemann 3 years ago
parent
commit
63b6c30a2c
1 changed files with 21 additions and 0 deletions
  1. 21 0
      door/input_test.go

+ 21 - 0
door/input_test.go

@@ -187,8 +187,29 @@ func TestDoorInputConnection(t *testing.T) {
 		t.Errorf("Disconnected flag shows: %t (should be true)", d.Disconnected)
 	}
 
+	if !d.HasKey() {
+		t.Error("HasKey should return true (disconnected).")
+	}
+
+	hungup = d.GetKey()
+
+	if hungup != -2 {
+		t.Errorf("Expected -2 (hangup), got %d", hungup)
+	}
 	client.Close()
 
+	blank := d.Input(5)
+
+	if blank != "" {
+		t.Errorf("Input should return blank (hangup).")
+	}
+
+	hungup = d.getch()
+
+	if hungup != -2 {
+		t.Errorf("Expected -2 (hangup), got %d", hungup)
+	}
+
 }
 
 func TestDisplayInput(t *testing.T) {