1 00:00:06,020 --> 00:00:11,420 Hopefully you were able to successfully set up some test cases in order to test the methods that we 2 00:00:11,420 --> 00:00:13,580 implemented and the last lecture. 3 00:00:14,030 --> 00:00:18,710 So we are now going to go over my test cases for our methods. 4 00:00:19,850 --> 00:00:25,580 So the first thing that we need to do is just set up where we conduct our tests. 5 00:00:26,510 --> 00:00:36,080 So we will give it our config tests and we will call it mod test and we will bring in our Q into scope. 6 00:00:38,550 --> 00:00:47,010 For our first test, we're going to actually be able to test two methods that we implemented. 7 00:00:48,180 --> 00:00:58,300 We're going to be able to test in adding in a couple of values and then also test our is empty method. 8 00:00:58,320 --> 00:01:01,440 So let's go ahead and do that by creating a new queue, 9 00:01:04,320 --> 00:01:05,580 adding in some values. 10 00:01:05,580 --> 00:01:06,900 So we will say one 11 00:01:09,570 --> 00:01:22,320 and two, and if we successfully add it in values, then our assert equals on Q dot is empty should 12 00:01:22,320 --> 00:01:23,550 return false. 13 00:01:24,950 --> 00:01:31,670 So if we successfully added in values, then our test should return false if we're looking to see if 14 00:01:31,670 --> 00:01:32,690 it is empty or not. 15 00:01:33,560 --> 00:01:43,340 So now we are going to test our DK method and this is going to let us see if we are returning values 16 00:01:43,340 --> 00:01:46,670 correctly when we take them out of the queue. 17 00:01:47,270 --> 00:01:49,100 So we need to create our queue again. 18 00:01:54,520 --> 00:01:56,680 We need to add in some values. 19 00:01:57,010 --> 00:02:00,370 So again, we get a test out on Q method even more. 20 00:02:04,250 --> 00:02:10,220 And now we can test if values are correctly taking out of the queue. 21 00:02:10,250 --> 00:02:19,010 So when we run queue dot dx queue, we expect this to be some one. 22 00:02:22,020 --> 00:02:26,730 Our next test, we will evaluate peaking. 23 00:02:29,280 --> 00:02:31,290 So let's create our queue. 24 00:02:34,020 --> 00:02:36,750 Equals Q new. 25 00:02:39,400 --> 00:02:44,200 And here we will add in our typical values of one and two. 26 00:02:49,570 --> 00:02:55,720 And when we do our assert equals, we will cue dot peak. 27 00:02:59,140 --> 00:03:05,920 And we expect some and a reference to the one to be returned. 28 00:03:08,680 --> 00:03:14,800 And then for our next test case, we will test out our length. 29 00:03:15,880 --> 00:03:22,630 So we will say let mute queue is equal to a new queue. 30 00:03:25,590 --> 00:03:38,460 We will add in a value add in our next value and we will assert equals q dot 31 00:03:40,950 --> 00:03:44,640 length and check that it equals to two. 32 00:03:44,820 --> 00:03:50,790 So let's make sure we have tested all of our methods. 33 00:03:50,790 --> 00:03:56,160 So we did new and Q dx Q peak length and is empty. 34 00:03:56,610 --> 00:04:03,780 So if we run this, we would expect everything to pass successfully, which is what we got. 35 00:04:05,100 --> 00:04:11,880 So hopefully you are able to see that implementing a Q is very similar to implementing an A stack. 36 00:04:12,180 --> 00:04:19,770 And the key difference between a stack and a Q is the order in which values are put in and taken out 37 00:04:20,370 --> 00:04:21,330 a stack. 38 00:04:21,330 --> 00:04:30,240 Is LIFO meaning last in, first out and a Q is FIFO first in, first out? 39 00:04:30,420 --> 00:04:36,090 So if you have any questions about my implementation or even one of your implementations, please feel 40 00:04:36,090 --> 00:04:38,790 free to ask them in the Q&A section.