File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,12 @@ func (err invalidLengthError) Error() string {
41
41
return fmt .Sprintf ("invalid UUID length: %d" , err .len )
42
42
}
43
43
44
+ // IsInvalidLengthError is matcher function for custom error invalidLengthError
45
+ func IsInvalidLengthError (err error ) bool {
46
+ _ , ok := err .(invalidLengthError )
47
+ return ok
48
+ }
49
+
44
50
// Parse decodes s into a UUID or returns an error. Both the standard UUID
45
51
// forms of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and
46
52
// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded as well as the
Original file line number Diff line number Diff line change @@ -526,6 +526,13 @@ func TestWrongLength(t *testing.T) {
526
526
}
527
527
}
528
528
529
+ func TestIsWrongLength (t * testing.T ) {
530
+ _ , err := Parse ("12345" )
531
+ if ! IsInvalidLengthError (err ) {
532
+ t .Errorf ("expected error type is invalidLengthError" )
533
+ }
534
+ }
535
+
529
536
var asString = "f47ac10b-58cc-0372-8567-0e02b2c3d479"
530
537
var asBytes = []byte (asString )
531
538
You can’t perform that action at this time.
0 commit comments