| 67 | } |
| 68 | |
| 69 | func TestPadZeroes(t *testing.T) { |
| 70 | tests := []struct { |
| 71 | name string |
| 72 | rawStr string |
| 73 | acc int |
| 74 | expected string |
| 75 | }{ |
| 76 | { |
| 77 | name: "No decimal part", |
| 78 | rawStr: "12:34:56", |
| 79 | acc: 6, |
| 80 | expected: "12:34:56", |
| 81 | }, |
| 82 | { |
| 83 | name: "Already correct precision", |
| 84 | rawStr: "12:34:56.123456", |
| 85 | acc: 6, |
| 86 | expected: "12:34:56.123456", |
| 87 | }, |
| 88 | { |
| 89 | name: "Less precision", |
| 90 | rawStr: "12:34:56.123", |
| 91 | acc: 6, |
| 92 | expected: "12:34:56.123000", |
| 93 | }, |
| 94 | { |
| 95 | name: "More precision", |
| 96 | rawStr: "12:34:56.123456789", |
| 97 | acc: 6, |
| 98 | expected: "12:34:56.123456789", |
| 99 | }, |
| 100 | { |
| 101 | name: "With timezone", |
| 102 | rawStr: "12:34:56.123+02:00", |
| 103 | acc: 6, |
| 104 | expected: "12:34:56.123000+02:00", |
| 105 | }, |
| 106 | { |
| 107 | name: "With negative timezone", |
| 108 | rawStr: "12:34:56.123-02:00", |
| 109 | acc: 6, |
| 110 | expected: "12:34:56.123000-02:00", |
| 111 | }, |
| 112 | { |
| 113 | name: "Invalid format: timezone before decimal (edge case fix)", |
| 114 | rawStr: "12:34-05:56.123", |
| 115 | acc: 6, |
| 116 | expected: "12:34-05:56.123000", |
| 117 | }, |
| 118 | { |
| 119 | name: "Negative interval: leading minus should be ignored", |
| 120 | rawStr: "-00:04:37.530865", |
| 121 | acc: 6, |
| 122 | expected: "-00:04:37.530865", |
| 123 | }, |
| 124 | { |
| 125 | name: "Negative interval with short precision", |
| 126 | rawStr: "-00:02:45.25", |