소스 검색

Menu test for panic when width too small.

Steve Thielemann 3 년 전
부모
커밋
12976b40da
1개의 변경된 파일17개의 추가작업 그리고 0개의 파일을 삭제
  1. 17 0
      door/menu_test.go

+ 17 - 0
door/menu_test.go

@@ -29,6 +29,23 @@ func TestMenuRender(t *testing.T) {
 	}
 }
 
+func TestMenuSize(t *testing.T) {
+	defer func() {
+		if r := recover(); r == nil {
+			t.Error("Menu Exeeding Width did not panic.")
+		}
+	}()
+
+	m := Menu{Panel: Panel{Width: 5,
+		X:     1,
+		Y:     1,
+		Style: DOUBLE,
+	}}
+	// len("[A] ABC") = 7 (which is > 5)
+	m.AddSelection("A", "ABC")
+
+}
+
 func TestMenuConnection(t *testing.T) {
 	tmpFile, err := ioutil.TempFile(os.TempDir(), "test-")
 	if err != nil {