mirror of
https://github.com/FourierTransformer/ftcsv.git
synced 2024-11-19 19:54:23 +00:00
updated version and added some more unit tests
This commit is contained in:
parent
3ba34b333a
commit
e218fb0a75
@ -1,9 +1,9 @@
|
|||||||
package = "ftcsv"
|
package = "ftcsv"
|
||||||
version = "1.1.0-1"
|
version = "1.1.1-1"
|
||||||
|
|
||||||
source = {
|
source = {
|
||||||
url = "git://github.com/FourierTransformer/ftcsv.git",
|
url = "git://github.com/FourierTransformer/ftcsv.git",
|
||||||
tag = "1.1.0"
|
tag = "1.1.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
description = {
|
description = {
|
@ -1,5 +1,5 @@
|
|||||||
local ftcsv = {
|
local ftcsv = {
|
||||||
_VERSION = 'ftcsv 1.1.0',
|
_VERSION = 'ftcsv 1.1.1',
|
||||||
_DESCRIPTION = 'CSV library for Lua',
|
_DESCRIPTION = 'CSV library for Lua',
|
||||||
_URL = 'https://github.com/FourierTransformer/ftcsv',
|
_URL = 'https://github.com/FourierTransformer/ftcsv',
|
||||||
_LICENSE = [[
|
_LICENSE = [[
|
||||||
|
@ -163,4 +163,37 @@ describe("csv features", function()
|
|||||||
assert.are.same(expected, actual)
|
assert.are.same(expected, actual)
|
||||||
end)
|
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)
|
end)
|
Loading…
Reference in New Issue
Block a user