tstime: fold fractional ParseDuration cases into TestParseDuration

Updates #21552

Signed-off-by: Aniket <[email protected]>
This commit is contained in:
Aniket authored and Alex Chan committed 2026-11-12 09:18:45 +00:00
1 parent 5e444c9f32
commit e3ecbb9894
1 file changed
+3 -7
+3 -7
View File
@@ -30,24 +30,20 @@ func TestParseDuration(t *testing.T) {
{"1w1d1h", 8*24*time.Hour + time.Hour},
{"1y", 0},
{"", 0},
{"1.5h", 90 * time.Minute},
}
for _, tt := range tests {
if got, _ := ParseDuration(tt.in); got != tt.want {
t.Errorf("ParseDuration(%q) = %d; want %d", tt.in, got, tt.want)
}
}
}
func TestParseDurationFractionalDaysAndWeeks(t *testing.T) {
for _, in := range []string{"0.5d", "1.5d", "1.5w", ".5d", "2.25w", "1d0.5d"} {
errTests := []string{"0.5d", "1.5d", "1.5w", ".5d", "2.25w", "1d0.5d"}
for _, in := range errTests {
if d, err := ParseDuration(in); err == nil {
t.Errorf("ParseDuration(%q) = %v, want error", in, d)
}
}
// Fractional standard units are still fine.
if got, _ := ParseDuration("1.5h"); got != 90*time.Minute {
t.Errorf("ParseDuration(%q) = %v, want %v", "1.5h", got, 90*time.Minute)
}
}
func TestGoDuration(t *testing.T) {