OliverJUnit mit änderung wegen DEL-Zeichen

main
Andreas Wurst 2025-06-02 15:42:39 +02:00
parent e7aa96947a
commit 458e3d20db
2 changed files with 20 additions and 17 deletions

View File

@ -27,12 +27,15 @@ if (passwort == null){
public static boolean checkZiffer(String passwort) { public static boolean checkZiffer(String passwort) {
if (passwort == null) { if (passwort == null) {
return false; return false;
}// Abfrage der Ziffern } // Abfrage der ZiffernS
return passwort.matches(".*[0-9].*[0-9].*[0-9].*"); return passwort.matches(".*[0-9].*[0-9].*[0-9].*");
} }
public static boolean checkSonderZeichen(String passwort) { public static boolean checkSonderZeichen(String passwort) {
if (passwort == null) {
return false;
}
// Überprüfung mit Regex durch Ausschluss // Überprüfung mit Regex durch Ausschluss
// [^A-Za-z0-9] Schließt alle ziffern und Buchstaben aus // [^A-Za-z0-9] Schließt alle ziffern und Buchstaben aus
// Ausschlus der Steuerzeichen: // Ausschlus der Steuerzeichen:
@ -40,11 +43,12 @@ if (passwort == null){
// [^/r] schließt Carriage Return aus // [^/r] schließt Carriage Return aus
// [^/n] schließt Line Feed aus // [^/n] schließt Line Feed aus
// [^A-Za-z0-9\\x00-\\x1F\\x7F] [^A-Za-z0-9\t\r\n] // [^A-Za-z0-9\\x00-\\x1F\\x7F] [^A-Za-z0-9\t\r\n]
String reg = "[\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E]"; String reg = "[\\x20-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E\\x80]";
return passwort.matches(".*" + reg + ".*" + reg + ".*" + reg + ".*"); return passwort.matches(".*" + reg + ".*" + reg + ".*" + reg + ".*");
// String negReg = "[^A-Za-z0-9\\x00-\\x1F\\x7F]"; // String negReg = "[^A-Za-z0-9\\x00-\\x1F\\x7F]";
// return passwort.matches(".*"+negReg+".*"+negReg+".*"+negReg+".*"); // return passwort.matches(".*"+negReg+".*"+negReg+".*"+negReg+".*");
//return passwort.matches(".*[^A-Za-z0-9\\x00-\\x1F\\x7F].*[^A-Za-z0-9\\x00-\\x1F\\x7F].*[^A-Za-z0-9\\x00-\\x1F\\x7F].*"); // return
// passwort.matches(".*[^A-Za-z0-9\\x00-\\x1F\\x7F].*[^A-Za-z0-9\\x00-\\x1F\\x7F].*[^A-Za-z0-9\\x00-\\x1F\\x7F].*");
} }
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -1,4 +1,3 @@
package Pflichtuebung_4;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@ -45,7 +44,7 @@ public class Test_Passwords_Oliver_S {
final static int STOP_CHAR_SONDERZ_3 = 96; final static int STOP_CHAR_SONDERZ_3 = 96;
final static int START_CHAR_SONDERZ_4 = 123; final static int START_CHAR_SONDERZ_4 = 123;
final static int STOP_CHAR_SONDERZ_4 = 127; final static int STOP_CHAR_SONDERZ_4 = 126;
@FunctionalInterface @FunctionalInterface
interface Check_X_Interface{ interface Check_X_Interface{