MCPcopy Create free account
hub / github.com/dmlc/treelite / TEST

Function TEST

tests/cpp/test_utils.cc:17–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include <gtest/gtest.h>
16
17TEST(FileUtils, StreamIO) {
18 std::string s{"Hello world"};
19 std::string s2;
20 std::filesystem::path tmpdir = std::filesystem::temp_directory_path();
21 std::filesystem::path filepath = tmpdir / std::filesystem::u8path("ななひら.txt");
22
23 {
24 std::ofstream ofs = treelite::detail::OpenFileForWriteAsStream(filepath);
25 ofs.write(s.data(), s.length());
26 }
27 {
28 std::ifstream ifs = treelite::detail::OpenFileForReadAsStream(filepath);
29 s2.resize(s.length());
30 ifs.read(s2.data(), s.length());
31 ASSERT_EQ(s, s2);
32 }
33
34 std::filesystem::remove(filepath);
35}
36
37TEST(FileUtils, OpenFileForReadAsFilePtr) {
38 std::string s{"Hello world"};

Callers

nothing calls this directly

Calls 3

OpenFileForWriteAsStreamFunction · 0.85
OpenFileForReadAsStreamFunction · 0.85
OpenFileForReadAsFilePtrFunction · 0.85

Tested by

no test coverage detected