mirror of
https://github.com/geoffleyland/lua-csv.git
synced 2024-11-23 01:34:19 +00:00
test.lua: add an exclamation mark to the end of newlines so that they're explicit
This commit is contained in:
parent
deac119c13
commit
c40e12bb7c
22
lua/test.lua
22
lua/test.lua
@ -17,13 +17,13 @@ local function testhandle(handle, correct_result)
|
|||||||
|
|
||||||
handle:close()
|
handle:close()
|
||||||
|
|
||||||
result = table.concat(result, "\n")
|
result = table.concat(result, "!\n").."!"
|
||||||
if result ~= correct_result then
|
if result ~= correct_result then
|
||||||
io.stderr:write(
|
io.stderr:write(
|
||||||
("Error reading '%s':\nExpected output:\n%s\n\nActual output:\n%s\n\n"):
|
("Error reading '%s':\nExpected output:\n%s\n\nActual output:\n%s\n\n"):
|
||||||
format(handle:name(), correct_result, result))
|
format(handle:name(), correct_result, result))
|
||||||
errors = errors + 1
|
errors = errors + 1
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -46,29 +46,29 @@ test("../test-data/embedded-newlines.csv", [[
|
|||||||
embedded
|
embedded
|
||||||
newline,embedded
|
newline,embedded
|
||||||
newline,embedded
|
newline,embedded
|
||||||
newline
|
newline!
|
||||||
embedded
|
embedded
|
||||||
newline,embedded
|
newline,embedded
|
||||||
newline,embedded
|
newline,embedded
|
||||||
newline]])
|
newline!]])
|
||||||
|
|
||||||
test("../test-data/embedded-quotes.csv", [[
|
test("../test-data/embedded-quotes.csv", [[
|
||||||
embedded "quotes",embedded "quotes",embedded "quotes"
|
embedded "quotes",embedded "quotes",embedded "quotes"!
|
||||||
embedded "quotes",embedded "quotes",embedded "quotes"]])
|
embedded "quotes",embedded "quotes",embedded "quotes"!]])
|
||||||
|
|
||||||
test("../test-data/header.csv", [[
|
test("../test-data/header.csv", [[
|
||||||
alpha:ONE,bravo:two,charlie:3
|
alpha:ONE,bravo:two,charlie:3!
|
||||||
alpha:four,bravo:five,charlie:6]], {header=true})
|
alpha:four,bravo:five,charlie:6!]], {header=true})
|
||||||
|
|
||||||
test("../test-data/header.csv", [[
|
test("../test-data/header.csv", [[
|
||||||
apple:one,charlie:30
|
apple:one,charlie:30!
|
||||||
apple:four,charlie:60]],
|
apple:four,charlie:60!]],
|
||||||
{ columns = {
|
{ columns = {
|
||||||
apple = { name = "ALPHA", transform = string.lower },
|
apple = { name = "ALPHA", transform = string.lower },
|
||||||
charlie = { transform = function(x) return tonumber(x) * 10 end }}})
|
charlie = { transform = function(x) return tonumber(x) * 10 end }}})
|
||||||
|
|
||||||
test("../test-data/blank-line.csv", [[
|
test("../test-data/blank-line.csv", [[
|
||||||
this,file,ends,with,a,blank,line]])
|
this,file,ends,with,a,blank,line!]])
|
||||||
|
|
||||||
|
|
||||||
if errors == 0 then
|
if errors == 0 then
|
||||||
|
Loading…
Reference in New Issue
Block a user