From 0863a2af75583b976aee3171585685b2524d0874 Mon Sep 17 00:00:00 2001 From: adamw Date: Sat, 8 Jul 2017 21:27:52 +0200 Subject: Simple URI tests --- .../softwaremill/sttp/UriInterpolatorTests.scala | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala (limited to 'tests/src/test/scala/com/softwaremill') diff --git a/tests/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala b/tests/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala new file mode 100644 index 0000000..57bb6af --- /dev/null +++ b/tests/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala @@ -0,0 +1,24 @@ +package com.softwaremill.sttp + +import java.net.URI + +import org.scalatest.{FlatSpec, Matchers} + +class UriInterpolatorTests extends FlatSpec with Matchers { + val v1 = "y" + val v2 = "a c" + val v2encoded = "a%20c" + + val testData: List[(URI, String)] = List( + (uri"http://example.com", "http://example.com"), + (uri"http://example.com?x=y", "http://example.com?x=y"), + (uri"http://example.com?x=$v1", s"http://example.com?x=$v1"), + (uri"http://example.com?x=$v2", s"http://example.com?x=$v2encoded") + ) + + for (((interpolated, expected), i) <- testData.zipWithIndex) { + it should s"interpolate to $expected ($i)" in { + interpolated should be (new URI(expected)) + } + } +} -- cgit v1.2.3