These exercises help you practice the basics of Go testing.
-
In the ex1 directory, there is a file called calculator.go, with a function called Average. Create a
calculator_test.gofile with a function to test Average. If you find a bug in the function, fix the bug and confirm that the test passes. -
In the ex2 directory, there is a file called temperature.go with a function called Convert. Create a
temperature_test.gofile with a function that uses a table test to validate all inputs and possible errors. If you find a bug in the function, fix the bug and confirm that the test passes. -
In the ex3 directory, there is a file called counter.go with a function called TotalFile. Create a
counter_test.gofile with a function to test TotalFile. Use a helper function to create both good and bad sample data.