-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_csv.cpp
More file actions
32 lines (23 loc) · 872 Bytes
/
test_csv.cpp
File metadata and controls
32 lines (23 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "test_settings.hpp"
#ifdef ENABLE_TESTS
#include "../utils_lib/external/doctest.hpp"
#include "../utils_lib/utils_csv.hpp"
TEST_CASE("Test utils::csv") {
utils::csv::Reader file;
file.use_dialect("excel");
file.read("./utils_lib/external/csv/tests/inputs/test_11_excel.csv");
int data = 1;
while (file.busy()) {
if (file.ready()) {
auto row = file.next_row();
// Each row is a csv::unordered_flat_map (github.com/martinus/robin-hood-hashing)
CHECK(row["a"] == std::to_string(data++));
CHECK(row["b"] == std::to_string(data++));
CHECK(row["c"] == std::to_string(data++));
}
}
const auto cols = file.cols();
CHECK(std::tie(cols[0], cols[1], cols[2]) == std::tie("a", "b", "c"));
CHECK(file.shape() == std::pair<size_t, size_t>{2, 3});
}
#endif