-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed a bug with parseLine and started writing unit tests
- Loading branch information
1 parent
06c5cd8
commit 549d780
Showing
2 changed files
with
63 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
local ftcsv = require('ftcsv') | ||
local cjson = require('cjson') | ||
|
||
local function loadFile(textFile) | ||
local file = io.open(textFile, "r") | ||
if not file then error("File not found at " .. textFile) end | ||
local allLines = file:read("*all") | ||
file:close() | ||
return allLines | ||
end | ||
|
||
describe("parseLine features", function() | ||
for i = 52, 52 do | ||
it("should handle correctness" .. i, function() | ||
local json = loadFile("spec/json/correctness.json") | ||
json = cjson.decode(json) | ||
local parse = {} | ||
for i, line in ftcsv.parseLine("spec/csvs/correctness.csv", ",", i) do | ||
assert.are.same(json[i], line) | ||
parse[i] = line | ||
end | ||
assert.are.same(#json, #parse) | ||
assert.are.same(json, parse) | ||
end) | ||
end | ||
end) |