Skip to content

Commit

Permalink
fix bench and testing for Long methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jackspirou committed Sep 15, 2024
1 parent 60c5aea commit 08a85af
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Validate checks if a given field name's public ID value is valid according to th
## func [ValidateLong](<https://github.com/agentstation/publicid/blob/main/publicid.go#L66>)

```go
func ValidateLong(fieldName, id string) error
func ValidateLong(, id string) error
```

validateLong checks if a given field name's public ID value is valid according to the constraints defined by package publicid.
Expand Down
2 changes: 1 addition & 1 deletion publicid.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func Validate(id string) error {

// validateLong checks if a given field name's public ID value is valid according to
// the constraints defined by package publicid.
func ValidateLong(fieldName, id string) error {
func ValidateLong(id string) error {
return validate(id, longLen)
}

Expand Down
2 changes: 1 addition & 1 deletion publicid_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func BenchmarkValidateLong(b *testing.B) {
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
err := publicid.ValidateLong("BenchmarkValidateLong", id)
err := publicid.ValidateLong(id)
if err != nil {
b.Fatal(err)
}
Expand Down
6 changes: 3 additions & 3 deletions publicid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestLong(t *testing.T) {
if len(id) != 12 {
t.Errorf("Long() returned id with length %d, want 12", len(id))
}
if err := ValidateLong("TestLong", id); err != nil {
if err := ValidateLong(id); err != nil {
t.Errorf("Long() returned invalid id: %v", err)
}
}
Expand All @@ -54,7 +54,7 @@ func TestLongWithAttempts(t *testing.T) {
if len(id) != 12 {
t.Errorf("Long(Attempts(5)) returned id with length %d, want 12", len(id))
}
if err := ValidateLong("TestLongWithAttempts", id); err != nil {
if err := ValidateLong(id); err != nil {
t.Errorf("Long(Attempts(5)) returned invalid id: %v", err)
}
}
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestValidateLong(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err := ValidateLong("TestValidateLong", tc.id)
err := ValidateLong(tc.id)
if (err != nil) != tc.wantError {
t.Errorf("ValidateLong() error = %v, wantError %v", err, tc.wantError)
}
Expand Down

0 comments on commit 08a85af

Please sign in to comment.