Parcourir la source

add some tests

Yasuhiro Matsumoto il y a 8 ans
Parent
commit
eed7f88f41
1 fichiers modifiés avec 20 ajouts et 0 suppressions
  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")
+	}
+}