diff options
author | Vincent Driessen <vincent@datafox.nl> | 2010-08-19 12:21:08 +0200 |
---|---|---|
committer | Vincent Driessen <vincent@datafox.nl> | 2010-08-19 12:21:08 +0200 |
commit | f84c47622786b654f2dfbe2e6d79b7f269a91a06 (patch) | |
tree | b1a767c97440e291487cffd0c0bf17a0410be212 /tests | |
parent | 81c52547b08e24b2be35ddca47167527e958fa6e (diff) | |
download | vim-rst-tables-f84c47622786b654f2dfbe2e6d79b7f269a91a06.tar.gz vim-rst-tables-f84c47622786b654f2dfbe2e6d79b7f269a91a06.tar.bz2 vim-rst-tables-f84c47622786b654f2dfbe2e6d79b7f269a91a06.zip |
Add line partitioner.
Is able to parse tables of the form:
+=====+=====================+
| Foo | Bar |
+=====+=====================+
| x | This is a long line |
| | that is spread out |
| | over multiple lines |
+-----+---------------------+
Into:
[['Foo', 'Bar'], ['x', 'This is a long line\nthat is spread out\nover multiple lines']]
The draw_table function needs to be written still, though.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_rst_tables.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/tests/test_rst_tables.py b/tests/test_rst_tables.py index 0f1f354..381adf8 100644 --- a/tests/test_rst_tables.py +++ b/tests/test_rst_tables.py @@ -22,7 +22,8 @@ import unittest # Load test subjects from rst_tables import get_table_bounds, reformat_table, parse_table, \ draw_table, table_line, get_column_widths, \ - pad_fields, unify_table, join_rows + pad_fields, unify_table, join_rows, \ + partition_raw_lines class TestRSTTableFormatter(unittest.TestCase): @@ -67,6 +68,19 @@ class TestRSTTableFormatter(unittest.TestCase): expected = ['x foo apple', 'y bar', 'z pear'] self.assertEquals(expected, join_rows(input_rows, sep=' ')) + def testPartitionRawLines(self): + self.assertEquals([], partition_raw_lines([])) + self.assertEquals([['']], partition_raw_lines([''])) + self.assertEquals( + [['foo'], ['bar']], + partition_raw_lines(['foo', 'bar'])) + self.assertEquals( + [['foo'], ['bar']], + partition_raw_lines(['foo', '+----+', 'bar'])) + self.assertEquals( + [['foo', 'bar'], ['baz']], + partition_raw_lines(['+-----+', 'foo', 'bar', '----', 'baz'])) + def testParseSimpleTable(self): self.assertEquals([['x y z']], parse_table(['x y z'])) self.assertEquals([['x', 'y z']], parse_table(['x y z'])) @@ -119,8 +133,7 @@ class TestRSTTableFormatter(unittest.TestCase): 'blah | A new line| ', '+-----+----+'] expect = [['Foo', 'Mu'], - ['x', 'This became somewhat larger'], - ['blah', 'A new line']] + ['x\nblah', 'This became somewhat larger\nA new line']] self.assertEquals(expect, parse_table(input)) input = ['+===+-----====+', @@ -130,8 +143,7 @@ class TestRSTTableFormatter(unittest.TestCase): 'blah | A new line|| ', '+-----+----+'] expect = [['Foo', 'Mu'], - ['x', 'This became somewhat larger'], - ['blah', 'A new line']] + ['x\nblah', 'This became somewhat larger\nA new line']] self.assertEquals(expect, parse_table(input)) def testTableLine(self): |