Welcome back. Writing test cases goes hand in hand with the incremental bit at a time development process that we've encouraged you to do. Let's work through an example. We're trying to define a distance function, and we have a skeleton of it here on line two. It takes as inputs two points, an x1, y1 coordinate and an x2, y2 coordinate. So, you can think of this like we have a grid and we have the origin at point 0, 0, and then we've got one, two, three, four, five, six, seven, and one, two, three, four, five, six, seven. Let's say we might have a point at 1, 2, and we might have another one at 1, 1. Let's imagine we've got one at 4, 6. So, here's four, and one, two, three, four, five, six. Right about here is 4, 6, and give it any pair of points. We want to be able to say how far apart are they. So, like between 1, 2 and 1, 1, there's a y distance of one. The x distance is zero. They have the same x value and the total distance between them as one. We wanted to figure out the distance between 1, 2 and 4, 6, we would figure out that the x distance is three and the y distance is four. Then if we remember our Pythagorean theorem formula, which I conveniently have for you, we'll take the x distance and square it, and the y distance in squared, we add those two together and then take the square root, that gives you the total distance. So, for example, with three and four, I would have a distance of three squared, so that's three squared equals nine, and four squared equals 16, add them together and we get 25. The square root of 25 is five. Or if you happen to remember the 3-4-5 triangle, we have three, four, and five. All right. So, sorry for that little bit of math, but we need to know that because that's the function we're going to try to implement this distance function. Now, initially, we've got a distance function that is not implemented. It takes an x1 and a y1, and x2 and a y2. It just returns none. I have a single test already defined. Because if we take the distance between any point and itself from 1, 2 to 1, 2, or from any point to itself, the distance ought to be zero. So, I can even start by running it. See how my first test does, and it tells me that I failed. Because the distance between the point 1, 2 and itself should have been zero, but we actually got none. So, the first thing we could do is replace that none with a zero, and we could return 0, 0. Now, if I run it, we pass that test. Very well, we've passed the first test, but that's not all that the distance function should do. If I gave it two different points, the distance ought not to be zero. So, before actually implementing this distance function, I'm going to write some more tests, and the test will tell me after I've implemented the distance function whether I've implemented it correctly. So, what's a couple of other tests that I might want to have? Well, I might want to check whether the distance between 1, 2 and 4, 6, that's what I illustrated before, whether that actually gives you a distance of five. If I take the distance between 0, 0 and 1, 1, and ought to be the square root of two. That's two to the power 0.5. So, now if I run my test, I'm still going to pass the first one, but I failed the other two. I was supposed to get five and I actually got zero, and I was supposed to get the square root of two, 1.41, et cetera, and I actually got zero. So then you could go and start to implement your distance function and as you implement it, you can check to make sure that you are passing all of these tests. So, here, I've now actually done the implementation. Now erase those marks which don't work anymore. We look at the x distance and y distance. We're squaring each of them and then we're taking the square root. Hopefully this works, but we can test it by writing and now we've passed all of the tests. So, I've magically skipped ahead a little bit, but you get the idea that having these tests is a way to know whether the implementation you've done of the function is correct or not. I'll see you next time.