From 16367146182b7a7f35f4d83d224d8f1636c9f773 Mon Sep 17 00:00:00 2001 From: glywk Date: Tue, 29 Oct 2024 10:45:12 +0100 Subject: [PATCH] AVRO-4085: Fix file size extraction error on windows platform (#3229) --- lang/c++/test/DataFileTests.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lang/c++/test/DataFileTests.cc b/lang/c++/test/DataFileTests.cc index ad6796fbcf8..7e2c78f9434 100644 --- a/lang/c++/test/DataFileTests.cc +++ b/lang/c++/test/DataFileTests.cc @@ -471,9 +471,7 @@ class DataFileTest { void testReaderSplits() { boost::mt19937 random(static_cast(time(nullptr))); avro::DataFileReader df(filename, writerSchema); - std::ifstream just_for_length( - filename, std::ifstream::ate | std::ifstream::binary); - int length = static_cast(just_for_length.tellg()); + int length = static_cast(boost::filesystem::file_size(filename)); int splits = 10; int end = length; // end of split int remaining = end; // bytes remaining @@ -696,7 +694,7 @@ struct codec_traits { if (auto *rd = dynamic_cast(&d)) { const std::vector fo = rd->fieldOrder(); - for (unsigned long it : fo) { + for (const auto it : fo) { switch (it) { case 0: { avro::decode(d, v.s2); @@ -1097,7 +1095,7 @@ init_unit_test_suite(int, char *[]) { shared_ptr t9(new DataFileTest("test9.df", sch, sch)); ts->add(BOOST_CLASS_TEST_CASE(&DataFileTest::testWrite, t9)); ts->add(BOOST_CLASS_TEST_CASE(&DataFileTest::testReaderSyncSeek, t9)); - //ts->add(BOOST_CLASS_TEST_CASE(&DataFileTest::testCleanup, t9)); + ts->add(BOOST_CLASS_TEST_CASE(&DataFileTest::testCleanup, t9)); boost::unit_test::framework::master_test_suite().add(ts); } {