Exercise · From a file to a project · lesson 10 of 10
Exercise: a table of cases
This time you write the tests, not the function. Fill in the cases table in cases_test.go: each case is a name name, an input x and the expected result want of abs. abs itself and the test that runs the table through t.Run are already in abs_test.go.
{"negative", -7, 7}— the subtestTestAbs/negative{"zero", 0, 0}{"positive", 4, 4}
Constraints: the table has at least one negative x, a zero and at least one positive x; names are non-empty and distinct; every x appears in the table once and is from -1000 to 1000; want is the absolute value of x.
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.