github.com/sandwich-go/boost@v1.3.29/xcmd/cmd_boolean_test.go (about)

     1  package xcmd
     2  
     3  import (
     4  	. "github.com/smartystreets/goconvey/convey"
     5  	"testing"
     6  )
     7  
     8  func TestCmdBoolean(t *testing.T) {
     9  	Convey("cmd boolean", t, func() {
    10  		for _, cmd := range []struct {
    11  			s       string
    12  			isFalse bool
    13  		}{
    14  			{s: "", isFalse: true},
    15  			{s: "0", isFalse: true},
    16  			{s: "n", isFalse: true}, {s: "N", isFalse: true},
    17  			{s: "no", isFalse: true}, {s: "No", isFalse: true}, {s: "nO", isFalse: true}, {s: "NO", isFalse: true},
    18  			{s: "off", isFalse: true}, {s: "Off", isFalse: true}, {s: "OFf", isFalse: true}, {s: "OFF", isFalse: true},
    19  			{s: "false", isFalse: true}, {s: "False", isFalse: true}, {s: "faLSE", isFalse: true}, {s: "FALSE", isFalse: true},
    20  			{s: "1", isFalse: false}, {s: "Y", isFalse: false}, {s: "Yes", isFalse: false}, {s: "YES", isFalse: false}, {s: "ON", isFalse: false}, {s: "TRUE", isFalse: false},
    21  		} {
    22  			So(IsFalse(cmd.s), ShouldEqual, cmd.isFalse)
    23  			So(IsTrue(cmd.s), ShouldEqual, !cmd.isFalse)
    24  		}
    25  	})
    26  }