Skip to content

Commit

Permalink
updated version and added some more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FourierTransformer committed Oct 21, 2016
1 parent 16c078c commit 75d533a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ftcsv-1.1.0-1.rockspec → ftcsv-1.1.1-1.rockspec
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion ftcsv.lua
Original file line number Diff line number Diff line change
@@ -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 = [[
Expand Down
33 changes: 33 additions & 0 deletions spec/feature_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 75d533a

Please sign in to comment.