Skip to content

Commit

Permalink
Update structs-methods-and-interfaces.md (quii#372)
Browse files Browse the repository at this point in the history
Update error message format string when print float type data to make it same like example given
  • Loading branch information
ardinusawan authored Sep 17, 2020
1 parent 24b7b9a commit 5cbf8da
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion structs-methods-and-interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ Remember earlier when we were implementing `Triangle` and we had the failing tes

We knew this was in relation to `Triangle` because we were just working with it, but what if a bug slipped in to the system in one of 20 cases in the table? How would a developer know which case failed? This is not a great experience for the developer, they will have to manually look through the cases to find out which case actually failed.

We can change our error message into `%#v got %.2f want %.2f`. The `%#v` format string will print out our struct with the values in its field, so the developer can see at a glance the properties that are being tested.
We can change our error message into `%#v got %g want %g`. The `%#v` format string will print out our struct with the values in its field, so the developer can see at a glance the properties that are being tested.

To increase the readability of our test cases further we can rename the `want` field into something more descriptive like `hasArea`.

Expand Down

0 comments on commit 5cbf8da

Please sign in to comment.