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

Method writeReadRemoveFile

Tests/Libraries/FileSystem/FileSystemTest.cpp:208–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208void SC::FileSystemTest::writeReadRemoveFile()
209{
210 //! [writeReadRemoveFileSnippet]
211 FileSystem fs;
212 // Make all operations relative to applicationRootDirectory
213 SC_TEST_EXPECT(fs.init(report.applicationRootDirectory.view()));
214 StringView content = "ASDF content";
215
216 // Check that file doesn't exists before write-ing it and then check that it exist
217 SC_TEST_EXPECT(not fs.exists("file.txt"));
218 SC_TEST_EXPECT(fs.writeString("file.txt", content));
219 SC_TEST_EXPECT(fs.existsAndIsFile("file.txt"));
220
221 // Read the file and check its content
222 String newString = StringEncoding::Ascii;
223 SC_TEST_EXPECT(fs.read("file.txt", newString));
224 SC_TEST_EXPECT(newString.view() == content);
225
226 // Remove all files created by the test
227 SC_TEST_EXPECT(fs.removeFile("file.txt"));
228 SC_TEST_EXPECT(not fs.exists("file.txt"));
229 //! [writeReadRemoveFileSnippet]
230}
231
232void SC::FileSystemTest::copyExistsFile()
233{

Callers

nothing calls this directly

Calls 7

existsMethod · 0.80
existsAndIsFileMethod · 0.80
initMethod · 0.45
viewMethod · 0.45
writeStringMethod · 0.45
readMethod · 0.45
removeFileMethod · 0.45

Tested by

no test coverage detected