コード例 #1
0
class QueueLinkedListTest(unittest.TestCase):
    def setUp(self):
        self.queue = QueueLinkedList()

    def test_all(self):
        for i in range(1, 11):
            self.queue.enqueue(i)

        self.assertEqual('1,2,3,4,5,6,7,8,9,10', self.queue.toString())

        for i in range(1, 11):
            self.assertEqual(i, self.queue.dequeue())
        
        self.assertIsNone(self.queue.dequeue())
コード例 #2
0
 def setUp(self):
     self.queue = QueueLinkedList()
コード例 #3
0
class TestQueue(unittest.TestCase):
    
    def setUp(self):
        self.queue = QueueLinkedList()
        
    def tearDown(self):
        self.queue = None
        
    def test_basic(self):
        """Basic test."""
        self.assertEqual(0, len(self.queue))
        self.assertTrue(self.queue.isEmpty())
        self.queue.append(99)
        self.assertEqual(1, len(self.queue))
        self.queue.append(30)
        self.assertEqual(99, self.queue.pop())
        self.assertEqual(30, self.queue.pop())

    def test_queue(self):
        """Three Elements."""
        self.assertEqual(0, len(self.queue))
        self.assertTrue(self.queue.isEmpty())
        self.queue.append(99)
        self.assertEqual(1, len(self.queue))
        self.queue.append(30)
        self.assertEqual(2, len(self.queue))
        self.assertEqual(99, self.queue.pop())
        self.assertEqual(1, len(self.queue))
        self.queue.append(15)
        self.assertEqual(2, len(self.queue))
        self.assertEqual(30, self.queue.pop())
        self.assertEqual(15, self.queue.pop())

    def test_iterators(self):
        """Iterators"""
        self.queue.append(99)
        self.assertEqual(1, len(self.queue))
        self.queue.append(30)
        self.assertTrue(30 in self.queue)
        self.assertFalse(15 in self.queue)
コード例 #4
0
 def setUp(self):
     self.queue = QueueLinkedList()
コード例 #5
0
class TestQueue(unittest.TestCase):
    def setUp(self):
        self.queue = QueueLinkedList()

    def tearDown(self):
        self.queue = None

    def test_basic(self):
        """Basic test."""
        self.assertEqual(0, len(self.queue))
        self.assertTrue(self.queue.isEmpty())
        self.queue.append(99)
        self.assertEqual(1, len(self.queue))
        self.queue.append(30)
        self.assertEqual(99, self.queue.pop())
        self.assertEqual(30, self.queue.pop())

    def test_queue(self):
        """Three Elements."""
        self.assertEqual(0, len(self.queue))
        self.assertTrue(self.queue.isEmpty())
        self.queue.append(99)
        self.assertEqual(1, len(self.queue))
        self.queue.append(30)
        self.assertEqual(2, len(self.queue))
        self.assertEqual(99, self.queue.pop())
        self.assertEqual(1, len(self.queue))
        self.queue.append(15)
        self.assertEqual(2, len(self.queue))
        self.assertEqual(30, self.queue.pop())
        self.assertEqual(15, self.queue.pop())

    def test_iterators(self):
        """Iterators"""
        self.queue.append(99)
        self.assertEqual(1, len(self.queue))
        self.queue.append(30)
        self.assertTrue(30 in self.queue)
        self.assertFalse(15 in self.queue)