/
ilyassab
/
homework6
Обзор
Документация
Войти
/
ilyassab
/
homework6
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/test/java/MyIOExampleTests.java
138 строк
4 KB
sabirzyanov.ilyas
homework
16 ноя 2025, 23:15
16 ноя 2025, 23:15
6241856
Код
Авторство
О чём код?
import org.junit.Assert; import org.junit.Test; import sbp.io.MyIOExample; import java.io.IOException; import java.nio.file.*; public class MyIOExampleTests { @Test public void workWithFileExistTest() { MyIOExample mio = new MyIOExample(); Assert.assertFalse(mio.workWithFile("MyFile")); } @Test public void workWithFileCreateTest() { MyIOExample mio = new MyIOExample(); Assert.assertTrue(mio.workWithFile("CreateNewFile")); } @Test(expected = InvalidPathException.class) public void workWithFileErrorPathTest() { MyIOExample mio = new MyIOExample(); mio.workWithFile("\0"); } @Test(expected = NullPointerException.class) public void workWithFileErrorNullPathTest() { MyIOExample mio = new MyIOExample(); mio.workWithFile(null); } @Test public void copyFileTest() { MyIOExample mio = new MyIOExample(); try { Files.deleteIfExists(Paths.get("MyFileCopy")); } catch (IOException e) {} Assert.assertTrue(mio.copyFile("MyFile", "MyFileCopy")); } @Test(expected = InvalidPathException.class) public void copyFileInvalidPathExceptionTest() { MyIOExample mio = new MyIOExample(); try { Files.deleteIfExists(Paths.get("MyFileCopy")); } catch (IOException e) {} Assert.assertTrue(mio.copyFile("MyFile", "\0")); } @Test public void copyFileExistsTest() { MyIOExample mio = new MyIOExample(); try { Files.deleteIfExists(Paths.get("MyFileCopy")); } catch (IOException e) {} mio.copyFile("MyFile", "MyFileCopy"); Assert.assertFalse(mio.copyFile("MyFile", "MyFileCopy")); } @Test public void copyBufferedFileTest() { MyIOExample mio = new MyIOExample(); try { Files.deleteIfExists(Paths.get("MyFileCopy")); } catch (IOException e) {} Assert.assertTrue(mio.copyBufferedFile("MyFile", "MyFileCopy")); } @Test(expected = InvalidPathException.class) public void copyBufferedFileInvalidPathExceptionTest() { MyIOExample mio = new MyIOExample(); try { Files.deleteIfExists(Paths.get("MyFileCopy")); } catch (IOException e) {} Assert.assertTrue(mio.copyBufferedFile("MyFile", "\0")); } @Test public void copyBufferedFileExistsTest() { MyIOExample mio = new MyIOExample(); try { Files.deleteIfExists(Paths.get("MyFileCopy")); } catch (IOException e) {} mio.copyBufferedFile("MyFile", "MyFileCopy"); Assert.assertFalse(mio.copyBufferedFile("MyFile", "MyFileCopy")); } @Test public void copyFileWithReaderAndWriterTest() { MyIOExample mio = new MyIOExample(); try { Files.deleteIfExists(Paths.get("MyFileCopy")); } catch (IOException e) {} Assert.assertTrue(mio.copyFileWithReaderAndWriter("MyFile", "MyFileCopy")); } @Test(expected = InvalidPathException.class) public void copyFileWithReaderAndWriterInvalidPathExceptionTest() { MyIOExample mio = new MyIOExample(); try { Files.deleteIfExists(Paths.get("MyFileCopy")); } catch (IOException e) {} Assert.assertTrue(mio.copyFileWithReaderAndWriter("MyFile", "\0")); } @Test public void copyFileWithReaderAndWriterExistsTest() { MyIOExample mio = new MyIOExample(); try { Files.deleteIfExists(Paths.get("MyFileCopy")); } catch (IOException e) {} mio.copyFileWithReaderAndWriter("MyFile", "MyFileCopy"); Assert.assertFalse(mio.copyFileWithReaderAndWriter("MyFile", "MyFileCopy")); } }