diff --git a/ftcsv-1.1.0-1.rockspec b/ftcsv-1.1.1-1.rockspec similarity index 95% rename from ftcsv-1.1.0-1.rockspec rename to ftcsv-1.1.1-1.rockspec index 8d319ad..235e058 100644 --- a/ftcsv-1.1.0-1.rockspec +++ b/ftcsv-1.1.1-1.rockspec @@ -1,9 +1,9 @@ package = "ftcsv" -version = "1.1.0-1" +version = "1.1.1-1" source = { url = "git://github.com/FourierTransformer/ftcsv.git", - tag = "1.1.0" + tag = "1.1.1" } description = { diff --git a/ftcsv.lua b/ftcsv.lua index 6973447..c9ef444 100644 --- a/ftcsv.lua +++ b/ftcsv.lua @@ -1,5 +1,5 @@ local ftcsv = { - _VERSION = 'ftcsv 1.1.0', + _VERSION = 'ftcsv 1.1.1', _DESCRIPTION = 'CSV library for Lua', _URL = 'https://github.com/FourierTransformer/ftcsv', _LICENSE = [[ diff --git a/spec/feature_spec.lua b/spec/feature_spec.lua index e7567e4..3810f0a 100644 --- a/spec/feature_spec.lua +++ b/spec/feature_spec.lua @@ -163,4 +163,37 @@ describe("csv features", function() assert.are.same(expected, actual) end) + it("should handle encoding files", function() + local expected = {} + expected[1] = {} + expected[1].A = "apple" + expected[1].B = "banana" + expected[1].C = "carrot" + local actual = ftcsv.parse(ftcsv.encode(expected, ","), ",", {loadFromString=true}) + local expected = ftcsv.parse("A,B,C\napple,banana,carrot", ",", {loadFromString=true}) + assert.are.same(expected, actual) + end) + + it("should handle encoding files with odd delimiters", function() + local expected = {} + expected[1] = {} + expected[1].A = "apple" + expected[1].B = "banana" + expected[1].C = "carrot" + local actual = ftcsv.parse(ftcsv.encode(expected, ">"), ">", {loadFromString=true}) + local expected = ftcsv.parse("A,B,C\napple,banana,carrot", ",", {loadFromString=true}) + assert.are.same(expected, actual) + end) + + it("should handle encoding files with only certain fields to keep", function() + local expected = {} + expected[1] = {} + expected[1].A = "apple" + expected[1].B = "banana" + expected[1].C = "carrot" + local actual = ftcsv.parse(ftcsv.encode(expected, ",", {fieldsToKeep={"A", "B"}}), ",", {loadFromString=true}) + local expected = ftcsv.parse("A,B\napple,banana", ",", {loadFromString=true}) + assert.are.same(expected, actual) + end) + end) \ No newline at end of file