package vtt import ( "fmt" "testing" "sub-cli/internal/model" ) func TestParseVTTTimestamp(t *testing.T) { testCases := []struct { input string expected model.Timestamp }{ // Standard format {"00:00:01.000", model.Timestamp{Hours: 0, Minutes: 0, Seconds: 1, Milliseconds: 0}}, // Without leading zeros {"0:0:1.0", model.Timestamp{Hours: 0, Minutes: 0, Seconds: 1, Milliseconds: 0}}, // Different millisecond formats {"00:00:01.1", model.Timestamp{Hours: 0, Minutes: 0, Seconds: 1, Milliseconds: 100}}, {"00:00:01.12", model.Timestamp{Hours: 0, Minutes: 0, Seconds: 1, Milliseconds: 120}}, {"00:00:01.123", model.Timestamp{Hours: 0, Minutes: 0, Seconds: 1, Milliseconds: 123}}, // Long milliseconds (should truncate) {"00:00:01.1234", model.Timestamp{Hours: 0, Minutes: 0, Seconds: 1, Milliseconds: 123}}, // Unusual but valid format {"01:02:03.456", model.Timestamp{Hours: 1, Minutes: 2, Seconds: 3, Milliseconds: 456}}, // Invalid format (should return a zero timestamp) {"invalid", model.Timestamp{Hours: 0, Minutes: 0, Seconds: 0, Milliseconds: 0}}, } for _, tc := range testCases { t.Run(fmt.Sprintf("Timestamp_%s", tc.input), func(t *testing.T) { result := parseVTTTimestamp(tc.input) if result != tc.expected { t.Errorf("parseVTTTimestamp(%s) = %+v, want %+v", tc.input, result, tc.expected) } }) } }