Skip to content
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

Add (Abstract)StringAssert#as(Boolean|Byte|Short|Integer|Long|Float|Double) #2520

Closed
onacit opened this issue Mar 8, 2022 · 4 comments
Closed
Assignees
Milestone

Comments

@onacit
Copy link
Contributor

onacit commented Mar 8, 2022

Summary

This is a refined feature request derived from #2509.
Per @scordio's commented, it might be reasonable to add following signatures.

AbstractStringAssert#asBoolean() returns BooleanAssert

AbstractStringAssert#asByte() returns ByteAssert
AbstractStringAssert#asByte(int radix) returns ByteAssert

AbstractStringAssert#asShort() returns ShortAssert
AbstractStringAssert#asShort(int radix) returns ShortAssert

AbstractStringAssert#asInteger() returns IntegerAssert
AbstractStringAssert#asInteger(int radix) returns IntegerAssert

AbstractStringAssert#asLong() returns LongAssert
AbstractStringAssert#asLong(int radix) returns LongAssert

AbstractStringAssert#asFloat() returns FloatAssert

AbstractStringAssert#asDouble() returns DoubleAssert

NumberFormatException throwable from those parse...(String) methods, except the Boolean#parseBoolean, should be regarded as failing assertions.

Example

assertThat("yes")
//        .isNotNull() // implicit
        .asBoolean()
        .isTrue(); // fails
assertThat("32")
        .asInteger()
        .isEqualTo(32); // succeeds
assertThat(".0d")
        .asDouble()
        .isZero();
@hezean
Copy link
Contributor

hezean commented Apr 18, 2022

Hi, I am interested in this. If these modifications are considered necessary, can you assign me?

@scordio scordio added this to the 3.24.0 milestone Apr 21, 2022
@scordio scordio added the status: team discussion An issue we'd like to discuss as a team to make progress label Apr 21, 2022
@scordio
Copy link
Member

scordio commented Apr 21, 2022

Tentatively slated for 3.24.0 solely for the purpose of team discussion, keeping #2580 on hold.

@scordio scordio modified the milestones: 3.24.0, 3.25.0 Nov 14, 2022
@joel-costigliola joel-costigliola removed the status: team discussion An issue we'd like to discuss as a team to make progress label Jan 26, 2023
@joel-costigliola joel-costigliola self-assigned this Mar 5, 2023
@joel-costigliola
Copy link
Member

We are agreeing to this as it is limited to string assertions

@joel-costigliola
Copy link
Member

Addressed by #2580

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants