From 4c81fb1df579143bdd1ec7f5b2a1779d3c3c58fd Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Thu, 19 Aug 2010 11:36:53 +0200 Subject: Add join_rows helper function (necessary for joining long lines later on). --- tests/test_rst_tables.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_rst_tables.py b/tests/test_rst_tables.py index f57761f..6c486dd 100644 --- a/tests/test_rst_tables.py +++ b/tests/test_rst_tables.py @@ -22,7 +22,7 @@ import unittest # Load test subjects from rst_tables import get_table_bounds, create_table, parse_table, \ draw_table, table_line, get_column_widths, \ - pad_fields, unify_table + pad_fields, unify_table, join_rows class TestRSTTableFormatter(unittest.TestCase): @@ -58,6 +58,15 @@ class TestRSTTableFormatter(unittest.TestCase): vim.current.window.cursor = (8, 0) self.assertEquals((8, 9), get_table_bounds()) + def testJoinSimpleRows(self): + input_rows = [['x', 'y', 'z'], ['foo', 'bar']] + expected = ['x\nfoo', 'y\nbar', 'z'] + self.assertEquals(expected, join_rows(input_rows)) + + input_rows.append(['apple', '', 'pear']) + expected = ['x foo apple', 'y bar', 'z pear'] + self.assertEquals(expected, join_rows(input_rows, sep=' ')) + def testParseSimpleTable(self): self.assertEquals([['x y z']], parse_table(['x y z'])) self.assertEquals([['x', 'y z']], parse_table(['x y z'])) @@ -191,3 +200,22 @@ a line ending. """.split('\n') create_table() self.assertEquals(expect, vim.current.buffer) + + def notestCreateComplexTable(self): + raw_lines = self.read_fixture('multiline-cells') + expect = """ ++================+===============================================================+ +| Feature | Description | ++================+===============================================================+ +| Ease of use | Drop dead simple! | ++----------------+---------------------------------------------------------------+ +| Foo | Bar, qux, mux | ++----------------+---------------------------------------------------------------+ +| Predictability | Lorem ipsum dolor sit amet, consectetur adipiscing elit. | ++----------------+---------------------------------------------------------------+ +| | Nullam congue dapibus aliquet. Integer ut rhoncus leo. In hac | ++----------------+---------------------------------------------------------------+ +| | habitasse platea dictumst. Phasellus pretium iaculis. | ++----------------+---------------------------------------------------------------+ +""".strip().split('\n') + self.assertEquals(expect, draw_table(parse_table(raw_lines))) -- cgit v1.2.3