1
0
mirror of https://github.com/ManyakRus/starter.git synced 2025-12-05 00:12:51 +02:00
Files
starter/calendar/calendar_test.go

44 lines
1.0 KiB
Go
Raw Normal View History

2023-03-17 11:20:09 +03:00
package calendar
import (
"testing"
"time"
)
func TestFindPreviousWorkDay(t *testing.T) {
2025-08-12 13:02:09 +03:00
Date := time.Date(2023, 03, 13, 0, 0, 0, 0, constants_starter.Loc)
2023-03-17 11:20:09 +03:00
Otvet := FindPreviousWorkDay(Date)
2025-08-12 13:02:09 +03:00
if Otvet != time.Date(2023, 03, 10, 0, 0, 0, 0, constants_starter.Loc) {
2023-03-17 11:20:09 +03:00
t.Error("TestFindPreviousWorkDay error")
}
}
func TestIsWorkDay(t *testing.T) {
2025-08-12 13:02:09 +03:00
Date := time.Date(2023, 03, 19, 0, 0, 0, 0, constants_starter.Loc)
2023-03-17 11:20:09 +03:00
Otvet := IsWorkDay(Date)
if Otvet != false {
t.Error("TestIsWorkDay error")
}
}
2025-02-12 15:12:33 +03:00
func TestHoursMinutesSeconds_UnmarshalByte(t *testing.T) {
Otvet := HoursMinutesSeconds{}
2025-02-12 15:17:19 +03:00
Otvet.UnmarshalJSON([]byte("01:02:03"))
2025-02-12 15:12:33 +03:00
if Otvet.Hours != 1 || Otvet.Minutes != 2 || Otvet.Seconds != 3 {
t.Error("TestHoursMinutesSeconds_UnmarshalByte error")
}
}
2025-05-20 15:43:12 +03:00
func TestDiff_dates(t *testing.T) {
2025-08-12 13:02:09 +03:00
Date1 := time.Date(2023, 03, 19, 0, 0, 0, 0, constants_starter.Loc)
Date2 := time.Date(2023, 03, 20, 0, 0, 0, 0, constants_starter.Loc)
2025-05-20 15:43:12 +03:00
_, _, days, _, _, _ := Diff_dates(Date1, Date2)
if days != 1 {
t.Error("TestDiff_dates error")
}
}