1 00:00:06,630 --> 00:00:09,210 Now that we have some methods implemented in. 2 00:00:09,240 --> 00:00:11,910 It is time for us to test them. 3 00:00:12,450 --> 00:00:15,210 So we need to create some tests. 4 00:00:15,210 --> 00:00:19,020 So we will say mod test and now we will say use super. 5 00:00:19,020 --> 00:00:26,370 And then we just want to take everything that we have implemented in thus far and now we want to create 6 00:00:27,240 --> 00:00:28,110 a test. 7 00:00:29,010 --> 00:00:37,350 So we will call it basics, since we are just testing our basic functions here and we want to create 8 00:00:37,350 --> 00:00:42,960 a new mutable list since we are going to be adding and removing elements. 9 00:00:42,960 --> 00:00:44,580 So we will create a new list. 10 00:00:44,940 --> 00:00:55,890 So the first thing we want to do is check if empty list behaves correctly. 11 00:00:56,100 --> 00:01:04,020 So we will use the assert equals macro and we will say list dot pop. 12 00:01:04,560 --> 00:01:08,850 And if we pop an empty list, then we should have none returned. 13 00:01:10,980 --> 00:01:22,950 Now we want to populate the list and we will say list dot push and we're going to copy and paste this 14 00:01:23,370 --> 00:01:28,770 a couple more times and we will put in one, two and three. 15 00:01:31,410 --> 00:01:34,440 And now we want to check normal. 16 00:01:35,570 --> 00:01:38,050 Removal by using a pop. 17 00:01:38,150 --> 00:01:40,400 So again, we will say assert equals. 18 00:01:40,670 --> 00:01:43,120 We will list dot pop. 19 00:01:43,130 --> 00:01:46,130 We know that we get a value return some value. 20 00:01:46,280 --> 00:01:51,140 So since three was the last value we pushed in, we expect that to be popped. 21 00:01:51,530 --> 00:02:01,490 And if we pop again, we expect some two to be returned since three is no longer in the list. 22 00:02:03,200 --> 00:02:15,770 Another test we would say push some more values on and now we want to say list dot push for and list 23 00:02:15,770 --> 00:02:17,780 dot push five. 24 00:02:20,150 --> 00:02:23,780 Let's go ahead and check our removal again. 25 00:02:26,270 --> 00:02:29,540 So now we want to say we want to pop. 26 00:02:29,540 --> 00:02:32,000 We expect five pop again. 27 00:02:32,000 --> 00:02:33,980 We expect four to be removed. 28 00:02:33,980 --> 00:02:37,940 And now let's do exhaustive 29 00:02:40,700 --> 00:02:42,710 removal check. 30 00:02:42,830 --> 00:02:49,550 So now that we know that four and five are gone, let's just go ahead and pop the rest of them. 31 00:02:50,870 --> 00:02:54,350 So now we expect some one to be returned. 32 00:02:55,220 --> 00:03:04,840 And if we do it again one more time with one no longer being in there, we now expect none to be returned. 33 00:03:04,850 --> 00:03:06,740 So let's just go over this real quick. 34 00:03:06,950 --> 00:03:10,190 So we're going to check to make sure an empty list behaves correctly. 35 00:03:10,190 --> 00:03:12,320 With a new list being created. 36 00:03:12,320 --> 00:03:20,270 We expect if we pop something that none is returned, we're going to use push to populate some values. 37 00:03:20,270 --> 00:03:26,810 So we want to then pop to make sure three was the last value we got pushed on. 38 00:03:26,810 --> 00:03:32,480 And then we want to pop again to make sure two was pushed before three. 39 00:03:33,050 --> 00:03:35,120 Then let's push a couple more values on. 40 00:03:35,120 --> 00:03:38,180 So now our list should be one, four, five. 41 00:03:38,720 --> 00:03:40,640 We want to pop and then pop again. 42 00:03:40,640 --> 00:03:42,470 So then five and four are gone. 43 00:03:42,470 --> 00:03:44,630 And now let's just make sure we can pop one. 44 00:03:44,630 --> 00:03:49,130 And then if we pop one more time, we want to make sure our list is now empty again. 45 00:03:49,700 --> 00:03:54,620 So if we run cargo test, we see that we have an error. 46 00:03:57,320 --> 00:04:02,480 And it is saying we need to add a semicolon somewhere. 47 00:04:02,510 --> 00:04:07,790 Let's see if that is our issue cargo test. 48 00:04:08,840 --> 00:04:13,010 And we see that our test were completed successfully. 49 00:04:13,010 --> 00:04:20,420 They are one test pass, which means everything inside of our test ran successfully and we have no failures. 50 00:04:21,140 --> 00:04:24,700 So it looks like our three methods are running correctly. 51 00:04:24,710 --> 00:04:32,210 So now that we know that we have a functioning linked list, let's begin implementing in a couple more 52 00:04:32,210 --> 00:04:37,520 methods and also look at some unique use cases that we need to account for.