Hide

Problem A
Test your linked list

Languages en sv

This is a problem which asks you to write an implementation of a linked list, as well as some unit tests for it. You should have already written unit tests, and gotten them accepted by Kattis before starting this problem. Using your unit tests locally, write a working LinkedList implementation, and then submit it on this problem. We will test your linked list using the tests you submitted, as well as a test suite we have created.

Our test suite will only insert basic data types (small strings and integers) in your list.

This problem can only be solved in Python. The problem is used for examination in course DD1327 at KTH, so it should not be used for other courses that the same students might take.

Code structure

Your submision must contain at least two files (but can contain multiple files with unit tests, if you want): LinkedList.py as well as at least one file with unit tests using the unittest standard library from python. We will run test discovery on the files you submit (i.e., the same as python -m unittest does), so ensure the test you submit are named test_something.py and contain classes named TestSomething inheriting from unittest.TestCase with member functions named test_something() for each test case. You can split your tests across multiple files, or put all in one file.

Example solution

The following is an example solution NOT solving the problem (it only tests one thing). If you submit this file with a file name matching test_*.py together with LinkedList.py from the attachments, you will pass the first test case (your own submitted tests), but fail on the next test case where we start running our test suite on your code (as LinkedList.py from the attachments is not a correct implementation).

import unittest

from LinkedList import LinkedList

class TestExample(unittest.TestCase):
    def test_emptyListHasSize0(self):
        list = LinkedList()
        self.assertEqual(list.size(), 0)

Please log in to submit a solution to this problem

Log in