Table-Driven

A table-driven test is like a basic unit test, except it maintains a table of different values ​​and results.

The test suite iterates over these values ​​and sends them to the test code. Using this approach, we can test various combinations of inputs and their respective outputs.


> go test -v

// Output:
=== RUN   TestAdd
--- PASS: TestAdd (0.00s)
PASS
ok      ./math 1.712s
                        
table_driven.go