## Splay Tree Solution - Software Testing

• 0:00 - 0:04
Now the second homework problem is a bit more
• 0:04 - 0:07
involved. Still not too bad but it requires a
• 0:07 - 0:09
bit more code. So we start off by initializing
• 0:09 - 0:12
the SplayTree and we have a few variables to
• 0:12 - 0:14
keep track of the current min and max as
• 0:14 - 0:17
we are going through. And we check whether the
• 0:17 - 0:22
empty SplayTree is actually empty, that is, isEmpty method
• 0:22 - 0:26
returns true. And similarly for findMin and findax, and sent
• 0:26 - 0:28
either can't be any min or max. And
• 0:28 - 0:32
that when we search an empty SplayTree that we
• 0:32 - 0:38
also return none. Now we insert 100 in here, and we set the current min and max
• 0:38 - 0:40
to be 100, just to initialize the tree
• 0:40 - 0:45
to something, and now we go through, and, for
• 0:45 - 0:48
10 examples we check whether the tree is
• 0:48 - 0:50
empty and it shouldn't be. Then we insert it,
• 0:50 - 0:54
insert a new key into the display tree for range
• 0:54 - 0:57
10 through 20 twice, just to see if that works
• 0:57 - 1:00
okay. Update current_min and current_max. Now we checked that that
• 1:00 - 1:03
has been inserted by trying to find it in the SplayTree,
• 1:03 - 1:06
and we assert that that should be found and it
• 1:06 - 1:10
should, find should return the current of the for loop
• 1:10 - 1:13
as found, and this is what we assert here. Now
• 1:13 - 1:16
we check the min and the max; the max shouldn't change,
• 1:16 - 1:20
since we're going from 10 to 20 and we've already inserted
• 1:20 - 1:24
100, but the min should change each time. So this should test,
• 1:24 - 1:26
the findMin function right here. And now we do the same
• 1:26 - 1:29
thing except we try to remove. And we just try to remove
• 1:29 - 1:32
these, assert that it's not empty, and that we don't find,
• 1:32 - 1:35
after removing the key, the key in the SplayTree, because it shouldn't
• 1:35 - 1:38
be in there anymore. And then just as a little, aside here,
• 1:38 - 1:41
we, try to insert 373 and remove it, to see what happens.
• 1:41 - 1:43
This is really not too involved. You could have gotten quite a bit
• 1:43 - 1:46
more advanced with this. This should do everything you need to do. So,
• 1:46 - 1:50
if we run this, we see we got it right. So, I hope
• 1:50 - 1:52
you had fun with this. Sorry about the bug that was in there
• 1:52 - 1:56
initially. And thank you to everyone who caught that, my fault entirely. So,
• 1:56 - 1:59
other than that, I hope you enjoyed this. I hope it showed you
• 1:59 - 2:03
what coverage can and can't do, and after this we'll be moving on
• 2:03 - 2:07
to random testing which I hope you'll also really enjoy. Thanks a lot.
Tytuł:
Splay Tree Solution - Software Testing
Opis:

more » « less
Video Language:
English
Team:
Udacity
Projekt:
CS258: Software Testing
Duration:
02:08
 Udacity Robot edited angielski subtitles for 04-02 Splay Tree Solution Udacity Robot edited angielski subtitles for 04-02 Splay Tree Solution Cogi-Admin edited angielski subtitles for 04-02 Splay Tree Solution

# English subtitles

## Revisions Compare revisions

• API
Udacity Robot
• API
Udacity Robot
• API