57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"math"
|
|
"pet-house.com/business/models"
|
|
"strconv"
|
|
"testing"
|
|
)
|
|
|
|
func TestGetStrDays(t *testing.T) {
|
|
var ReserveMap map[string]models.ReserveTimeFilter
|
|
ReserveMap = make(map[string]models.ReserveTimeFilter)
|
|
ReserveMap["2024-04-10"] = models.ReserveTimeFilter{
|
|
Type: 1,
|
|
Content: "2024-04-10",
|
|
}
|
|
ReserveMap["12"] = models.ReserveTimeFilter{
|
|
Type: 2,
|
|
Content: "12",
|
|
}
|
|
//days := GetStrDays(7, 30, ReserveMap, nil, 1, nil, 2)
|
|
//fmt.Println(days)
|
|
}
|
|
|
|
func TestCalc(t *testing.T) {
|
|
i := math.Round(386 * (float64(85) / 100))
|
|
fmt.Println(i)
|
|
}
|
|
func TestCalc1(t *testing.T) {
|
|
i := float64(85) / 100
|
|
fmt.Println(i)
|
|
}
|
|
|
|
func roundToOneDecimalPlace(value float64) float64 {
|
|
return math.Round(value*10) / 10
|
|
}
|
|
|
|
func TestCalc3(t *testing.T) {
|
|
i := float64(348) * 0.95
|
|
fmt.Println(i)
|
|
}
|
|
func TestCalc4(t *testing.T) {
|
|
value := 267.77
|
|
roundedValue := roundToOneDecimalPlace(value)
|
|
fmt.Printf("%.1f\n", roundedValue) // 输出 3.1
|
|
}
|
|
func TestCalc5(t *testing.T) {
|
|
var a = 1596
|
|
float := strconv.FormatFloat(float64(a/10.0), 'f', 1, 64)
|
|
fmt.Printf(float)
|
|
}
|
|
func TestMath(t *testing.T) {
|
|
var a = int(RoundToOneDecimalPlace(float64(150)*(95/100.0)) * 10)
|
|
fmt.Println(a)
|
|
}
|