-
-
Notifications
You must be signed in to change notification settings - Fork 230
add CharSequence.length feature extractor (fluent/infix) #2106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
robstoll
merged 2 commits into
robstoll:main
from
joonseolee:feature/add-charsequence-length
Dec 4, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
34 changes: 34 additions & 0 deletions
34
...src/commonMain/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceFeatureExtractors.kt
This file contains hidden or 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,34 @@ | ||
| package ch.tutteli.atrium.api.fluent.en_GB | ||
|
|
||
| import ch.tutteli.atrium.creating.Expect | ||
| import ch.tutteli.atrium.logic._logic | ||
| import ch.tutteli.atrium.logic.length | ||
|
|
||
|
|
||
| /** | ||
| * Creates an [Expect] for the property [CharSequence.length] of the subject of `this` expectation, | ||
| * so that further fluent calls are assertions about it. | ||
| * | ||
| * @return The newly created [Expect] for the extracted feature | ||
| * | ||
| * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceExpectationSamples.lengthFeature | ||
| * | ||
| * @since 1.3.0 | ||
| */ | ||
| val <T : CharSequence> Expect<T>.length: Expect<Int> | ||
| get() = _logic.length().transform() | ||
|
|
||
| /** | ||
| * Expects that the property [CharSequence.length] of the subject of `this` expectation | ||
| * holds all assertions the given [assertionCreator] creates for it and | ||
| * returns an [Expect] for the current subject of `this` expectation. | ||
| * | ||
| * @return an [Expect] for the subject of `this` expectation. | ||
| * | ||
| * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceExpectationSamples.length | ||
| * | ||
| * @since 1.3.0 | ||
| */ | ||
| fun <T : CharSequence> Expect<T>.length(assertionCreator: Expect<Int>.() -> Unit): Expect<T> = | ||
| _logic.length().collectAndAppend(assertionCreator) | ||
|
|
This file contains hidden or 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
27 changes: 27 additions & 0 deletions
27
.../kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/CharSequenceFeatureExtractorSamples.kt
This file contains hidden or 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,27 @@ | ||
| package ch.tutteli.atrium.api.fluent.en_GB.samples | ||
|
|
||
| import ch.tutteli.atrium.api.fluent.en_GB.length | ||
| import ch.tutteli.atrium.api.fluent.en_GB.toBeGreaterThan | ||
| import ch.tutteli.atrium.api.verbs.internal.expect | ||
| import kotlin.test.Test | ||
|
|
||
| class CharSequenceFeatureExtractorSamples { | ||
|
|
||
| @Test | ||
| fun lengthFeature() { | ||
| expect("Hello").length.toBeGreaterThan(3) | ||
|
|
||
| fails { | ||
| expect("Hi").length.toBeGreaterThan(3) | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| fun length() { | ||
| expect("Hello").length { toBeGreaterThan(3) } | ||
|
|
||
| fails { | ||
| expect("Hi").length { toBeGreaterThan(3) } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
1 change: 0 additions & 1 deletion
1
...onTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/CharSequenceExpectationSamples.kt
This file contains hidden or 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
33 changes: 33 additions & 0 deletions
33
...t/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/CharSequenceFeatureExtractorSamples.kt
This file contains hidden or 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,33 @@ | ||
| package ch.tutteli.atrium.api.infix.en_GB.samples | ||
|
|
||
| import ch.tutteli.atrium.api.infix.en_GB.it | ||
| import ch.tutteli.atrium.api.infix.en_GB.length | ||
| import ch.tutteli.atrium.api.infix.en_GB.toEqual | ||
| import ch.tutteli.atrium.api.verbs.expect | ||
| import kotlin.test.Test | ||
|
|
||
| class CharSequenceFeatureExtractorSamples { | ||
|
|
||
| @Test | ||
| fun lengthFeature() { | ||
| expect("Hello").length toEqual 5 | ||
|
|
||
| fails { | ||
| expect("Hi").length toEqual 3 | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| fun length() { | ||
| expect("Hello") length { | ||
| it toEqual 5 | ||
| } | ||
|
|
||
| fails { | ||
| expect("Hi") length { | ||
| it toEqual 3 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.