updated version and added some more unit tests

This commit is contained in:
FourierTransformer 2016-10-20 22:56:26 -05:00
parent 3ba34b333a
commit e218fb0a75
3 changed files with 36 additions and 3 deletions

View File

@ -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 = {

View File

@ -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 = [[

View File

@ -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)