github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/internal/mathutils/mathutils_test.go (about)

     1  package mathutils
     2  
     3  import "testing"
     4  
     5  func TestMaxInt(t *testing.T) {
     6  	type args struct {
     7  		ints []int
     8  	}
     9  	tests := []struct {
    10  		name string
    11  		args args
    12  		want int
    13  	}{
    14  		{
    15  			"Returns max",
    16  			args{[]int{1, 2, 5, 4, 3}},
    17  			5,
    18  		},
    19  	}
    20  	for _, tt := range tests {
    21  		t.Run(tt.name, func(t *testing.T) {
    22  			if got := MaxInt(tt.args.ints...); got != tt.want {
    23  				t.Errorf("MaxInt() = %v, want %v", got, tt.want)
    24  			}
    25  		})
    26  	}
    27  }
    28  
    29  func TestMinInt(t *testing.T) {
    30  	type args struct {
    31  		ints []int
    32  	}
    33  	tests := []struct {
    34  		name string
    35  		args args
    36  		want int
    37  	}{
    38  		{
    39  			"Returns min",
    40  			args{[]int{1, 2, 5, 4, 3}},
    41  			1,
    42  		},
    43  	}
    44  	for _, tt := range tests {
    45  		t.Run(tt.name, func(t *testing.T) {
    46  			if got := MinInt(tt.args.ints...); got != tt.want {
    47  				t.Errorf("MinInt() = %v, want %v", got, tt.want)
    48  			}
    49  		})
    50  	}
    51  }