Skip to content

Commit

Permalink
♻️ Refactor EmailAddress.Companion.fromString(Any) (#635)
Browse files Browse the repository at this point in the history
  • Loading branch information
LVMVRQUXL committed Mar 31, 2024
1 parent 96007a6 commit 0cbf46d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/commonMain/kotlin/org/kotools/types/EmailAddress.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class EmailAddress private constructor() {
*
* Here's an example of calling this function from Kotlin code:
*
* SAMPLE: EmailAddressCompanionKotlinSample.fromStringSample.md
* SAMPLE: EmailAddressCompanionKotlinSample.fromString_Any.md
* </details>
*
* <br>
Expand All @@ -81,7 +81,7 @@ public class EmailAddress private constructor() {
*
* Here's an example of calling this function from Java code:
*
* SAMPLE: EmailAddressCompanionJavaSample.fromStringSample.md
* SAMPLE: EmailAddressCompanionJavaSample.fromString_Any.md
* </details>
* <br>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void patternSample() {
System.out.println(pattern); // ^\S+@\S+\.\S+$
} // END

void fromStringSample() {
void fromString_Any() {
final Object value = "[email protected]";
try {
EmailAddress.fromString(value); // TABS: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ internal object EmailAddressCompanionKotlinSample {
println(pattern) // ^\S+@\S+\.\S+$
} // END

fun fromStringSample() {
@Suppress("FunctionName")
fun fromString_Any() {
val value: Any = "[email protected]"
val result: Result<EmailAddress> = kotlin.runCatching {
EmailAddress.fromString(value) // TABS: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ void patternSample_should_pass() {
}

@Test
void fromStringSample_should_pass() {
void fromString_Any_should_pass() {
final EmailAddressCompanionJavaSample sample =
new EmailAddressCompanionJavaSample();
final String actual = Assertions.assertDoesNotThrow(
() -> SystemLambda.tapSystemOut(sample::fromStringSample)
() -> SystemLambda.tapSystemOut(sample::fromString_Any)
).trim();
final String expected = "success";
Assertions.assertEquals(expected, actual);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ class EmailAddressCompanionKotlinSampleTest {
}

@Test
fun fromStringSample_should_pass() {
val actual: Boolean = SystemLambda
.tapSystemOut(Sample::fromStringSample)
fun `fromString(Any) should pass`() {
val actual: Boolean = SystemLambda.tapSystemOut(Sample::fromString_Any)
.trim()
.toBooleanStrict()
assertTrue(actual)
Expand Down

0 comments on commit 0cbf46d

Please sign in to comment.