-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fixer.go): enhance lookup function to support methods in additio…
…n to functions feat(fixer_test.go): add unit tests for the enhanced lookup functionality feat(testdata/stringer.go): add comments and new methods to support testing of new lookup functionality refactor(fixer.go): use strings package for splitting function names, improving code readability and functionality
- Loading branch information
1 parent
9ea8391
commit dc79d3f
Showing
3 changed files
with
67 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestLookup(t *testing.T) { | ||
t.Parallel() | ||
|
||
tests := []struct { | ||
filename, functionName string | ||
start, end int | ||
err error | ||
}{ | ||
{"testdata/reachable.go", "Reachable", 5, 7, nil}, | ||
{"testdata/stringer.go", "myString.String", 12, 14, nil}, | ||
{"testdata/stringer.go", "myString.Unreachable", 20, 22, nil}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.filename+":"+tt.functionName, func(t *testing.T) { | ||
t.Parallel() | ||
start, end, err := lookup(tt.filename, tt.functionName) | ||
if start != tt.start || end != tt.end || err != tt.err { | ||
t.Errorf("lookup(%q, %q) = (%d, %d, %v); want (%d, %d, %v)", | ||
tt.filename, tt.functionName, start, end, err, tt.start, tt.end, tt.err) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters