New unit test format

This commit is contained in:
Nick
2019-08-30 21:11:18 +01:00
parent db85c8f275
commit 6cd385e4c0
19972 changed files with 1626600 additions and 0 deletions
@@ -0,0 +1,14 @@
package baeldunggreeter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Formatter {
public static String getFormattedDate() {
DateFormat dateFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
Date date = new Date();
return dateFormat.format(date);
}
}
@@ -0,0 +1,23 @@
package baeldunggreetertest;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import java.util.regex.Pattern;
import org.junit.Test;
import baeldunggreeter.Formatter;
public class FormatterTest {
@Test
public void testFormatter() {
String dateRegex1 = "^((19|20)\\d\\d)-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01]) ([2][0-3]|[0-1][0-9]|[1-9]):[0-5][0-9]:([0-5][0-9]|[6][0])$";
String dateString = Formatter.getFormattedDate();
assertTrue(Pattern
.matches(dateRegex1, dateString));
}
}