aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-01-31 17:38:23 +0000
committerFuwn <[email protected]>2026-01-31 17:38:23 +0000
commitd7b0de9f8b3f0722043207824061ac57c1490af2 (patch)
tree897641a91d0be43758fd31bab45eee4512f7bd45
parentrefactor: Split formatter.go into separate files (diff)
downloadiku-d7b0de9f8b3f0722043207824061ac57c1490af2.tar.xz
iku-d7b0de9f8b3f0722043207824061ac57c1490af2.zip
style: Use idiomatic Go test naming conventions
-rw-r--r--formatter_bench_test.go8
-rw-r--r--formatter_test.go72
2 files changed, 40 insertions, 40 deletions
diff --git a/formatter_bench_test.go b/formatter_bench_test.go
index 2a6d3cd..0820a10 100644
--- a/formatter_bench_test.go
+++ b/formatter_bench_test.go
@@ -5,7 +5,7 @@ import (
"testing"
)
-func BenchmarkFormat_Small(benchmarkRunner *testing.B) {
+func BenchmarkFormatSmall(b *testing.B) {
inputSource := []byte(`package main
func main() {
x := 1
@@ -18,12 +18,12 @@ func main() {
`)
formatter := &Formatter{CommentMode: CommentsFollow}
- for benchmarkRunner.Loop() {
+ for b.Loop() {
_, _ = formatter.Format(inputSource)
}
}
-func BenchmarkFormat_Large(benchmarkRunner *testing.B) {
+func BenchmarkFormatLarge(b *testing.B) {
var sourceBuilder strings.Builder
sourceBuilder.WriteString("package main\n\n")
@@ -43,7 +43,7 @@ func BenchmarkFormat_Large(benchmarkRunner *testing.B) {
inputSource := []byte(sourceBuilder.String())
formatter := &Formatter{CommentMode: CommentsFollow}
- for benchmarkRunner.Loop() {
+ for b.Loop() {
_, _ = formatter.Format(inputSource)
}
}
diff --git a/formatter_test.go b/formatter_test.go
index eadcbae..1942bfe 100644
--- a/formatter_test.go
+++ b/formatter_test.go
@@ -4,7 +4,7 @@ import (
"testing"
)
-func TestFormat_RemovesExtraBlankLines(testRunner *testing.T) {
+func TestFormatRemovesExtraBlankLines(t *testing.T) {
inputSource := `package main
func main() {
@@ -25,15 +25,15 @@ func main() {
formattedResult, err := formatter.Format([]byte(inputSource))
if err != nil {
- testRunner.Fatalf("Format error: %v", err)
+ t.Fatalf("Format error: %v", err)
}
if string(formattedResult) != expectedOutput {
- testRunner.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
+ t.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
}
}
-func TestFormat_AddsBlankLineAroundScopedStatements(testRunner *testing.T) {
+func TestFormatScopedStatements(t *testing.T) {
inputSource := `package main
func main() {
@@ -60,15 +60,15 @@ func main() {
formattedResult, err := formatter.Format([]byte(inputSource))
if err != nil {
- testRunner.Fatalf("Format error: %v", err)
+ t.Fatalf("Format error: %v", err)
}
if string(formattedResult) != expectedOutput {
- testRunner.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
+ t.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
}
}
-func TestFormat_NestedScopes(testRunner *testing.T) {
+func TestFormatNestedScopes(t *testing.T) {
inputSource := `package main
func main() {
@@ -99,15 +99,15 @@ func main() {
formattedResult, err := formatter.Format([]byte(inputSource))
if err != nil {
- testRunner.Fatalf("Format error: %v", err)
+ t.Fatalf("Format error: %v", err)
}
if string(formattedResult) != expectedOutput {
- testRunner.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
+ t.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
}
}
-func TestFormat_ForLoop(testRunner *testing.T) {
+func TestFormatForLoop(t *testing.T) {
inputSource := `package main
func main() {
@@ -134,15 +134,15 @@ func main() {
formattedResult, err := formatter.Format([]byte(inputSource))
if err != nil {
- testRunner.Fatalf("Format error: %v", err)
+ t.Fatalf("Format error: %v", err)
}
if string(formattedResult) != expectedOutput {
- testRunner.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
+ t.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
}
}
-func TestFormat_Switch(testRunner *testing.T) {
+func TestFormatSwitch(t *testing.T) {
inputSource := `package main
func main() {
@@ -171,15 +171,15 @@ func main() {
formattedResult, err := formatter.Format([]byte(inputSource))
if err != nil {
- testRunner.Fatalf("Format error: %v", err)
+ t.Fatalf("Format error: %v", err)
}
if string(formattedResult) != expectedOutput {
- testRunner.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
+ t.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
}
}
-func TestFormat_MultipleFunctions(testRunner *testing.T) {
+func TestFormatMultipleFunctions(t *testing.T) {
inputSource := `package main
func foo() {
@@ -205,15 +205,15 @@ func bar() {
formattedResult, err := formatter.Format([]byte(inputSource))
if err != nil {
- testRunner.Fatalf("Format error: %v", err)
+ t.Fatalf("Format error: %v", err)
}
if string(formattedResult) != expectedOutput {
- testRunner.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
+ t.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
}
}
-func TestFormat_TypeStruct(testRunner *testing.T) {
+func TestFormatTypeStruct(t *testing.T) {
inputSource := `package main
type Foo struct {
@@ -233,15 +233,15 @@ var x = 1
formattedResult, err := formatter.Format([]byte(inputSource))
if err != nil {
- testRunner.Fatalf("Format error: %v", err)
+ t.Fatalf("Format error: %v", err)
}
if string(formattedResult) != expectedOutput {
- testRunner.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
+ t.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
}
}
-func TestFormat_DifferentStatementTypes(testRunner *testing.T) {
+func TestFormatDifferentStatementTypes(t *testing.T) {
inputSource := `package main
func main() {
@@ -274,15 +274,15 @@ func main() {
formattedResult, err := formatter.Format([]byte(inputSource))
if err != nil {
- testRunner.Fatalf("Format error: %v", err)
+ t.Fatalf("Format error: %v", err)
}
if string(formattedResult) != expectedOutput {
- testRunner.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
+ t.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
}
}
-func TestFormat_ConsecutiveIfs(testRunner *testing.T) {
+func TestFormatConsecutiveIfs(t *testing.T) {
inputSource := `package main
func main() {
@@ -310,15 +310,15 @@ func main() {
formattedResult, err := formatter.Format([]byte(inputSource))
if err != nil {
- testRunner.Fatalf("Format error: %v", err)
+ t.Fatalf("Format error: %v", err)
}
if string(formattedResult) != expectedOutput {
- testRunner.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
+ t.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
}
}
-func TestFormat_CaseClauseStatements(testRunner *testing.T) {
+func TestFormatCaseClauseStatements(t *testing.T) {
inputSource := `package main
func main() {
@@ -348,15 +348,15 @@ func main() {
formattedResult, err := formatter.Format([]byte(inputSource))
if err != nil {
- testRunner.Fatalf("Format error: %v", err)
+ t.Fatalf("Format error: %v", err)
}
if string(formattedResult) != expectedOutput {
- testRunner.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
+ t.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
}
}
-func TestFormat_DeferWithInlineFunc(testRunner *testing.T) {
+func TestFormatDeferInlineFunc(t *testing.T) {
inputSource := `package main
func main() {
@@ -376,15 +376,15 @@ func main() {
formattedResult, err := formatter.Format([]byte(inputSource))
if err != nil {
- testRunner.Fatalf("Format error: %v", err)
+ t.Fatalf("Format error: %v", err)
}
if string(formattedResult) != expectedOutput {
- testRunner.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
+ t.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
}
}
-func TestFormat_CaseClauseConsecutiveAssignments(testRunner *testing.T) {
+func TestFormatCaseClauseAssignments(t *testing.T) {
inputSource := `package main
func main() {
@@ -415,10 +415,10 @@ func main() {
formattedResult, err := formatter.Format([]byte(inputSource))
if err != nil {
- testRunner.Fatalf("Format error: %v", err)
+ t.Fatalf("Format error: %v", err)
}
if string(formattedResult) != expectedOutput {
- testRunner.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
+ t.Errorf("got:\n%s\nwant:\n%s", formattedResult, expectedOutput)
}
}