aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Driessen <vincent@datafox.nl>2010-08-19 10:49:51 +0200
committerVincent Driessen <vincent@datafox.nl>2010-08-19 10:49:51 +0200
commitbc3620adf956828562071f9feafc5923de567ea9 (patch)
tree317d3d80697a3982915e652e66522adde00e06e0 /tests
parent3a4e12229e09e72619dc1bcc5403db1e452d9ecb (diff)
downloadvim-rst-tables-bc3620adf956828562071f9feafc5923de567ea9.tar.gz
vim-rst-tables-bc3620adf956828562071f9feafc5923de567ea9.tar.bz2
vim-rst-tables-bc3620adf956828562071f9feafc5923de567ea9.zip
Add ability to remove all empty columns automatically.
Diffstat (limited to 'tests')
-rw-r--r--tests/fixtures/multiline-cells.txt6
-rw-r--r--tests/test_rst_tables.py18
2 files changed, 20 insertions, 4 deletions
diff --git a/tests/fixtures/multiline-cells.txt b/tests/fixtures/multiline-cells.txt
new file mode 100644
index 0000000..78465fd
--- /dev/null
+++ b/tests/fixtures/multiline-cells.txt
@@ -0,0 +1,6 @@
+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.
diff --git a/tests/test_rst_tables.py b/tests/test_rst_tables.py
index 1eb61a6..0517769 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
+ pad_fields, unify_table
class TestRSTTableFormatter(unittest.TestCase):
@@ -75,6 +75,16 @@ class TestRSTTableFormatter(unittest.TestCase):
expected = [['x', 'y', ''], ['a', 'b', 'c'], ['only one', '', '']]
self.assertEquals(expected, parse_table(input))
+ def testUnifyTables(self):
+ input = [[' x ', ' y'], ['xxx', ' yyyy ', 'zz']]
+ expected = [[' x ', ' y', ''], ['xxx', ' yyyy ', 'zz']]
+ self.assertEquals(expected, unify_table(input))
+
+ def testUnifyTablesRemovesEmptyColumns(self):
+ input = [['x', '', 'y'], ['xxx', '', 'yyyy', 'zz', ' ']]
+ expected = [['x', 'y', ''], ['xxx', 'yyyy', 'zz']]
+ self.assertEquals(expected, unify_table(input))
+
def testParseDealsWithSpacesAtLineEnd(self):
input = ['x y ', 'a b ', 'only one']
expected = [['x', 'y'], ['a', 'b'], ['only one', '']]
@@ -107,9 +117,9 @@ class TestRSTTableFormatter(unittest.TestCase):
'| x | This became somewhat larger |',
'blah | A new line|| ',
'+-----+----+']
- expect = [['Foo', 'Mu', ''],
- ['x', 'This became somewhat larger', ''],
- ['blah', 'A new line', '']]
+ expect = [['Foo', 'Mu'],
+ ['x', 'This became somewhat larger'],
+ ['blah', 'A new line']]
self.assertEquals(expect, parse_table(input))
def testTableLine(self):