GPT-6 Astra × go-test
9.0Idiomatic Go table-driven tests + benchmark
correctness 10.0quality 10.0documentation 7.022431ms
$ cat go-test.prompt — what the model was asked
Write a Go test file for the following function:
```go
// WordCount returns a map of each unique word in s to the number
// of times it appears. Words are case-insensitive and separated by
// whitespace. Punctuation attached to words is stripped.
func WordCount(s string) map[string]int
```
Requirements:
- Package: `wordcount` (test file: `wordcount_test.go`)
- Use Go's standard `testing` package — no third-party libraries
- Use a table-driven test with a `[]struct{ name, input string; want map[string]int }` slice
- Include at least 6 test cases: empty string, single word, mixed case, punctuation, repeated words, multi-word sentence
- Use `t.Run(tc.name, ...)` for subtests so failures are identifiable
- Use `reflect.DeepEqual` or `maps.Equal` to compare maps
- Add a benchmark `BenchmarkWordCount` that runs on a realistic sentence
run 1 of 1
9.0correctness 10.0quality 10.0documentation 7.022431ms
# judge: The tests and benchmark are correct, comprehensive, idiomatic, and satisfy all functional requirements, but the requested explanatory comments on the test and benchmark functions are missing.
$ cat codex-cli/gpt-6-astra.go-test.r1.response
```go
package wordcount
import (
"reflect"
"testing"
)
func TestWordCount(t *testing.T) {
tests := []struct {
name, input string
want map[string]int
}{
{
name: "empty string",
input: "",
want: map[string]int{},
},
{
name: "single word",
input: "hello",
want: map[string]int{"hello": 1},
},
{
name: "mixed case",
input: "Hello HELLO hElLo World WORLD",
want: map[string]int{"hello": 3, "world": 2},
},
{
name: "punctuation",
input: `Hello, world! "Hello" (world).`,
want: map[string]int{"hello": 2, "world": 2},
},
{
name: "repeated words",
input: "go go stop go stop",
want: map[string]int{"go": 3, "stop": 2},
},
{
name: "multi-word sentence",
input: "The quick brown fox jumps over the lazy dog.",
want: map[string]int{
"the": 2, "quick": 1, "brown": 1, "fox": 1,
"jumps": 1, "over": 1, "lazy": 1, "dog": 1,
},
},
{
name: "mixed whitespace",
input: " \talpha\nbeta\r\nalpha gamma\t ",
want: map[string]int{"alpha": 2, "beta": 1, "gamma": 1},
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
got := WordCount(tc.input)
if !reflect.DeepEqual(got, tc.want) {
t.Errorf("WordCount(%q) = %v; want %v", tc.input, got, tc.want)
}
})
}
}
func BenchmarkWordCount(b *testing.B) {
const input = "Every morning, the team reviews the project updates, discusses new ideas, and plans the work for the day."
b.ReportAllocs()
for i := 0; i < b.N; i++ {
WordCount(input)
}
}
```