• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FourierTransformer / ftcsv / 26347998376

24 May 2026 12:58AM UTC coverage: 99.01% (+0.1%) from 98.901%
26347998376

push

github

web-flow
Merge 2d58c9475 into edf705c37

1195 of 1209 new or added lines in 5 files covered. (98.84%)

1 existing line in 1 file now uncovered.

1600 of 1616 relevant lines covered (99.01%)

1129.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.67
/tests/error_test.lua
1
local ftcsv = require('ftcsv')
5✔
2
local tested = require("tested")
5✔
3

4
local files = {
5✔
5
    {"empty_file", "ftcsv: Cannot parse an empty file"},
5✔
6
    {"empty_file_newline", "ftcsv: Cannot parse a file which contains empty headers"},
5✔
7
    {"empty_header", "ftcsv: Cannot parse a file which contains empty headers"},
5✔
8
    {"too_few_cols", "ftcsv: too few columns in row 1"},
5✔
9
    {"too_few_cols_end", "ftcsv: too few columns in row 2"},
5✔
10
    {"too_many_cols", "ftcsv: too many columns in row 2"},
5✔
11
    {"dne", "ftcsv: File not found at spec/bad_csvs/dne.csv"}
5✔
12
}
4✔
13

14
tested.test("csv decode error", function()
10✔
15
    for _, value in ipairs(files) do
40✔
16
        local filename = "spec/bad_csvs/" .. value[1] .. ".csv"
35✔
17
        tested.assert_throws_exception({
70✔
18
            given=filename,
35✔
19
            should="throw specific exception",
28✔
20
            expected=value[2],
35✔
21
            actual=function() ftcsv.parse(filename, ",") end
70✔
22
        })
35✔
23
    end
24
end)
25

26
tested.test("no headers or renaming", function()
10✔
27
    local test = function()
28
        local options = {loadFromString=true, headers=false, fieldsToKeep={1, 2}}
5✔
29
        ftcsv.parse("apple>banana>carrot\ndiamond>emerald>pearl", ">", options)
5✔
30
    end
31
    tested.assert_throws_exception({
10✔
32
        given="no headers and no renaming takes place",
4✔
33
        expected="ftcsv: fieldsToKeep only works with header-less files when using the 'rename' functionality",
4✔
34
        actual=test
5✔
35
    })
36

37
end)
38

39

40
tested.test("encode error out with missing field", function()
10✔
41
    local encodeThis = {
5✔
42
        {a = 'herp1', b = 'derp1'},
5✔
43
        {a = 'herp2', b = 'derp2'},
5✔
44
        {a = 'herp3', b = 'derp3'},
5✔
45
    }
4✔
46

47
    local test = function()
48
        ftcsv.encode(encodeThis, ">", {fieldsToKeep={"c"}})
5✔
49
    end
50

51
    tested.assert_throws_exception({
10✔
52
        given="specify a field that doesn't exist during encode",
4✔
53
        expected="ftcsv: the field 'c' doesn't exist in the inputTable",
4✔
54
        actual=test
5✔
55
    })
56
end)
57

58
tested.test("parseLine and loadFromString", function()
10✔
59
    local test = function()
60
        local parse = {}
5✔
61
        for i, line in ftcsv.parseLine("a,b,c\n1,2,3", ",", {loadFromString=true}) do
5✔
NEW
62
            parse[i] = line
×
63
        end
NEW
64
        return parse
×
65
    end
66

67
    tested.assert_throws_exception({
10✔
68
        given="parseLine and loadFromString",
4✔
69
        expected="ftcsv: parseLine currently doesn't support loading from string",
4✔
70
        actual=test
5✔
71
    })
72
end)
73

74
tested.test("missing quotes", function()
10✔
75
    local test = function()
76
        local actual = ftcsv.parse('a,b,c\n"apple,banana,carrot', ",", {loadFromString=true})
5✔
77
    end
78
    tested.assert_throws_exception({
10✔
79
        given="missing quotes",
4✔
80
        expected="ftcsv: can't find closing quote in row 1. Try running with the option ignoreQuotes=true if the source incorrectly uses quotes.",
4✔
81
        actual=test
5✔
82
    })
83
end)
84

85
tested.test("buffersize without parseLine", function()
10✔
86
    local test = function()
87
        local actual = ftcsv.parse('a,b,c\n"apple,banana,carrot', ",", {loadFromString=true, bufferSize=34})
5✔
88
    end
89
    tested.assert_throws_exception({
10✔
90
        should="error if bufferSize is set when parsing entire files",
4✔
91
        expected="ftcsv: bufferSize can only be specified using 'parseLine'. When using 'parse', the entire file is read into memory",
4✔
92
        actual=test,
5✔
93
    })
94
end)
95

96
return tested
5✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc