Date(0, 1, 2, 3, 4, 5, 6, UTC),
Date(7, 8, 9, 10, 11, 12, 13, FixedZone("", 0)),
Unix(81985467080890095, 0x76543210), // Time.sec: 0x0123456789ABCDEF
- {}, // nil location
+ {}, // nil location
Date(1, 2, 3, 4, 5, 6, 7, FixedZone("", 32767*60)),
Date(1, 2, 3, 4, 5, 6, 7, FixedZone("", -32768*60)),
}
func TestDurationNanoseconds(t *testing.T) {
for _, tt := range nsDurationTests {
if got := tt.d.Nanoseconds(); got != tt.want {
- t.Errorf("d.Nanoseconds() = %d; want: %d", got, tt.want)
+ t.Errorf("Duration(%s).Nanoseconds() = %d; want: %d", tt.d, got, tt.want)
+ }
+ }
+}
+
+var usDurationTests = []struct {
+ d Duration
+ want int64
+}{
+ {Duration(-1000), -1},
+ {Duration(1000), 1},
+}
+
+func TestDurationMicroseconds(t *testing.T) {
+ for _, tt := range usDurationTests {
+ if got := tt.d.Microseconds(); got != tt.want {
+ t.Errorf("Duration(%s).Microseconds() = %d; want: %d", tt.d, got, tt.want)
+ }
+ }
+}
+
+var msDurationTests = []struct {
+ d Duration
+ want int64
+}{
+ {Duration(-1000000), -1},
+ {Duration(1000000), 1},
+}
+
+func TestDurationMilliseconds(t *testing.T) {
+ for _, tt := range msDurationTests {
+ if got := tt.d.Milliseconds(); got != tt.want {
+ t.Errorf("Duration(%s).Milliseconds() = %d; want: %d", tt.d, got, tt.want)
}
}
}
func TestDurationSeconds(t *testing.T) {
for _, tt := range secDurationTests {
if got := tt.d.Seconds(); got != tt.want {
- t.Errorf("d.Seconds() = %g; want: %g", got, tt.want)
+ t.Errorf("Duration(%s).Seconds() = %g; want: %g", tt.d, got, tt.want)
}
}
}
func TestDurationMinutes(t *testing.T) {
for _, tt := range minDurationTests {
if got := tt.d.Minutes(); got != tt.want {
- t.Errorf("d.Minutes() = %g; want: %g", got, tt.want)
+ t.Errorf("Duration(%s).Minutes() = %g; want: %g", tt.d, got, tt.want)
}
}
}
func TestDurationHours(t *testing.T) {
for _, tt := range hourDurationTests {
if got := tt.d.Hours(); got != tt.want {
- t.Errorf("d.Hours() = %g; want: %g", got, tt.want)
+ t.Errorf("Duration(%s).Hours() = %g; want: %g", tt.d, got, tt.want)
}
}
}