Skip to content

Commit 30271a0

Browse files
committed
add test for get column labels of empty label row
1 parent 7528d7c commit 30271a0

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ if(RAPIDCSV_BUILD_TESTS)
196196
add_unit_test(test104)
197197
add_unit_test(test105)
198198
add_unit_test(test106)
199+
add_unit_test(test107)
199200

200201
# perf tests
201202
add_perf_test(ptest001)

tests/test107.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// test107.cpp - get column labels of empty label row
2+
3+
#include <rapidcsv.h>
4+
#include "unittest.h"
5+
6+
int main()
7+
{
8+
int rv = 0;
9+
10+
try
11+
{
12+
// Empty document, specify column and row labels available
13+
std::string csv = "";
14+
std::istringstream s(csv);
15+
rapidcsv::Document doc(s, rapidcsv::LabelParams(0, 0));
16+
17+
// InsertRow create a row with 0 columns
18+
doc.InsertRow<std::string>(0);
19+
20+
// Get column names
21+
std::vector<std::string> names = doc.GetColumnNames();
22+
unittest::ExpectEqual(size_t, names.size(), size_t(0));
23+
}
24+
catch (const std::exception& ex)
25+
{
26+
std::cout << "exception: " << ex.what() << std::endl;
27+
rv = 1;
28+
}
29+
30+
return rv;
31+
}

0 commit comments

Comments
 (0)