mirror of
https://gitee.com/NorthCityChen/stl-go.git
synced 2025-05-25 12:01:08 +00:00
39 lines
986 B
Go
39 lines
986 B
Go
/*
|
|
* @Author: NorthCity1984
|
|
* @LastEditTime: 2022-04-02 13:19:50
|
|
* @Description:
|
|
* @Website: https://grimoire.cn
|
|
* Copyright (c) NorthCity1984 All rights reserved.
|
|
*/
|
|
package math_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitee.com/NorthCityChen/stl-go/math"
|
|
)
|
|
|
|
func TestMin(t *testing.T) {
|
|
if ans := math.Min(12); ans != 12 {
|
|
t.Errorf("min(12) should be 12, not %d", ans)
|
|
}
|
|
if ans := math.Min(12, 23, 44, 4, 6); ans != 4 {
|
|
t.Errorf("min(12, 23, 44, 4, 6) should be 4, not %d", ans)
|
|
}
|
|
if ans := math.Min[float32](12, 23, 0.5, 88, -1); ans != -1 {
|
|
t.Errorf("min(12, 23, 0.5, 88, -1) should be -1, not %f", ans)
|
|
}
|
|
}
|
|
|
|
func TestMax(t *testing.T) {
|
|
if ans := math.Max(12); ans != 12 {
|
|
t.Errorf("max(12) should be 12, not %d", ans)
|
|
}
|
|
if ans := math.Max(12, 23, 44, 4, 6); ans != 44 {
|
|
t.Errorf("max(12, 23, 44, 4, 6) should be 44, not %d", ans)
|
|
}
|
|
if ans := math.Max[float32](12, 23, 0.5, 88, -1); ans != 88 {
|
|
t.Errorf("max(12, 23, 0.5, 88, -1) should be 88, not %f", ans)
|
|
}
|
|
}
|