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

FourierTransformer / ftcsv / 21464715402

29 Jan 2026 03:40AM UTC coverage: 99.01% (+0.1%) from 98.901%
21464715402

push

github

web-flow
Merge 28821c2c2 into edf705c37

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

1600 of 1616 relevant lines covered (99.01%)

1418.24 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')
6✔
2
local tested = require("tested")
6✔
3

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

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

26
tested.test("no headers or renaming", function()
12✔
27
    local test = function()
28
        local options = {loadFromString=true, headers=false, fieldsToKeep={1, 2}}
6✔
29
        ftcsv.parse("apple>banana>carrot\ndiamond>emerald>pearl", ">", options)
6✔
30
    end
31
    tested.assert_throws_exception({
12✔
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
6✔
35
    })
36

37
end)
38

39

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

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

51
    tested.assert_throws_exception({
12✔
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
6✔
55
    })
56
end)
57

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

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

74
tested.test("missing quotes", function()
12✔
75
    local test = function()
76
        local actual = ftcsv.parse('a,b,c\n"apple,banana,carrot', ",", {loadFromString=true})
6✔
77
    end
78
    tested.assert_throws_exception({
12✔
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
6✔
82
    })
83
end)
84

85
tested.test("buffersize without parseLine", function()
12✔
86
    local test = function()
87
        local actual = ftcsv.parse('a,b,c\n"apple,banana,carrot', ",", {loadFromString=true, bufferSize=34})
6✔
88
    end
89
    tested.assert_throws_exception({
12✔
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,
6✔
93
    })
94
end)
95

96
return tested
6✔
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