• 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

90.32
/tests/parseLine_test.lua
1
local ftcsv = require('ftcsv')
6✔
2
local cjson = require('cjson')
6✔
3
local tested = require("tested")
6✔
4

5
local function loadFile(textFile)
6
    local file = io.open(textFile, "r")
24✔
7
    if not file then error("File not found at " .. textFile) end
24✔
8
    local allLines = file:read("*all")
24✔
9
    file:close()
24✔
10
    return allLines
24✔
11
end
12

13
tested.test("parseLine features small, working buffer size", function()
12✔
14
    local json = loadFile("spec/json/correctness.json")
6✔
15
    json = cjson.decode(json)
6✔
16
    local parse = {}
6✔
17
    for i, line in ftcsv.parseLine("spec/csvs/correctness.csv", ",", {bufferSize=52}) do
50✔
18
        parse[i] = line
30✔
19
    end
20
    tested.assert({
12✔
21
        given="spec/json/correctness.json",
4✔
22
        should="handle correctness",
4✔
23
        expected=json,
6✔
24
        actual=parse
6✔
25
    })
26
end)
27

28
tested.test("parseLine features small, nonworking buffer size", function()
12✔
29
    local test = function()
30
        local parse = {}
6✔
31
        for i, line in ftcsv.parseLine("spec/csvs/correctness.csv", ",", {bufferSize=63}) do
24✔
32
            parse[i] = line
12✔
33
        end
NEW
34
        return parse
×
35
    end
36
    tested.assert_throws_exception({
12✔
37
        given="nonworking buffersize",
4✔
38
        expected="ftcsv: bufferSize needs to be larger to parse this file",
4✔
39
        actual=test
6✔
40
    })
41
end)
42

43
tested.test("parseLine features smaller, nonworking buffer size", function()
12✔
44
    local test = function()
45
        local parse = {}
6✔
46
        for i, line in ftcsv.parseLine("spec/csvs/correctness.csv", ",", {bufferSize=50}) do
32✔
47
            parse[i] = line
18✔
48
        end
NEW
49
        return parse
×
50
    end
51
    tested.assert_throws_exception({
12✔
52
        given="nonworking buffersize",
4✔
53
        expected="ftcsv: bufferSize needs to be larger to parse this file",
4✔
54
        actual=test
6✔
55
    })
56
end)
57

58
tested.test("smaller bufferSize than header and incorrect number of fields", function()
12✔
59
    local test = function()
60
        local parse = {}
6✔
61
        for i, line in ftcsv.parseLine("spec/csvs/correctness.csv", ",", {bufferSize=23}) do
6✔
NEW
62
            parse[i] = line
×
63
        end
NEW
64
        return parse
×
65
    end
66
    tested.assert_throws_exception({
12✔
67
        given="nonworking buffersize",
4✔
68
        expected="ftcsv: bufferSize needs to be larger to parse this file",
4✔
69
        actual=test
6✔
70
    })
71
end)
72

73
tested.test("smaller bufferSize than header, but with correct field numbers", function()
12✔
74
    local test = function()
75
        local parse = {}
6✔
76
        for i, line in ftcsv.parseLine("spec/csvs/correctness.csv", ",", {bufferSize=30}) do
6✔
NEW
77
            parse[i] = line
×
78
        end
NEW
79
        return parse
×
80
    end
81
    tested.assert_throws_exception({
12✔
82
        given="nonworking buffersize",
4✔
83
        expected="ftcsv: bufferSize needs to be larger to parse this file",
4✔
84
        actual=test
6✔
85
    })
86
end)
87

88
tested.test("parseLine with options but not bufferSize", function()
12✔
89

90
    local json = loadFile("spec/json/correctness.json")
6✔
91
    json = cjson.decode(json)
6✔
92

93
    local parse = {}
6✔
94
    for i, line in ftcsv.parseLine("spec/csvs/correctness.csv", ",", {rename={["Year"] = "Full Year"}}) do
50✔
95
           parse[i] = line
30✔
96
    end
97
    tested.assert({
12✔
98
        given="spec/csvs/correctness.csv",
4✔
99
        should="be the same size, even though renamed",
4✔
100
        expected=#json,
6✔
101
        actual=#parse
6✔
102
    })
103
end)
104

105
tested.test("parseLine features small, working buffer size without delimiter", function()
12✔
106
    local json = loadFile("spec/json/correctness.json")
6✔
107
    json = cjson.decode(json)
6✔
108
    local parse = {}
6✔
109
    for i, line in ftcsv.parseLine("spec/csvs/correctness.csv", {bufferSize=52}) do
50✔
110
        parse[i] = line
30✔
111
    end
112
    tested.assert({
12✔
113
        given="spec/csvs/correctness.csv",
4✔
114
        expected=json,
6✔
115
        actual=parse
6✔
116
    })
117
end)
118

119
tested.test("parseLine features small, nonworking buffer size without delimiter", function()
12✔
120
    local test = function()
121
        local parse = {}
6✔
122
        for i, line in ftcsv.parseLine("spec/csvs/correctness.csv", {bufferSize=63}) do
24✔
123
            parse[i] = line
12✔
124
        end
NEW
125
        return parse
×
126
    end
127
    tested.assert_throws_exception({
12✔
128
        given="nonworking buffersize",
4✔
129
        expected="ftcsv: bufferSize needs to be larger to parse this file",
4✔
130
        actual=test
6✔
131
    })  
132
end)
133

134
tested.test("parseLine features smaller, nonworking buffer size without delimiter", function()
12✔
135
    local test = function()
136
        local parse = {}
6✔
137
        for i, line in ftcsv.parseLine("spec/csvs/correctness.csv", {bufferSize=50}) do
32✔
138
            parse[i] = line
18✔
139
        end
NEW
140
        return parse
×
141
    end
142
    tested.assert_throws_exception({
12✔
143
        given="nonworking buffersize",
4✔
144
        expected="ftcsv: bufferSize needs to be larger to parse this file",
4✔
145
        actual=test
6✔
146
    }) 
147
end)
148

149
tested.test("smaller bufferSize than header and incorrect number of fields without delimiter", function()
12✔
150
    local test = function()
151
        local parse = {}
6✔
152
        for i, line in ftcsv.parseLine("spec/csvs/correctness.csv", {bufferSize=23}) do
6✔
NEW
153
            parse[i] = line
×
154
        end
NEW
155
        return parse
×
156
    end
157
    tested.assert_throws_exception({
12✔
158
        given="nonworking buffersize",
4✔
159
        expected="ftcsv: bufferSize needs to be larger to parse this file",
4✔
160
        actual=test
6✔
161
    }) 
162
end)
163

164
tested.test("smaller bufferSize than header, but with correct field numbers without delimiter", function()
12✔
165
    local test = function()
166
        local parse = {}
6✔
167
        for i, line in ftcsv.parseLine("spec/csvs/correctness.csv", {bufferSize=30}) do
6✔
NEW
168
            parse[i] = line
×
169
        end
NEW
170
        return parse
×
171
    end
172
    tested.assert_throws_exception({
12✔
173
        given="nonworking buffersize",
4✔
174
        expected="ftcsv: bufferSize needs to be larger to parse this file",
4✔
175
        actual=test
6✔
176
    }) 
177
end)
178

179
tested.test("parseLine with options but not bufferSize without delimiter", function()
12✔
180
    local json = loadFile("spec/json/correctness.json")
6✔
181
    json = cjson.decode(json)
6✔
182

183
    local parse = {}
6✔
184
    for i, line in ftcsv.parseLine("spec/csvs/correctness.csv", {rename={["Year"] = "Full Year"}}) do
50✔
185
        parse[i] = line
30✔
186
    end
187
    tested.assert({
12✔
188
        given="spec/csvs/correctness.csv",
4✔
189
        should="be the same size, even though renamed",
4✔
190
        expected=#json,
6✔
191
        actual=#parse
6✔
192
    })
193

194
end)
195

196
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