| 14 | |
| 15 | namespace xgboost::data { |
| 16 | TEST(FileIterator, Basic) { |
| 17 | auto check_n_features = [](FileIterator *iter) { |
| 18 | size_t n_features = 0; |
| 19 | iter->Reset(); |
| 20 | while (iter->Next()) { |
| 21 | auto proxy = MakeProxy(iter->Proxy()); |
| 22 | auto csr = std::any_cast<std::shared_ptr<CSRArrayAdapter>>(proxy->Adapter()); |
| 23 | n_features = std::max(n_features, csr->NumColumns()); |
| 24 | } |
| 25 | ASSERT_EQ(n_features, 5); |
| 26 | }; |
| 27 | |
| 28 | common::TemporaryDirectory tmpdir; |
| 29 | { |
| 30 | auto zpath = tmpdir.Str() + "/0-based.svm"; |
| 31 | CreateBigTestData(zpath, 3 * 64, true); |
| 32 | zpath += "?indexing_mode=0&format=libsvm"; |
| 33 | FileIterator iter{zpath, 0, 1}; |
| 34 | check_n_features(&iter); |
| 35 | } |
| 36 | |
| 37 | { |
| 38 | auto opath = tmpdir.Str() + "/1-based.svm"; |
| 39 | CreateBigTestData(opath, 3 * 64, false); |
| 40 | opath += "?indexing_mode=1&format=libsvm"; |
| 41 | FileIterator iter{opath, 0, 1}; |
| 42 | check_n_features(&iter); |
| 43 | } |
| 44 | } |
| 45 | } // namespace xgboost::data |
nothing calls this directly
no test coverage detected