Skip to content

Commit e218fb0

Browse files
updated version and added some more unit tests
1 parent 3ba34b3 commit e218fb0

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

ftcsv-1.1.0-1.rockspec renamed to ftcsv-1.1.1-1.rockspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package = "ftcsv"
2-
version = "1.1.0-1"
2+
version = "1.1.1-1"
33

44
source = {
55
url = "git://github.com/FourierTransformer/ftcsv.git",
6-
tag = "1.1.0"
6+
tag = "1.1.1"
77
}
88

99
description = {

ftcsv.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local ftcsv = {
2-
_VERSION = 'ftcsv 1.1.0',
2+
_VERSION = 'ftcsv 1.1.1',
33
_DESCRIPTION = 'CSV library for Lua',
44
_URL = 'https://github.com/FourierTransformer/ftcsv',
55
_LICENSE = [[

spec/feature_spec.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,37 @@ describe("csv features", function()
163163
assert.are.same(expected, actual)
164164
end)
165165

166+
it("should handle encoding files", function()
167+
local expected = {}
168+
expected[1] = {}
169+
expected[1].A = "apple"
170+
expected[1].B = "banana"
171+
expected[1].C = "carrot"
172+
local actual = ftcsv.parse(ftcsv.encode(expected, ","), ",", {loadFromString=true})
173+
local expected = ftcsv.parse("A,B,C\napple,banana,carrot", ",", {loadFromString=true})
174+
assert.are.same(expected, actual)
175+
end)
176+
177+
it("should handle encoding files with odd delimiters", function()
178+
local expected = {}
179+
expected[1] = {}
180+
expected[1].A = "apple"
181+
expected[1].B = "banana"
182+
expected[1].C = "carrot"
183+
local actual = ftcsv.parse(ftcsv.encode(expected, ">"), ">", {loadFromString=true})
184+
local expected = ftcsv.parse("A,B,C\napple,banana,carrot", ",", {loadFromString=true})
185+
assert.are.same(expected, actual)
186+
end)
187+
188+
it("should handle encoding files with only certain fields to keep", function()
189+
local expected = {}
190+
expected[1] = {}
191+
expected[1].A = "apple"
192+
expected[1].B = "banana"
193+
expected[1].C = "carrot"
194+
local actual = ftcsv.parse(ftcsv.encode(expected, ",", {fieldsToKeep={"A", "B"}}), ",", {loadFromString=true})
195+
local expected = ftcsv.parse("A,B\napple,banana", ",", {loadFromString=true})
196+
assert.are.same(expected, actual)
197+
end)
198+
166199
end)

0 commit comments

Comments
 (0)