From 004520390e22d49516a0e0ea8e6e4c535e6fdedc Mon Sep 17 00:00:00 2001 From: Piotr Szefler Date: Wed, 27 Oct 2021 18:28:19 +0200 Subject: [PATCH] =?UTF-8?q?Prze=C5=9Blij=20pliki=20do=20''?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plik dotyczący testów: Poprawność PESEL oraz poprawność ścieżki do zapisu pliku. --- Testy.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Testy.java diff --git a/Testy.java b/Testy.java new file mode 100644 index 0000000..a9d0ae3 --- /dev/null +++ b/Testy.java @@ -0,0 +1,50 @@ +package wmiproject; +import java.io.File; + +public class Testy { + + private String[] peselgood = {"60110353151","57041454875","73082572695","95111316474","61121094969"} ; + + private String[] peselbad = {"99090303240","90931202030","20202020202","29023955555","57041454874"}; + + private String communicate = ""; + + + //test1 - Sprawdza czy działa tester peseli + public String PrzetestujPeselValid() { + var i = 0; + while (i<5) { + PeselValid sprawdzgood = new PeselValid(peselgood[i]); + PeselValid sprawdzbad = new PeselValid(peselbad[i]); + if(sprawdzgood.isValid() == true && sprawdzbad.isValid() == false) { + i++; + if(communicate.isEmpty()) { + communicate = "Test sprawdzania peseli zdany."; + } + } + else { + i=5; + communicate = "Problem w mechanizmie validacji PESEL"; + } + } + return communicate; + } + //test2 - Sprawdza czy ścieżka istnieje lub jest poprawna. + public void PrzetestujPliki(String filepath) { + + File f = new File(filepath); + + if(!f.isDirectory()){ + communicate = "Błędna ścieżka, lub katalog nie istnieje!"; + System.out.println(communicate); + System.exit(0); + } + else if(f.isDirectory()){ + communicate = "Katalog istnieje! "; + System.out.println(communicate); + + } + + + } +}