typeover
curriculum

Curriculum Idioms & ecosystem Testing exercise 3 · mcq

Testing

Pick the IDIOMATIC failure-reporting line inside a Go test function. (got and want are local variables; t is the *testing.T.) TypeScript: expect(got).toBe(want). Go has no assertion library — testing.T's methods + a bare if are the whole vocabulary.

TypeScript reference
Pick the idiomatic Go translation

About this theme

Go has a testing package in the standard library. Tests live next to code in _test.go files. The pattern is table-driven: a slice of (name, input, want) tuples plus t.Run(name, ...) for subtests. No assertion library required — if got != want { t.Errorf(...) } is the whole vocabulary.