-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarsdatetime_test.go
37 lines (32 loc) · 1.03 KB
/
marsdatetime_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
package main
import "testing"
func TestEarthToMarsDate(t *testing.T) {
dates := []struct {
in string
out MarsDate
}{
{"2019-12-27T15:22:22Z", MarsDate{MSD: "51,896.44035", MTC: "10:34:06"}},
{"2006-01-02T15:04:05Z", MarsDate{MSD: "46,926.06938", MTC: "01:39:54"}},
{"2019-12-27T15:04:03", MarsDate{MSD: "51,896.42797", MTC: "10:16:17"}},
}
for _, date := range dates {
got, err := EarthToMarsDate(date.in)
if err != nil {
}
if got.MSD != date.out.MSD && got.MTC != date.out.MTC {
t.Errorf("EarthToMarsDate(%q) == %q, want %q", date.in, got, date.out)
}
}
failed := []struct {
in string
out ResultError
}{
{"2006-01-02 15:04:05", ResultError{Message: "Invalid DateTime format provided. Use RFC3339 for DateTime format: \"2019-12-27T15:04:03\""}},
}
for _, fail := range failed {
_, err := EarthToMarsDate(fail.in)
if err.Message != "Invalid DateTime format provided. Use RFC3339 for DateTime format: \"2019-12-27T15:04:03\"" {
t.Errorf("EarthToMarsDate(%q) == %q, want %q", fail.in, err, fail.out)
}
}
}