Esempio n. 1
0
 def test_interleave(self):
     self.assertEqual(interleave([1,2],[3,4]), [1,3,2,4])
     self.assertEqual(interleave([1,2],[3,4,5]), [1,3,2,4,5])
     self.assertEqual(interleave([1,2],[3,4,5,6]), [1,3,2,4,5,6])
     self.assertEqual(interleave(['a','b','c'],[3,4]), ['a',3,'b',4,'c'])
     self.assertEqual(interleave([1],[3]), [1,3])
     self.assertEqual(interleave([1,2],[]), [1,2])
     self.assertEqual(interleave(['Aqua','Start up'],[1,2]), ['Aqua',1,'Start up',2])
     self.assertEqual(interleave([1,2],['Aqua','Start up']), [1,'Aqua',2,'Start up'])
     self.assertEqual(interleave([1],[2,3,4,5,6,7,8,9]), [1,2,3,4,5,6,7,8,9])
     self.assertEqual(interleave([],[]), [])
Esempio n. 2
0
 def test_interleave(self):
     self.assertEqual(interleave([1, 2], [3, 4]), [1, 3, 2, 4])
     self.assertEqual(interleave([1, 2], [3, 4, 5]), [1, 3, 2, 4, 5])
     self.assertEqual(interleave([1, 2], [3, 4, 5, 6]), [1, 3, 2, 4, 5, 6])
     self.assertEqual(interleave(['a', 'b', 'c'], [3, 4]),
                      ['a', 3, 'b', 4, 'c'])
     self.assertEqual(interleave([1], [3]), [1, 3])
     self.assertEqual(interleave([1, 2], []), [1, 2])
     self.assertEqual(interleave(['Aqua', 'Start up'], [1, 2]),
                      ['Aqua', 1, 'Start up', 2])
     self.assertEqual(interleave([1, 2], ['Aqua', 'Start up']),
                      [1, 'Aqua', 2, 'Start up'])
     self.assertEqual(interleave([1], [2, 3, 4, 5, 6, 7, 8, 9]),
                      [1, 2, 3, 4, 5, 6, 7, 8, 9])
     self.assertEqual(interleave([], []), [])
Esempio n. 3
0
 def test_interleave(self):
     self.assertEqual(["a", 1, "b", 2, True, None], interleave(["a", "b"], [1, 2, True, None]))
     self.assertEqual([1, "a", 2, "b", True, None], interleave([1, 2, True, None], ["a", "b"]))
     self.assertEqual([None], interleave([None], []))
     self.assertEqual(["H", 4, "E", 5, "L", 6, "L", 7, "O"], interleave(["H", "E", "L", "L", "O"], [4, 5, 6, 7]))
     self.assertEqual([1, 0, 1, 0, 1, 0], interleave([1, 1, 1], [0, 0, 0]))
     self.assertEqual([None, True, False, len, True, [], {}, ()], interleave([None, False, True, [], {}, ()], [True, len]))
     self.assertEqual([0, 4, 1, 5, 2, 6, 3, 7], interleave([0, 1, 2, 3], [4, 5, 6, 7]))
     self.assertEqual([], interleave([], []))
 def test_interleave( self ):
     self.assertEqual( [], interleave( [], [] ) )
     self.assertEqual( [ 1, 'a', [ 1, 'a' ], ( 1, 'a' ) ], interleave( [ 1, 'a', [ 1, 'a' ], ( 1, 'a' ) ], [] ) )
     self.assertEqual( [ 1, 'a', [ 1, 'a' ], ( 1, 'a' ) ], interleave( [], [ 1, 'a', [ 1, 'a' ], ( 1, 'a' ) ] ) )
     self.assertEqual( [ 0, 1, 2, 3, 4, 5, 6, 7 ], interleave( [ 0, 2, 4, 6 ], [ 1, 3, 5, 7 ] ) )
     self.assertEqual( [ 'a', 1, 'b', 2, True, None ], interleave( [ 'a', 'b' ], [ 1, 2, True, None ] ) )
     self.assertEqual( [ 1, 'a', 2, 'b', True, None ], interleave( [ 1, 2, True, None ], [ 'a', 'b' ] ) )
    def test_interleave(self) :
        # List 1 length > List 2 length
        list1 = ["a", None, "b"]
        list2 = [1, True]
        self.assertEqual(["a", 1, None, True, "b"], interleave(list1, list2))

        # List 1 empty
        list1 = []
        self.assertEqual([1, True], interleave(list1, list2))

        # List 2 empty
        list1 = ["a", None, "b"]
        list2 = []
        self.assertEqual(["a", None, "b"], interleave(list1, list2))

        # List 1 length == List 2 length
        list1 = ["a", None]
        list2 = [1, True]
        self.assertEqual(["a", 1, None, True], interleave(list1, list2))

        # List 1 length < List 2 length
        list1 = [None]
        list2 = [1, True]
        self.assertEqual([None, 1, True], interleave(list1, list2))

        # List 1 == List 2
        list1 = [None, 1, "a", False]
        list2 = [None, 1, "a", False]
        self.assertEqual([None, None, 1, 1, "a", "a", False, False], interleave(list1, list2))
 def test_interleave(self):
     self.assertEqual([], interleave([], []))
     self.assertEqual([1, 'a', [1, 'a'], (1, 'a')],
                      interleave([1, 'a', [1, 'a'], (1, 'a')], []))
     self.assertEqual([1, 'a', [1, 'a'], (1, 'a')],
                      interleave([], [1, 'a', [1, 'a'], (1, 'a')]))
     self.assertEqual([0, 1, 2, 3, 4, 5, 6, 7],
                      interleave([0, 2, 4, 6], [1, 3, 5, 7]))
     self.assertEqual(['a', 1, 'b', 2, True, None],
                      interleave(['a', 'b'], [1, 2, True, None]))
     self.assertEqual([1, 'a', 2, 'b', True, None],
                      interleave([1, 2, True, None], ['a', 'b']))