github.com/songzhibin97/go-baseutils@v0.0.2-0.20240302024150-487d8ce9c082/base/bternaryexpr/uternaryexpr_test.go (about) 1 package bternaryexpr 2 3 import ( 4 "testing" 5 ) 6 7 func TestTernaryExpr(t *testing.T) { 8 type args struct { 9 boolExpr bool 10 trueReturn interface{} 11 falseReturn interface{} 12 } 13 tests := []struct { 14 name string 15 args args 16 want interface{} 17 }{ 18 { 19 name: "base", 20 args: args{ 21 boolExpr: true, 22 trueReturn: 1, 23 falseReturn: 2, 24 }, 25 want: 1, 26 }, 27 { 28 name: "base", 29 args: args{ 30 boolExpr: false, 31 trueReturn: 1, 32 falseReturn: 2, 33 }, 34 want: 2, 35 }, 36 } 37 for _, tt := range tests { 38 t.Run(tt.name, func(t *testing.T) { 39 if got := TernaryExpr(tt.args.boolExpr, tt.args.trueReturn, tt.args.falseReturn); got != tt.want { 40 t.Errorf("TernaryExpr() = %v, want %v", got, tt.want) 41 } 42 }) 43 } 44 }