forked from OHDSI/WhiteRabbit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from thehyve/issue-313
Issue 313
- Loading branch information
Showing
2 changed files
with
78 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
rabbit-core/src/test/java/org/ohdsi/utilities/StringUtilitiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.ohdsi.utilities; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class StringUtilitiesTest { | ||
|
||
@Test | ||
void isDate() { | ||
// previously supported date formats: yyyy.mm.dd or mm.dd.yy ("." may be any separator) | ||
assertTrue(StringUtilities.isDate("31.01.23")); | ||
assertTrue(StringUtilities.isDate("31.12.32")); | ||
assertTrue(StringUtilities.isDate("12.31.32")); | ||
assertTrue(StringUtilities.isDate("2023.01.31")); | ||
assertTrue(StringUtilities.isDate("2032.12.31")); | ||
assertFalse(StringUtilities.isDate("2032.12.32")); | ||
|
||
// more generally supported date formats after implementing issue #313 (copilot generated) | ||
assertTrue(StringUtilities.isDate("2023-01-01")); | ||
assertTrue(StringUtilities.isDate("01/01/2023")); | ||
assertTrue(StringUtilities.isDate("01-01-2023")); | ||
assertTrue(StringUtilities.isDate("01.01.2023")); | ||
assertTrue(StringUtilities.isDate("2023/01/01")); | ||
assertTrue(StringUtilities.isDate("2023.01.01")); | ||
assertTrue(StringUtilities.isDate("2023 01 01")); | ||
assertTrue(StringUtilities.isDate("01 01 2023")); | ||
assertFalse(StringUtilities.isDate("2023-13-01")); | ||
assertFalse(StringUtilities.isDate("2023-01-32")); | ||
assertFalse(StringUtilities.isDate("2023/01/32")); | ||
assertFalse(StringUtilities.isDate("not a date")); | ||
|
||
assertTrue(StringUtilities.isDate("2023-12-31")); | ||
assertTrue(StringUtilities.isDate("12-31-2023")); | ||
assertTrue(StringUtilities.isDate("12-13-2023")); | ||
assertTrue(StringUtilities.isDate("13-12-2023")); | ||
assertFalse(StringUtilities.isDate("13-13-2023")); | ||
|
||
} | ||
} |