-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add
EmailAddress.Companion.PATTERN
constant property (#635)
Adds the constant property with tests, tested Kotlin and Java code samples, and dumps the Application Binary Interface (ABI).
- Loading branch information
Showing
7 changed files
with
118 additions
and
1 deletion.
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
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
15 changes: 15 additions & 0 deletions
15
src/commonTest/kotlin/org/kotools/types/EmailAddressTest.kt
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,15 @@ | ||
package org.kotools.types | ||
|
||
import kotools.types.experimental.ExperimentalKotoolsTypesApi | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
@OptIn(ExperimentalKotoolsTypesApi::class) | ||
class EmailAddressCompanionTest { | ||
@Test | ||
fun pattern_should_pass() { | ||
val actual: String = EmailAddress.PATTERN | ||
val expected = "^\\S+@\\S+\\.\\S+\$" | ||
assertEquals(expected, actual) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
subprojects/samples/src/main/java/EmailAddressCompanionJavaSample.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,8 @@ | ||
package org.kotools.types; | ||
|
||
class EmailAddressCompanionJavaSample { | ||
void patternSample() { | ||
final String pattern = EmailAddress.PATTERN; | ||
System.out.println(pattern); // ^\S+@\S+\.\S+$ | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
subprojects/samples/src/main/kotlin/EmailAddressCompanionKotlinSample.kt
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,11 @@ | ||
package org.kotools.types | ||
|
||
import kotools.types.experimental.ExperimentalKotoolsTypesApi | ||
|
||
internal object EmailAddressCompanionKotlinSample { | ||
@OptIn(ExperimentalKotoolsTypesApi::class) | ||
fun patternSample() { | ||
val pattern: String = EmailAddress.PATTERN | ||
println(pattern) // ^\S+@\S+\.\S+$ | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
subprojects/samples/src/test/java/EmailAddressCompanionJavaSampleTest.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,18 @@ | ||
package org.kotools.types; | ||
|
||
import com.github.stefanbirkner.systemlambda.SystemLambda; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class EmailAddressCompanionJavaSampleTest { | ||
@Test | ||
void patternSample_should_pass() { | ||
final EmailAddressCompanionJavaSample sample = | ||
new EmailAddressCompanionJavaSample(); | ||
final String actual = Assertions.assertDoesNotThrow( | ||
() -> SystemLambda.tapSystemOut(sample::patternSample).trim() | ||
); | ||
final String expected = "^\\S+@\\S+\\.\\S+$"; | ||
Assertions.assertEquals(expected, actual); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
subprojects/samples/src/test/kotlin/EmailAddressCompanionKotlinSampleTest.kt
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,16 @@ | ||
package org.kotools.types | ||
|
||
import com.github.stefanbirkner.systemlambda.SystemLambda | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class EmailAddressCompanionKotlinSampleTest { | ||
@Test | ||
fun patternSample_should_pass() { | ||
val actual: String = SystemLambda | ||
.tapSystemOut(EmailAddressCompanionKotlinSample::patternSample) | ||
.trim() | ||
val expected = "^\\S+@\\S+\\.\\S+\$" | ||
assertEquals(expected, actual) | ||
} | ||
} |