diff options
author | Vincent Driessen <vincent@datafox.nl> | 2010-08-19 11:36:53 +0200 |
---|---|---|
committer | Vincent Driessen <vincent@datafox.nl> | 2010-08-19 11:38:50 +0200 |
commit | 4c81fb1df579143bdd1ec7f5b2a1779d3c3c58fd (patch) | |
tree | 17d7130e5bcd0b045fd536da56711faf8bf65862 /tests | |
parent | c72ce15d5941aaa3384a1a160996b0c92ec0efef (diff) | |
download | vim-rst-tables-4c81fb1df579143bdd1ec7f5b2a1779d3c3c58fd.tar.gz vim-rst-tables-4c81fb1df579143bdd1ec7f5b2a1779d3c3c58fd.tar.bz2 vim-rst-tables-4c81fb1df579143bdd1ec7f5b2a1779d3c3c58fd.zip |
Add join_rows helper function (necessary for joining long lines later on).
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_rst_tables.py | 30 |
1 files changed, 29 insertions, 1 deletions
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))) |