gitee.com/go-spring2/spring-base@v1.1.3/color/color_test.go (about)

     1  /*
     2   * Copyright 2012-2019 the original author or authors.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *      https://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  package color_test
    18  
    19  import (
    20  	"fmt"
    21  	"testing"
    22  
    23  	"gitee.com/go-spring2/spring-base/color"
    24  )
    25  
    26  func TestColor(t *testing.T) {
    27  
    28  	fmt.Println(color.Bold.Sprint("ok"))
    29  	fmt.Println(color.Italic.Sprint("ok"))
    30  	fmt.Println(color.Underline.Sprint("ok"))
    31  	fmt.Println(color.ReverseVideo.Sprint("ok"))
    32  	fmt.Println(color.CrossedOut.Sprint("ok"))
    33  
    34  	fmt.Println(color.Black.Sprintf("ok"))
    35  	fmt.Println(color.Red.Sprintf("ok"))
    36  	fmt.Println(color.Green.Sprintf("ok"))
    37  	fmt.Println(color.Yellow.Sprintf("ok"))
    38  	fmt.Println(color.Blue.Sprintf("ok"))
    39  	fmt.Println(color.Magenta.Sprintf("ok"))
    40  	fmt.Println(color.Cyan.Sprintf("ok"))
    41  	fmt.Println(color.White.Sprintf("ok"))
    42  
    43  	fmt.Println(color.BgBlack.Sprint("ok"))
    44  	fmt.Println(color.BgRed.Sprint("ok"))
    45  	fmt.Println(color.BgGreen.Sprint("ok"))
    46  	fmt.Println(color.BgYellow.Sprint("ok"))
    47  	fmt.Println(color.BgBlue.Sprint("ok"))
    48  	fmt.Println(color.BgMagenta.Sprint("ok"))
    49  	fmt.Println(color.BgCyan.Sprint("ok"))
    50  	fmt.Println(color.BgWhite.Sprint("ok"))
    51  
    52  	attributes := []color.Attribute{
    53  		color.Bold,
    54  		color.Italic,
    55  		color.Underline,
    56  		color.ReverseVideo,
    57  		color.CrossedOut,
    58  		color.Red,
    59  		color.BgGreen,
    60  	}
    61  
    62  	fmt.Println(color.NewText().Sprint("ok"))
    63  	fmt.Println(color.NewText(attributes...).Sprint("ok"))
    64  	fmt.Println(color.NewText(attributes...).Sprintf("ok"))
    65  }