Skip to content

Commit

Permalink
Adding test scenarios related to leading and trailing spaces when par…
Browse files Browse the repository at this point in the history
…sing string to Long

PiperOrigin-RevId: 710059358
  • Loading branch information
java-team-github-bot authored and Google Java Core Libraries committed Dec 27, 2024
1 parent 800b3d4 commit 58fb2eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,9 @@ public void testTryParse() {
assertThat(Longs.tryParse("-")).isNull();
assertThat(Longs.tryParse("+1")).isNull();
assertThat(Longs.tryParse("999999999999999999999999")).isNull();
assertThat(Longs.tryParse(" ")).isNull();
assertThat(Longs.tryParse("1 ")).isNull();
assertThat(Longs.tryParse(" 1")).isNull();
assertWithMessage("Max long + 1")
.that(Longs.tryParse(BigInteger.valueOf(MAX_VALUE).add(BigInteger.ONE).toString()))
.isNull();
Expand Down
3 changes: 3 additions & 0 deletions guava-tests/test/com/google/common/primitives/LongsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,9 @@ public void testTryParse() {
assertThat(Longs.tryParse("-")).isNull();
assertThat(Longs.tryParse("+1")).isNull();
assertThat(Longs.tryParse("999999999999999999999999")).isNull();
assertThat(Longs.tryParse(" ")).isNull();
assertThat(Longs.tryParse("1 ")).isNull();
assertThat(Longs.tryParse(" 1")).isNull();
assertWithMessage("Max long + 1")
.that(Longs.tryParse(BigInteger.valueOf(MAX_VALUE).add(BigInteger.ONE).toString()))
.isNull();
Expand Down

0 comments on commit 58fb2eb

Please sign in to comment.