Browse Source

add some tests

Yasuhiro Matsumoto 8 năm trước cách đây
mục cha
commit
eed7f88f41
1 tập tin đã thay đổi với 20 bổ sung0 xóa
  1. 20 0
      colorable_test.go

+ 20 - 0
colorable_test.go

@@ -2,6 +2,8 @@ package colorable
 
 import (
 	"bytes"
+	"os"
+	"runtime"
 	"testing"
 )
 
@@ -28,3 +30,21 @@ func TestEncoding(t *testing.T) {
 	checkEncoding(t, []byte(`é`))   // "é" in UTF-8
 	checkEncoding(t, []byte{233})   // 'é' in Latin-1
 }
+
+func TestColorable(t *testing.T) {
+	if runtime.GOOS == "windows" {
+		t.Skipf("skip this test on windows")
+	}
+	_, ok := NewColorableStdout().(*os.File)
+	if !ok {
+		t.Fatalf("should os.Stdout on UNIX")
+	}
+	_, ok = NewColorableStderr().(*os.File)
+	if !ok {
+		t.Fatalf("should os.Stdout on UNIX")
+	}
+	_, ok = NewColorable(os.Stdout).(*os.File)
+	if !ok {
+		t.Fatalf("should os.Stdout on UNIX")
+	}
+}