aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/scala
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/test/scala')
-rw-r--r--core/src/test/scala/com/softwaremill/sttp/UriTests.scala19
1 files changed, 17 insertions, 2 deletions
diff --git a/core/src/test/scala/com/softwaremill/sttp/UriTests.scala b/core/src/test/scala/com/softwaremill/sttp/UriTests.scala
index 3c54fd2..23fe3d5 100644
--- a/core/src/test/scala/com/softwaremill/sttp/UriTests.scala
+++ b/core/src/test/scala/com/softwaremill/sttp/UriTests.scala
@@ -50,8 +50,7 @@ class UriTests extends FunSuite with Matchers {
"http://example.com#f:g/h%20i",
Uri("http", None, "example.com", None, List("key=value"), Nil, None) ->
"http://example.com/key=value",
- Uri("http", "www.mikołak.net") ->
- "http://www.xn--mikoak-6db.net"
+ Uri("2001:db8::ff00:42:8329", 8080) -> "http://[2001:db8::ff00:42:8329]:8080"
)
for {
@@ -112,6 +111,22 @@ class UriTests extends FunSuite with Matchers {
}
}
+ val hostTestData = List(
+ "www.mikołak.net" -> "http://www.xn--mikoak-6db.net",
+ "192.168.1.0" -> "http://192.168.1.0",
+ "::1" -> "http://[::1]",
+ "2001:db8::ff00:42:8329" -> "http://[2001:db8::ff00:42:8329]",
+ "2001:0db8:0000:0000:0000:ff00:0042:8329" -> "http://[2001:0db8:0000:0000:0000:ff00:0042:8329]"
+ )
+
+ for {
+ (host, expected) <- hostTestData
+ } {
+ test(s"host $host should serialize to $expected") {
+ Uri(host).toString should be(s"$expected")
+ }
+ }
+
test("should convert from java URI") {
val uriAsString = "https://sub.example.com:8080/a/b/xyz?p1=v1&p2=v2#f"
Uri(URI.create(uriAsString)).toString should be(uriAsString)