diff --git a/shapes/shapes_test.go b/shapes/shapes_test.go index 6cdfdd0..275ecb7 100644 --- a/shapes/shapes_test.go +++ b/shapes/shapes_test.go @@ -14,18 +14,21 @@ func TestPerimeter(t *testing.T) { func TestArea(t *testing.T) { areaTests := []struct { - shape Shape - exp float64 + name string + shape Shape + hasArea float64 }{ - {Rectangle{30.5, 20.5}, 625.25}, - {Circle{10}, 314.1592653589793}, - {Triangle{12, 6}, 36.0}, + {name: "Rectangle", shape: Rectangle{Width: 30.5, Height: 20.5}, hasArea: 625.25}, + {name: "Circle", shape: Circle{Radius: 10}, hasArea: 314.1592653589793}, + {name: "Triangle", shape: Triangle{Width: 12, Height: 6}, hasArea: 36.0}, } for _, test := range areaTests { - got := test.shape.Area() - if got != test.exp { - t.Errorf("got %.2f expected %.2f", got, test.exp) - } + t.Run(test.name, func(t *testing.T) { + got := test.shape.Area() + if got != test.hasArea { + t.Errorf("%#v got %g expected %g", test.shape, got, test.hasArea) + } + }) } }