Skip to content

Instantly share code, notes, and snippets.

@ramadani
Created July 16, 2018 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramadani/9c2476ba931d919bf0b69dc0e82640b1 to your computer and use it in GitHub Desktop.
Save ramadani/9c2476ba931d919bf0b69dc0e82640b1 to your computer and use it in GitHub Desktop.
Full Circle Test Code
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