Procházet zdrojové kódy

stworzono test dla pustego pliku

Adam Matuszewski před 1 rokem
rodič
revize
502726f75b

+ 0 - 0
KonwersjaLiter2/src/main/resources/empty.txt


+ 7 - 0
KonwersjaLiter2/src/main/resources/zadania.txt

@@ -0,0 +1,7 @@
+Mamy dla jednego pliku
+
+1. pusty plik
+2. wiele plików
+3. plik zawierający same cyfry
+4. plik zawierający same znaki
+5.

+ 25 - 1
KonwersjaLiter2/src/test/java/pl/dmcs/FileConverterTest.java

@@ -9,7 +9,7 @@ import java.nio.file.Paths;
 public class FileConverterTest {
 public class FileConverterTest {
 
 
     @Test
     @Test
-    public void testConvertToUpperCase() throws IOException {
+    void testConvertToUpperCase() throws IOException {
         Path filePath = Paths.get("src/main/resources/test.txt");
         Path filePath = Paths.get("src/main/resources/test.txt");
         String originalContent = Files.readString(filePath);
         String originalContent = Files.readString(filePath);
         String expectedContent ="TEST\n" +
         String expectedContent ="TEST\n" +
@@ -29,4 +29,28 @@ public class FileConverterTest {
 
 
         //  Files.writeString(filePath, originalContent);
         //  Files.writeString(filePath, originalContent);
     }
     }
+
+    // test na pusty plik
+    @Test
+    void testConvertEmpty() throws IOException{
+        Path emptyFilePath = Paths.get("src/main/resources/empty.txt");
+        //Files.createFile(emptyFilePath); // twrorzy plik
+
+        FileConverter converter = new FileConverter();
+        converter.convertToUpperCase(emptyFilePath.toString());
+
+        String actualContent = Files.readString(emptyFilePath);
+
+        assertEquals("",actualContent);
+
+        //Files.deleteIfExists(emptyFilePath); // usuwa plik
+
+    }
+
+
+
+
+
+
+
 }
 }