# HG changeset patch # User Matthew Wild # Date 1257006522 0 # Node ID 29e532c213f7096751c15ab37a108c52f67e137a # Parent fc93ff84350dfc9277392160dd517627b7bf436a Add tests diff -r fc93ff84350d -r 29e532c213f7 test_data.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test_data.lua Sat Oct 31 16:28:42 2009 +0000 @@ -0,0 +1,7 @@ +data = { + { "one", "two", "three", "four", "five" }; + { "one", "", "three", "four", "five" }; + { "one\t", "two", "three", "four", "five" }; + { "one\t", "two", "three", "four", "five" }; + { "one\\", "two", "three", "four", "five" }; + } diff -r fc93ff84350d -r 29e532c213f7 test_data.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test_data.tsv Sat Oct 31 16:28:42 2009 +0000 @@ -0,0 +1,5 @@ +one two three four five +one three four five +one\t two three four five +one\ two three four five +one\\ two three four five diff -r fc93ff84350d -r 29e532c213f7 test_tsv.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test_tsv.lua Sat Oct 31 16:28:42 2009 +0000 @@ -0,0 +1,19 @@ +dofile "test_data.lua" + +local tsv = require "tsv" + +local row = 0; +for line in io.lines("test_data.tsv") do + row = row + 1; + local col = 0; + tsv.read_record(line, function (v) + col = col + 1; + if data[row][col] ~= v then + print(("MISMATCH at row %d, column %d: %s is not %s") + :format(row, col, v, tostring(data[row][col]))) + bad = true; + end + end); +end + +os.exit(bad and 1 or 0);