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

FourierTransformer / ftcsv / 30870348305

04 Aug 2026 01:57AM UTC coverage: 99.01% (+0.1%) from 98.901%
30870348305

push

github

web-flow
Merge eea6a48b7 into d8586b9f6

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%)

1339.07 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("tests/json/correctness.json")
6 ✔
15
    json = cjson.decode(json)
6 ✔
16
    local parse = {}
6 ✔
17
    for i, line in ftcsv.parseLine("tests/csvs/correctness.csv", ",", {bufferSize=52}) do
43 ✔
18
        parse[i] = line
30 ✔
19
    end
20
    tested.assert({
12 ✔
21
        given="tests/json/correctness.json",
5 ✔
22
        should="handle correctness",
5 ✔
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("tests/csvs/correctness.csv", ",", {bufferSize=63}) do
21 ✔
32
            parse[i] = line
12 ✔
33
        end
NEW
34
        return parse
×
35
    end
36
    tested.assert_throws_exception({
12 ✔
37
        given="nonworking buffersize",
5 ✔
38
        expected="ftcsv: bufferSize needs to be larger to parse this file",
5 ✔
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("tests/csvs/correctness.csv", ",", {bufferSize=50}) do
28 ✔
47
            parse[i] = line
18 ✔
48
        end
NEW
49
        return parse
×
50
    end
51
    tested.assert_throws_exception({
12 ✔
52
        given="nonworking buffersize",
5 ✔
53
        expected="ftcsv: bufferSize needs to be larger to parse this file",
5 ✔
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("tests/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",
5 ✔
68
        expected="ftcsv: bufferSize needs to be larger to parse this file",
5 ✔
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("tests/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",
5 ✔
83
        expected="ftcsv: bufferSize needs to be larger to parse this file",
5 ✔
84
        actual=test
6 ✔
85
    })
86
end)
87

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

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

93
    local parse = {}
6 ✔
94
    for i, line in ftcsv.parseLine("tests/csvs/correctness.csv", ",", {rename={["Year"] = "Full Year"}}) do
43 ✔
95
           parse[i] = line
30 ✔
96
    end
97
    tested.assert({
12 ✔
98
        given="tests/csvs/correctness.csv",
5 ✔
99
        should="be the same size, even though renamed",
5 ✔
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("tests/json/correctness.json")
6 ✔
107
    json = cjson.decode(json)
6 ✔
108
    local parse = {}
6 ✔
109
    for i, line in ftcsv.parseLine("tests/csvs/correctness.csv", {bufferSize=52}) do
43 ✔
110
        parse[i] = line
30 ✔
111
    end
112
    tested.assert({
12 ✔
113
        given="tests/csvs/correctness.csv",
5 ✔
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("tests/csvs/correctness.csv", {bufferSize=63}) do
21 ✔
123
            parse[i] = line
12 ✔
124
        end
NEW
125
        return parse
×
126
    end
127
    tested.assert_throws_exception({
12 ✔
128
        given="nonworking buffersize",
5 ✔
129
        expected="ftcsv: bufferSize needs to be larger to parse this file",
5 ✔
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("tests/csvs/correctness.csv", {bufferSize=50}) do
28 ✔
138
            parse[i] = line
18 ✔
139
        end
NEW
140
        return parse
×
141
    end
142
    tested.assert_throws_exception({
12 ✔
143
        given="nonworking buffersize",
5 ✔
144
        expected="ftcsv: bufferSize needs to be larger to parse this file",
5 ✔
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("tests/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",
5 ✔
159
        expected="ftcsv: bufferSize needs to be larger to parse this file",
5 ✔
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("tests/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",
5 ✔
174
        expected="ftcsv: bufferSize needs to be larger to parse this file",
5 ✔
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("tests/json/correctness.json")
6 ✔
181
    json = cjson.decode(json)
6 ✔
182

183
    local parse = {}
6 ✔
184
    for i, line in ftcsv.parseLine("tests/csvs/correctness.csv", {rename={["Year"] = "Full Year"}}) do
43 ✔
185
        parse[i] = line
30 ✔
186
    end
187
    tested.assert({
12 ✔
188
        given="tests/csvs/correctness.csv",
5 ✔
189
        should="be the same size, even though renamed",
5 ✔
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 TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc