Created
July 16, 2018 09:42
-
-
Save ramadani/9c2476ba931d919bf0b69dc0e82640b1 to your computer and use it in GitHub Desktop.
Full Circle Test Code
This file contains 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 circle | |
import ( | |
"testing" | |
) | |
func TestDiameter(t *testing.T) { | |
circle := Circle{Radius: 7} | |
expected := 14.0 | |
actual := circle.Diameter() | |
if actual != expected { | |
t.Errorf("TestDiameter failed, expected: '%.2f', got: '%.2f'", expected, actual) | |
} | |
} | |
func TestArea(t *testing.T) { | |
circle := Circle{Radius: 10} | |
expected := 314.1592653589793 | |
actual := circle.Area() | |
if actual != expected { | |
t.Errorf("TestArea failed, expected: '%.2f', got: '%.2f'", expected, actual) | |
} | |
} | |
func TestCircumference(t *testing.T) { | |
circle := Circle{Radius: 10} | |
expected := 62.83185307179586 | |
actual := circle.Circumference() | |
if actual != expected { | |
t.Errorf("TestCircumference failed, expected: '%.2f', got: '%.2f'", expected, actual) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment