• 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

194
end)
195

196
return tested
5 ✔
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