-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ScalaJS Compilation by Removing JVM-specific java.util.Objects Re…
…ferences in PathCodecPlatformSpecific (#3155)
- Loading branch information
Showing
2 changed files
with
47 additions
and
6 deletions.
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
35 changes: 35 additions & 0 deletions
35
zio-http/js/src/test/scala/zio/http/PathCodecPlatformSpecificSpec.scala
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,35 @@ | ||
package zio.http.codec | ||
|
||
import zio._ | ||
import zio.test.Assertion._ | ||
import zio.test._ | ||
|
||
object PathCodecPlatformSpecificSpec extends ZIOSpecDefault { | ||
|
||
def spec = suite("PathCodecJSPlatformSpecificSpec")( | ||
test("parseInt should correctly parse a valid integer from a CharSequence") { | ||
val charSequence = "12345" | ||
val result = new PathCodecPlatformSpecific {}.parseInt(charSequence, 0, charSequence.length, 10) | ||
assert(result)(equalTo(12345)) | ||
}, | ||
test("parseInt should throw an error for an invalid radix") { | ||
val charSequence = "12345" | ||
val result = ZIO.attempt { | ||
new PathCodecPlatformSpecific {}.parseInt(charSequence, 0, charSequence.length, Character.MAX_RADIX + 1) | ||
}.either | ||
assertZIO(result)(isLeft(hasMessage(containsString("radix")))) | ||
}, | ||
test("parseLong should correctly parse a valid long from a CharSequence") { | ||
val charSequence = "123456789012345" | ||
val result = new PathCodecPlatformSpecific {}.parseLong(charSequence, 0, charSequence.length, 10) | ||
assert(result)(equalTo(123456789012345L)) | ||
}, | ||
test("parseLong should throw an error for an invalid input") { | ||
val charSequence = "invalid123" | ||
val result = ZIO.attempt { | ||
new PathCodecPlatformSpecific {}.parseLong(charSequence, 0, charSequence.length, 10) | ||
}.either | ||
assertZIO(result)(isLeft(hasMessage(containsString("Error at index")))) | ||
}, | ||
) | ||
} |