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

Method renameFile

Tests/Libraries/FileSystem/FileSystemTest.cpp:336–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334}
335
336void SC::FileSystemTest::renameFile()
337{
338 //! [renameFileSnippet]
339 FileSystem fs;
340 SC_TEST_EXPECT(fs.init(report.applicationRootDirectory.view()));
341
342 // Create a file and check that it exists
343 SC_TEST_EXPECT(fs.writeString("renameTest.txt", "asdf"));
344 SC_TEST_EXPECT(fs.existsAndIsFile("renameTest.txt"));
345
346 // Rename the file
347 SC_TEST_EXPECT(fs.rename("renameTest.txt", "renameTest2.txt"));
348
349 // Check that the file has been renamed
350 SC_TEST_EXPECT(fs.existsAndIsFile("renameTest2.txt"));
351 SC_TEST_EXPECT(not fs.existsAndIsFile("renameTest.txt"));
352
353 // Rename the file again
354 SC_TEST_EXPECT(fs.rename("renameTest2.txt", "renameTest.txt"));
355
356 // Check that the file has been renamed
357 SC_TEST_EXPECT(fs.existsAndIsFile("renameTest.txt"));
358 SC_TEST_EXPECT(not fs.existsAndIsFile("renameTest2.txt"));
359
360 // Remove all files created by the test
361 SC_TEST_EXPECT(fs.removeFile("renameTest.txt"));
362 //! [renameFileSnippet]
363}
364
365void SC::FileSystemTest::renameDirectory()
366{

Callers

nothing calls this directly

Calls 6

existsAndIsFileMethod · 0.80
initMethod · 0.45
viewMethod · 0.45
writeStringMethod · 0.45
renameMethod · 0.45
removeFileMethod · 0.45

Tested by

no test coverage detected