Created
September 5, 2021 15:32
-
-
Save agusrichard/6c6c196274947b70c296a0ba7330c7d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "testing" | |
| func TestDoubleMe(t *testing.T) { | |
| table := []struct { | |
| input float64 | |
| expected float64 | |
| }{ | |
| {1, 2}, | |
| {-1, -2}, | |
| {0, 0}, | |
| {-100, -200}, | |
| {100, 200}, | |
| } | |
| for _, test := range table { | |
| result := doubleMe(test.input) | |
| if result != test.expected { | |
| t.Errorf("doubleMe(%f) = %f, expected %f", test.input, result, test.expected) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment