예제 #1
0
 def test_input_lines_that_do_not_fit_on_single_output_line(self):
     # ARRANGE #
     wrapper = sut.Wrapper(page_width=5)
     # ACT #
     lines = wrapper.no_word_wrap(['123 567', 'abc efg'])
     # ASSERT #
     self.assertEqual(['123 5', '67', 'abc e', 'fg'], lines)
예제 #2
0
 def test_empty_lines(self):
     # ARRANGE #
     wrapper = sut.Wrapper(page_width=5)
     # ACT #
     lines = wrapper.no_word_wrap(['', ''])
     # ASSERT #
     self.assertEqual(['', ''], lines)
예제 #3
0
 def test_input_lines_that_all_fit_on_single_output_line(self):
     # ARRANGE #
     wrapper = sut.Wrapper(page_width=5)
     # ACT #
     lines = wrapper.no_word_wrap(['12', '', 'ab'])
     # ASSERT #
     self.assertEqual(['12', '', 'ab'], lines)
예제 #4
0
 def test_push_indent(self):
     wrapper = sut.Wrapper()
     indent = sut.Indent('first line', 'following lines')
     wrapper.push_indent(indent)
     _check_current_indent(self, wrapper, indent)
     self.assertEqual([sut.Indent('', '')], wrapper.saved_indents_stack,
                      'Saved indent stack')
예제 #5
0
 def test_indentation_when_all_input_lines_fit_on_single_output_line(self):
     # ARRANGE #
     wrapper = sut.Wrapper(page_width=5)
     indent = sut.Indent('>', '>>')
     wrapper.push_indent(indent)
     # ACT #
     lines = wrapper.no_word_wrap(['fst', 'snd'])
     # ASSERT #
     self.assertEqual(['>fst', '>>snd'], lines)
예제 #6
0
 def test_pop_indent(self):
     wrapper = sut.Wrapper()
     indent1 = sut.Indent('a1', 'a2')
     wrapper.push_indent(indent1)
     wrapper.push_indent(sut.Indent('b1', 'b2'))
     wrapper.pop_indent()
     _check_current_indent(self, wrapper, indent1)
     self.assertEqual([sut.Indent('', '')], wrapper.saved_indents_stack,
                      'Saved indent1 stack')
예제 #7
0
 def test_indentation_when_first_input_line_do_not_fit_on_single_output_line(
         self):
     # ARRANGE #
     wrapper = sut.Wrapper(page_width=5)
     indent = sut.Indent('>', '>>')
     wrapper.push_indent(indent)
     # ACT #
     lines = wrapper.no_word_wrap(['2345678'])
     # ASSERT #
     self.assertEqual(['>2345', '>>678'], lines)
예제 #8
0
    def test_push_indent_increase(self):
        wrapper = sut.Wrapper()
        first_indent = sut.Indent('a1', 'a2')
        delta = sut.Indent('b1', 'b2')
        wrapper.push_indent(first_indent)
        wrapper.push_indent_increase(delta)

        sum_indent = sut.Indent(
            first_indent.first_line + delta.first_line,
            first_indent.following_lines + delta.following_lines)

        _check_current_indent(self, wrapper, sum_indent)
        self.assertEqual([first_indent, sut.Indent('', '')],
                         wrapper.saved_indents_stack,
                         'Saved first_indent stack')
예제 #9
0
 def test(self):
     wrapper = sut.Wrapper(page_width=100)
     with wrapper.indent_increase(sut.Indent.identical('[INDENT]')):
         lines = wrapper.wrap('text')
     self.assertEqual(['[INDENT]text'], lines, 'Resulting lines')
     _check_indent(self, wrapper, sut.Indent.identical(''), [])
예제 #10
0
 def test_construction(self):
     wrapper = sut.Wrapper(page_width=10)
     self.assertEqual(10, wrapper.text_wrapper.width)
     _check_current_indent(self, wrapper, sut.Indent('', ''))
     self.assertFalse(wrapper.saved_indents_stack, 'Saved indent stack')