@@ -0,0 +1,3657 @@
+# A generic test template for the Python solutions to the linked list problems.%0A#%0A# The testee function is recommended to be defined inside the %22solution%22 module.%0A#%0A%0Aimport sys%0Aimport LinkedList%0Aimport solution%0A%0AFP_RATIO_PREC = 2%0A# The number of digits of precision in the values representing %0A# the passed/failed ratio to the total number of tests.%0A%0Adef TestMain(sol, log=sys.stdout, doNotLogPassed=True) -%3E bool:%0A    %22%22%22%0A    @param sol:             the function to be tested.%0A    @param log:             a stream or a file to log the tester output to.%0A    @param doNotLogPassed:  if True, all successful tests will not be logged.%0A    @return:                True if all tests in the TESTS array were successful, False otherwise.%0A%0A    All tester functions should follow the signature%0A    of the TestMain function.%0A    %22%22%22%0A  %0A    def TestPredefined(sol, log, doNotLogPassed=True) -%3E bool:%0A        class ArgsExpectedPairCollection:%0A            def __init__(self, count=60, minVal=0, maxVal=1073741823):%0A                self.count  = count%0A                self.minVal = minVal%0A                self.maxVal = maxVal%0A                %0A            def __len__(self):%0A                return self.count%0A%0A            def __iter__(self):%0A                import random%0A%0A                for _ in range(self.count):%0A%0A                    leftVal    = random.randint(self.minVal, self.maxVal)%0A                    rightVal   = random.randint(self.minVal, self.maxVal)%0A                    resultVal  = leftVal + rightVal%0A%0A                    leftHead   = LinkedList.ConvertArrayToLinkedList(map(int, str(leftVal)))%0A                    rightHead  = LinkedList.ConvertArrayToLinkedList(map(int, str(rightVal)))%0A                    resultHead = LinkedList.ConvertArrayToLinkedList(map(int, str(resultVal)))%0A%0A                    yield ((leftHead, rightHead, ), resultHead, )%0A        %0A        ARGS_EXPECTED_PAIRS = ArgsExpectedPairCollection()%0A%0A        areAllPassed = True%0A        failedCount  = 0%0A        passedCount  = 0%0A%0A        for testId, argsExpectedPair in enumerate(ARGS_EXPECTED_PAIRS):%0A            args, expected = argsExpectedPair%0A            actual         = sol(*args)%0A            isPassed       = LinkedList.Equals(expected, actual)%0A            %0A            if not(isPassed and doNotLogPassed):%0A                print('Test #%7B%7D'.format(testId),                             file=log)%0A                print('Args: (%7B%7D)'.format(', '.join(map(str, args))),        file=log)%0A                print('Expected: %7B%7D'.format(expected),                       file=log)%0A                print('Actual: %7B%7D'.format(actual),                           file=log)%0A                print('%7B%7D'.format('OK' if expected == actual else 'FAILED'), file=log)%0A                print(                                                       file=log)%0A            %0A            if not isPassed:%0A                failedCount  += 1%0A                areAllPassed  = False%0A            else:%0A                passedCount  += 1%0A        %0A        passedRatio = passedCount / len(ARGS_EXPECTED_PAIRS)%0A        failedRatio = failedCount / len(ARGS_EXPECTED_PAIRS)%0A%0A        print('Passed: %7B%7D, %25%7B:.%7Bprec%7Df%7D'.format(passedCount, 100.0 * passedRatio, prec=FP_RATIO_PREC), file=log)%0A        print('Failed: %7B%7D, %25%7B:.%7Bprec%7Df%7D'.format(failedCount, 100.0 * failedRatio, prec=FP_RATIO_PREC), file=log)%0A%0A        return areAllPassed    %0A%0A    # Please add all tester functions to the TESTS tuple.%0A    TESTS        = (TestPredefined, )%0A    areAllPassed = True%0A%0A    for Test in TESTS:%0A        if not Test(sol, log):%0A            areAllPassed = False%0A%0A    return areAllPassed%0A%0Aif __name__ == '__main__':%0A    TestMain(solution.AddTwo)%0A

Create tests.py