Puzzles
Regular Expressions
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.time.LocalDate; import java.time.format.DateTimeFormatter; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { private String today = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); private String randomDay = LocalDate.now().plusDays(2).format(DateTimeFormatter.ofPattern("yyyyMMdd")); @Test void basicTest() { assertFalse(PasswordValidation.validatePassword("")); assertTrue(PasswordValidation.validatePassword("pass73$OCT" + today + "len23")); assertFalse(PasswordValidation.validatePassword("TOdaY" + today + ".feb29P6g@#fahHl")); assertFalse(PasswordValidation.validatePassword("sib$dic&omonUl98DSA" + today + "len17shJDAIDB78334&Okk.53jfh")); assertTrue(PasswordValidation.validatePassword("dskjRUE3576&sj_88@mAyJun" + today + "JUL47.1j6SB2nI7")); } @Test void largestBasicTest() { assertTrue(PasswordValidation.validatePassword("TOdaY" + today + ".feb29P6gwo@fahH")); assertTrue(PasswordValidation.validatePassword("h&ks-KlOCt" + today + "#aai78Ho37M7M_lj73.")); assertTrue(PasswordValidation.validatePassword(today + "&jUN1.df487-ks228d43#hULP0@cb111baQ")); assertFalse(PasswordValidation.validatePassword("k17DiC9@P" + today)); assertFalse(PasswordValidation.validatePassword("hJAN" + today + "&17a9")); assertFalse(PasswordValidation.validatePassword("p6NOv#L17" + today)); assertFalse(PasswordValidation.validatePassword("MyP@ssworD-67sAloU" + today + "29o")); assertFalse(PasswordValidation.validatePassword("MyP@sswMAy-67sAlU" + today + "29o")); assertFalse(PasswordValidation.validatePassword("Lol_sC_apR01" + today + "nOp")); assertFalse(PasswordValidation.validatePassword(".SiL" + today + "jUt7190lAUG2f27")); assertFalse(PasswordValidation.validatePassword("JupoJUN43.90-12plUSlenght31$h#1")); assertFalse(PasswordValidation.validatePassword("n0TC84nTeInmar.nn_" + randomDay + "poAl98712mQ")); } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- import static org.junit.Assert.assertFalse;
- import static org.junit.Assert.assertTrue;
- import java.time.LocalDate;
- import java.time.format.DateTimeFormatter;
- // TODO: Replace examples and use TDD by writing your own tests
- class SolutionTest {
- private String today = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
- private String randomDay = LocalDate.now().plusDays(2).format(DateTimeFormatter.ofPattern("yyyyMMdd"));
- @Test
- void basicTest() {
- assertFalse(PasswordValidation.validatePassword(""));
- assertTrue(PasswordValidation.validatePassword("pass73$OCT" + today + "len23"));
- assertFalse(PasswordValidation.validatePassword("TOdaY" + today + ".feb29P6g@#fahHl"));
- assertFalse(PasswordValidation.validatePassword("sib$dic&omonUl98DSA" + today + "len17shJDAIDB78334&Okk.53jfh"));
- assertTrue(PasswordValidation.validatePassword("dskjRUE3576&sj_88@mAyJun" + today + "JUL47.1j6SB2nI7"));
- }
- @Test
void testSomething() {// assertEquals("expected", "actual");- void largestBasicTest() {
- assertTrue(PasswordValidation.validatePassword("TOdaY" + today + ".feb29P6gwo@fahH"));
- assertTrue(PasswordValidation.validatePassword("h&ks-KlOCt" + today + "#aai78Ho37M7M_lj73."));
- assertTrue(PasswordValidation.validatePassword(today + "&jUN1.df487-ks228d43#hULP0@cb111baQ"));
- assertFalse(PasswordValidation.validatePassword("k17DiC9@P" + today));
- assertFalse(PasswordValidation.validatePassword("hJAN" + today + "&17a9"));
- assertFalse(PasswordValidation.validatePassword("p6NOv#L17" + today));
- assertFalse(PasswordValidation.validatePassword("MyP@ssworD-67sAloU" + today + "29o"));
- assertFalse(PasswordValidation.validatePassword("MyP@sswMAy-67sAlU" + today + "29o"));
- assertFalse(PasswordValidation.validatePassword("Lol_sC_apR01" + today + "nOp"));
- assertFalse(PasswordValidation.validatePassword(".SiL" + today + "jUt7190lAUG2f27"));
- assertFalse(PasswordValidation.validatePassword("JupoJUN43.90-12plUSlenght31$h#1"));
- assertFalse(PasswordValidation.validatePassword("n0TC84nTeInmar.nn_" + randomDay + "poAl98712mQ"));
- }
- }