Beispiel #1
0
 def setUp(self):
     self.linkedList = LinkedListCreator()
     self.linkedList.setArray([1, 2, 3])
     self.linkedList1 = self.linkedList.getLinkedList()
     self.linkedList.setArray([3, 4, 5])
     self.linkedList2 = self.linkedList.getLinkedList()
     self.addLinkedList = AddLinkedList()
     self.addLinkedList.setList1(self.linkedList1)
     self.addLinkedList.setList2(self.linkedList2)
     self.linkedList.setArray([8, 6, 4])
     self.sumList = self.addLinkedList.getSumList()
Beispiel #2
0
 def numToList(self,num):
     retList=[]
     currentNum=int()
     while True:
         currentNum=num%10
         num=num/10
         if currentNum==0 and num==0:
             break
         else:
             retList.append(currentNum)
     linkedList=LinkedListCreator()
     linkedList.setArray(retList)
     return linkedList.getLinkedList()
Beispiel #3
0
 def numToList(self, num):
     retList = []
     currentNum = int()
     while True:
         currentNum = num % 10
         num = num / 10
         if currentNum == 0 and num == 0:
             break
         else:
             retList.append(currentNum)
     linkedList = LinkedListCreator()
     linkedList.setArray(retList)
     return linkedList.getLinkedList()
Beispiel #4
0
 def setUp(self):
     self.linkedList=LinkedListCreator()
     self.linkedList.setArray([1,2,3])
     self.linkedList1=self.linkedList.getLinkedList()
     self.linkedList.setArray([3,4,5])
     self.linkedList2=self.linkedList.getLinkedList()
     self.addLinkedList=AddLinkedList()
     self.addLinkedList.setList1(self.linkedList1)
     self.addLinkedList.setList2(self.linkedList2)
     self.linkedList.setArray([8,6,4])
     self.sumList=self.addLinkedList.getSumList()
Beispiel #5
0
class TestSum(unittest.TestCase):
    def setUp(self):
        self.linkedList=LinkedListCreator()
        self.linkedList.setArray([1,2,3])
        self.linkedList1=self.linkedList.getLinkedList()
        self.linkedList.setArray([3,4,5])
        self.linkedList2=self.linkedList.getLinkedList()
        self.addLinkedList=AddLinkedList()
        self.addLinkedList.setList1(self.linkedList1)
        self.addLinkedList.setList2(self.linkedList2)
        self.linkedList.setArray([8,6,4])
        self.sumList=self.addLinkedList.getSumList()

    def testSum(self):
        self.assertEqual(self.sumList.getValue(),4)
        self.assertEqual(self.sumList.getNext().getValue(),6)
        self.assertEqual(self.sumList.getNext().getNext().getValue(),8)
Beispiel #6
0
class TestSum(unittest.TestCase):
    def setUp(self):
        self.linkedList = LinkedListCreator()
        self.linkedList.setArray([1, 2, 3])
        self.linkedList1 = self.linkedList.getLinkedList()
        self.linkedList.setArray([3, 4, 5])
        self.linkedList2 = self.linkedList.getLinkedList()
        self.addLinkedList = AddLinkedList()
        self.addLinkedList.setList1(self.linkedList1)
        self.addLinkedList.setList2(self.linkedList2)
        self.linkedList.setArray([8, 6, 4])
        self.sumList = self.addLinkedList.getSumList()

    def testSum(self):
        self.assertEqual(self.sumList.getValue(), 4)
        self.assertEqual(self.sumList.getNext().getValue(), 6)
        self.assertEqual(self.sumList.getNext().getNext().getValue(), 8)