MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / fileReadWriteTest

Method fileReadWriteTest

Tests/InteropSTL/STLFileSystemTest.cpp:30–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28};
29
30void SC::CppSTLFileSystemTest::fileReadWriteTest()
31{
32 // FileSystem
33 FileSystem fs;
34 SC_TEST_EXPECT(fs.init(report.applicationRootDirectory.view()));
35 std::string sampleText = "STL is not so much Sane";
36 SC_TEST_EXPECT(fs.writeString("test.txt", asSane(sampleText)));
37 std::string readFromFS;
38 std::string_view targetFile = "test.txt";
39 SC_TEST_EXPECT(fs.read(asSane(targetFile), readFromFS));
40 SC_TEST_EXPECT(readFromFS == sampleText);
41
42 // Path
43 std::string finalPath;
44 SC_TEST_EXPECT(Path::join(finalPath, {report.applicationRootDirectory.view(), asSane(targetFile)}));
45
46 // File
47 FileDescriptor fd;
48 SC_TEST_EXPECT(fd.open(asSane(finalPath), FileOpen::Mode::Read));
49 std::string readFromFD;
50 SC_TEST_EXPECT(fd.readUntilEOF(readFromFD));
51 SC_TEST_EXPECT(readFromFS == readFromFD);
52}
53
54namespace SC
55{

Callers

nothing calls this directly

Calls 8

asSaneFunction · 0.85
readUntilEOFMethod · 0.80
joinFunction · 0.50
initMethod · 0.45
viewMethod · 0.45
writeStringMethod · 0.45
readMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected