summaryrefslogtreecommitdiff
path: root/test/csv/test_table.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/csv/test_table.rb')
-rwxr-xr-xtest/csv/test_table.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/csv/test_table.rb b/test/csv/test_table.rb
index d99b7d2..a5ae8e0 100755
--- a/test/csv/test_table.rb
+++ b/test/csv/test_table.rb
@@ -21,6 +21,8 @@ class TestCSV::Table < TestCSV
@header_table = CSV::Table.new(
[CSV::Row.new(%w{A B C}, %w{A B C}, true)] + @rows
)
+
+ @header_only_table = CSV::Table.new([], headers: %w{A B C})
end
def test_initialze
@@ -63,6 +65,10 @@ class TestCSV::Table < TestCSV
assert_equal Array.new, t.headers
end
+ def test_headers_only
+ assert_equal(%w[A B C], @header_only_table.headers)
+ end
+
def test_index
##################
### Mixed Mode ###
@@ -471,6 +477,21 @@ A
CSV
end
+ def test_delete_headers_only
+ ###################
+ ### Column Mode ###
+ ###################
+ @header_only_table.by_col!
+
+ # delete by index
+ assert_equal([], @header_only_table.delete(0))
+ assert_equal(%w[B C], @header_only_table.headers)
+
+ # delete by header
+ assert_equal([], @header_only_table.delete("C"))
+ assert_equal(%w[B], @header_only_table.headers)
+ end
+
def test_values_at
##################
### Mixed Mode ###