-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathparse_time_test.go
57 lines (50 loc) · 1.23 KB
/
parse_time_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"io"
"os"
"testing"
"github.com/usher2/u2ckdump/internal/logger"
)
func init() {
logger.LogInit(io.Discard, os.Stdout, os.Stderr, os.Stderr)
}
// TestParseRFC3339Time tests the parseRFC3339Time function.
func TestParseRFC3339Time(t *testing.T) {
tests := []struct {
name string
timeStr string
expectedVal int64
}{
{"Valid RFC3339 Time", "2023-03-25T12:34:56Z", 1679747696},
{"Empty String", "", 0},
{"Invalid Time String", "invalid_time", 0},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := parseRFC3339Time(tt.timeStr)
if result != tt.expectedVal {
t.Errorf("Expected %d, got %d", tt.expectedVal, result)
}
})
}
}
// TestParseMoscowTime tests the parseMoscowTime function.
func TestParseMoscowTime(t *testing.T) {
tests := []struct {
name string
timeStr string
expectedVal int64
}{
{"Valid Moscow Time", "2023-03-25T15:34:56", 1679747696},
{"Empty String", "", 0},
{"Invalid Time String", "invalid_time", 0},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := parseMoscowTime(tt.timeStr)
if result != tt.expectedVal {
t.Errorf("Expected %d, got %d", tt.expectedVal, result)
}
})
}
}