samedi 14 décembre 2019

Best suited doc-tests for the verification of the correctness of a function

I was wondering if there is a way to determine the necessary doc-tests for a function? Perhaps a protocol that we need to follow to come up with them?

The doc-tests that I could come up with are as follows:

>>> speed_ticket_value(0)
0

>>> speed_ticket_value(30)
100

>>> speed_ticket_value(50)
1000

>>> speed_ticket_value(-20)
0

However, I'm not entirely sure if the first test case covers the same functionality testing as the last one and the second as the third? Are doc-test necessarily meant to capture potential bugs in a function, or can just be used to capture the desired functionality of the developer? Sorry if my question seems silly.

Here's the question:

enter image description here

Any suggestions or tips would be greatly appreciated!

Aucun commentaire:

Enregistrer un commentaire