-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
A triangle angles sums up to 180 degrees.
For Test Driven Development we need to start with a test, and the test should fail before we write the real code.
In Python we can create a test like this:
def test_sum_angles():
if classification(60,60,60) == false :
print(" sum_angles FAILED ")
The code that fails look like this:
def classification (a,b,c):
return false
Write the above in your own language of choice and see that the test indeed prints out FAILED.
Now add the minimal amount of code that makes the test pass.
def classification(a,b,c):
if a+b+c == 180:
print("This IS a triangle")
return true
return false
Run the code and see that the test passes. We now have a working test to check if we have a triangle.
Extra - For Test Driven Development, clean up the code ( refactor it ) and re-run all tests to check that nothing broke in the code.
Metadata
Metadata
Assignees
Labels
No labels