date_test.go 763 B

1234567891011121314151617181920212223242526272829303132
  1. package common
  2. import (
  3. "github.com/gogf/gf/os/gtime"
  4. "reflect"
  5. "testing"
  6. )
  7. func TestGetCNEndOfWeek(t *testing.T) {
  8. type args struct {
  9. time *gtime.Time
  10. }
  11. tests := []struct {
  12. name string
  13. args args
  14. want *gtime.Time
  15. }{
  16. {"日期测试", args{time: gtime.Now()}, gtime.NewFromStr("2020-09-19 23:59:59")},
  17. {"时间测试", args{time: gtime.Now()}, gtime.NewFromStr("2020-09-19 23:59:59")},
  18. }
  19. for _, tt := range tests {
  20. t.Run(tt.name, func(t *testing.T) {
  21. got := GetCNEndOfWeek(tt.args.time)
  22. if !reflect.DeepEqual(got.Day(), tt.want.Day()) {
  23. t.Errorf("GetCNEndOfWeek() = %v, want %v", got, tt.want)
  24. }
  25. if !reflect.DeepEqual(got.Hour(), tt.want.Hour()) {
  26. t.Errorf("GetCNEndOfWeek() = %v, want %v", got, tt.want)
  27. }
  28. })
  29. }
  30. }