package auto import ( "testing" ) func TestAutoAbnormalRecordPprof(t *testing.T) { type args struct { mem float64 } tests := []struct { name string p *auto args args want bool setup func(p *auto) teardown func(p *auto) }{ { name: "empty memory", p: &auto{}, args: args{mem: 0}, want: false, }, { name: "empty fixed quotient", p: &auto{}, args: args{mem: 10}, want: false, }, { name: "dynamic quotient greater than fixed quotient", p: &auto{ recordSensitivity: 1, fixedQuotient: 2, perHourQuotient: []int{1}, }, args: args{mem: 3}, want: true, }, { name: "dynamic quotient less than fixed quotient", p: &auto{ recordSensitivity: 1, fixedQuotient: 2, perHourQuotient: []int{1}, }, args: args{mem: 1}, want: false, }, { name: "dynamic quotient equals to fixed quotient and perHourQuotient contains dynamic quotient", p: &auto{ recordSensitivity: 1, fixedQuotient: 2, perHourQuotient: []int{1, 2}, }, args: args{mem: 1}, want: false, }, { name: "dynamic quotient equals to fixed quotient and perHourQuotient doesn't contain dynamic quotient", p: &auto{ recordSensitivity: 1, fixedQuotient: 2, perHourQuotient: []int{1}, }, args: args{mem: 2}, want: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if tt.setup != nil { tt.setup(tt.p) } test1 := tt.p.judgeAbnormalMemoryState(tt.args.mem) if test1 != tt.want { t.Errorf("auto.abnormalRecordPprof() wantErr %v", test1) } }) } }