Skip to content

Commit 6da3df6

Browse files
committed
FIX: Fix MSVC build with path string conversion
1 parent 85f2aad commit 6da3df6

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ build
22
CMakeSettings.json
33
vcpkg_installed
44
.vs
5+
.cache
56
!*.zst

src/detail/buffer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ void Buffer::Shift() {
7373
write_pos_ = read_pos_ + unread_bytes;
7474
}
7575

76-
std::ostream& databento::detail::operator<<(std::ostream& stream,
77-
const Buffer& buffer) {
76+
namespace databento::detail {
77+
std::ostream& operator<<(std::ostream& stream, const Buffer& buffer) {
7878
return StreamOpBuilder{stream}
7979
.SetTypeName("Buffer")
8080
.SetSpacer(" ")
@@ -87,3 +87,4 @@ std::ostream& databento::detail::operator<<(std::ostream& stream,
8787
.AddField("WriteCapacity", buffer.WriteCapacity())
8888
.Finish();
8989
}
90+
} // namespace databento::detail

tests/include/temp_file.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <cassert> // assert
66
#include <cstdio> // remove
7+
#include <filesystem>
78
#include <fstream> // ifstream
89
#include <string>
910
#include <utility> // move
@@ -15,6 +16,8 @@ namespace databento {
1516
// goes out of scope.
1617
class TempFile {
1718
public:
19+
explicit TempFile(const std::filesystem::path& path)
20+
: TempFile{path.string()} {}
1821
explicit TempFile(std::string path) : path_{std::move(path)} {
1922
std::ifstream f{path_};
2023
if (Exists()) {

tests/src/historical_tests.cpp

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,26 @@ TEST_F(HistoricalTests, TestBatchDownloadAll) {
245245
ASSERT_FALSE(temp_metadata_file.Exists());
246246
ASSERT_FALSE(temp_dbn_file.Exists());
247247
const std::vector<std::string> paths =
248-
target.BatchDownload(tmp_path_, kJobId);
248+
target.BatchDownload(tmp_path_.string(), kJobId);
249249
EXPECT_TRUE(temp_metadata_file.Exists());
250250
EXPECT_TRUE(temp_dbn_file.Exists());
251251
ASSERT_EQ(paths.size(), 2);
252-
EXPECT_NE(std::find(paths.begin(), paths.end(), temp_metadata_file.Path()),
253-
paths.end());
254-
EXPECT_NE(std::find(paths.begin(), paths.end(), temp_dbn_file.Path()),
255-
paths.end());
252+
EXPECT_NE(
253+
std::find_if(paths.begin(), paths.end(),
254+
[&temp_metadata_file](const auto& path) {
255+
return std::filesystem::path{path}.lexically_normal() ==
256+
std::filesystem::path{temp_metadata_file.Path()}
257+
.lexically_normal();
258+
}),
259+
paths.end());
260+
EXPECT_NE(
261+
std::find_if(paths.begin(), paths.end(),
262+
[&temp_dbn_file](const auto& path) {
263+
return std::filesystem::path{path}.lexically_normal() ==
264+
std::filesystem::path{temp_dbn_file.Path()}
265+
.lexically_normal();
266+
}),
267+
paths.end());
256268
}
257269

258270
TEST_F(HistoricalTests, TestBatchDownloadSingle) {
@@ -267,9 +279,11 @@ TEST_F(HistoricalTests, TestBatchDownloadSingle) {
267279
static_cast<std::uint16_t>(port)};
268280
ASSERT_FALSE(temp_metadata_file.Exists());
269281
const std::string path =
270-
target.BatchDownload(tmp_path_, kJobId, "test_metadata.json");
282+
target.BatchDownload(tmp_path_.string(), kJobId, "test_metadata.json");
271283
EXPECT_TRUE(temp_metadata_file.Exists());
272-
EXPECT_EQ(path, temp_metadata_file.Path());
284+
EXPECT_EQ(
285+
std::filesystem::path{path}.lexically_normal(),
286+
std::filesystem::path{temp_metadata_file.Path()}.lexically_normal());
273287
}
274288

275289
TEST_F(HistoricalTests, TestBatchDownloadSingleInvalidFile) {
@@ -280,8 +294,9 @@ TEST_F(HistoricalTests, TestBatchDownloadSingleInvalidFile) {
280294

281295
databento::Historical target{logger_.get(), kApiKey, "localhost",
282296
static_cast<std::uint16_t>(port)};
283-
ASSERT_THROW(target.BatchDownload(tmp_path_, kJobId, "test_metadata.js"),
284-
InvalidArgumentError);
297+
ASSERT_THROW(
298+
target.BatchDownload(tmp_path_.string(), kJobId, "test_metadata.js"),
299+
InvalidArgumentError);
285300
}
286301

287302
TEST_F(HistoricalTests, TestMetadataListPublishers) {

0 commit comments

Comments
 (0)