@@ -71,6 +71,24 @@ def test_line(self):
7171 self .challenge .lines = ['one' , 'two' , 'three' ]
7272 self .assertEqual (self .challenge .line (1 ), 'two' )
7373
74+ def test_line_to_permuation (self ):
75+ """Show a line can be retrieved as permutation."""
76+ self .challenge .lines = ['one' , '+1 -2' ]
77+ result = self .challenge .line_to_permutation (1 )
78+ self .assertEqual (result , [1 , - 2 ])
79+
80+ def test_line_to_permuation_with_parenthesis (self ):
81+ """Show a line can be retrieved as permutation."""
82+ self .challenge .lines = ['one' , '(+1 -2)' ]
83+ result = self .challenge .line_to_permutation (1 )
84+ self .assertEqual (result , [1 , - 2 ])
85+
86+ def test_line_to_permuation_surrounded_with_terminals (self ):
87+ """Show a line can be retrieved as permutation."""
88+ self .challenge .lines = ['one' , '+1 -2' ]
89+ result = self .challenge .line_to_permutation (1 )
90+ self .assertEqual (result , [1 , - 2 ])
91+
7492 def test_line_to_integers (self ):
7593 """Show a line can be retrieved as integers."""
7694 self .challenge .lines = ['one' , '1, 2, 3' ]
@@ -260,3 +278,10 @@ def test_format_path(self):
260278 self .assertEqual (result , '11->22->33' )
261279 result = self .challenge .format_path ([11 , 22 , 33 ], backwards = True )
262280 self .assertEqual (result , '11<-22<-33' )
281+
282+ def test_format_permuations (self ):
283+ """Show a list of permuations can be formatted."""
284+ list = [[1 , - 2 ], [- 3 , 4 ]]
285+ actual = self .challenge .format_permutations (list )
286+ expect = '(+1 -2)\n (-3 +4)'
287+ self .assertEqual (expect , actual )
0 commit comments