File tree Expand file tree Collapse file tree 4 files changed +10
-1
lines changed
Expand file tree Collapse file tree 4 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,9 @@ func TestParseDateFailsIfMalformed(t *testing.T) {
114114 "20-12-12" ,
115115 "asdf" ,
116116 "01.01.2000" ,
117+ "⠃⠚⠚⠚-⠁⠃-⠚⠛" , // Braille digits
118+ "二〇〇〇-一二-〇四" , // Japanese digits
119+ "᠒᠐᠐᠐-᠑᠒-᠐᠗" , // Mongolean digits
117120 } {
118121 d , err := NewDateFromString (s )
119122 assert .Nil (t , d )
Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ func (d duration) ToStringWithSign() string {
111111 return s
112112}
113113
114- var durationPattern = regexp .MustCompile (`^(-|\+ )?((\d+)h)?((\d+)m)?$` )
114+ var durationPattern = regexp .MustCompile (`^([-+] )?((\d+)h)?((\d+)m)?$` )
115115
116116func NewDurationFromString (hhmm string ) (Duration , error ) {
117117 match := durationPattern .FindStringSubmatch (hhmm )
Original file line number Diff line number Diff line change @@ -130,6 +130,9 @@ func TestParsingFailsWithInvalidValue(t *testing.T) {
130130 "asdf" ,
131131 "6h asdf" ,
132132 "qwer 30m" ,
133+ "⠙⠛m" , // Braille digits
134+ "四二h" , // Japanese digits
135+ "᠒h᠐᠒m" , // Mongolean digits
133136 } {
134137 duration , err := NewDurationFromString (d )
135138 assert .EqualError (t , err , "MALFORMED_DURATION" )
Original file line number Diff line number Diff line change @@ -207,6 +207,9 @@ func TestParseMalformedTimesFail(t *testing.T) {
207207 "13:3" , // Minutes must have 2 digits
208208 "-14:12" , // Hours cannot be negative
209209 "14:-12" , // Minutes cannot be negative
210+ "⠃⠚:⠙⠛" , // Braille digits
211+ "四:二八" , // Japanese digits
212+ "᠒᠐:᠑᠒" , // Mongolean digits
210213 } {
211214 tm , err := NewTimeFromString (s )
212215 require .Nil (t , tm , s )
You can’t perform that action at this time.
0 commit comments