-
Notifications
You must be signed in to change notification settings - Fork 0
/
tdd_nesting_structure_comparison.py
26 lines (19 loc) · 1.28 KB
/
tdd_nesting_structure_comparison.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import unittest
import nesting_structure_comparison
class TestFunctions(unittest.TestCase):
def test_longest_consec(self):
#check true
self.assertTrue(nesting_structure_comparison.same_structure_as([ 1, 1, 1 ], [ 2, 2, 2 ] ))
self.assertTrue(nesting_structure_comparison.same_structure_as([ 1, [ 1, 1 ] ], [ 2, [ 2, 2 ] ]))
self.assertTrue(nesting_structure_comparison.same_structure_as([ [ [ ], [ ] ] ], [ [ [ ], [ ] ] ]))
self.assertTrue(nesting_structure_comparison.same_structure_as([1,[[[1]]]],[2,[[[2]]]]))
self.assertTrue(nesting_structure_comparison.same_structure_as([1,'[',']'],['[',']',1]))
#check false
self.assertFalse(nesting_structure_comparison.same_structure_as([ 1, [ 1, 1 ] ], [ [ 2, 2 ], 2 ]))
self.assertFalse(nesting_structure_comparison.same_structure_as([ 1, [ 1, 1 ] ], [ [ 2 ], 2 ]))
self.assertFalse(nesting_structure_comparison.same_structure_as([ [ [ ], [ ] ] ], [ [ 1, 1 ] ]))
self.assertFalse(nesting_structure_comparison.same_structure_as([],1))
self.assertFalse(nesting_structure_comparison.same_structure_as([],{}))
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TestFunctions)
unittest.TextTestRunner(verbosity=2).run(suite)