Skip to content

Commit

Permalink
Start on test suite for Param
Browse files Browse the repository at this point in the history
  • Loading branch information
noelwelsh committed Feb 9, 2024
1 parent da3028b commit c600cc9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions core/jvm/src/test/scala/krop/route/ParamSuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2023 Creative Scala
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package krop.route

import munit.FunSuite
import scala.util.Success

class ParamSuite extends FunSuite {
test("Param.one parses valid parameter") {
assertEquals(Param.int.parse("1"), Success(1))
assertEquals(Param.int.parse("42"), Success(42))
}

test("Param.one fails to parse invalid parameter") {
assert(Param.int.parse("one").isFailure)
}
}
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/krop/route/Param.scala
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ object Param {
def mkString(separator: String): Param.All[String] = {
val quotedSeparator = Pattern.quote(separator)
Param.All(
"<String>",
s"<String>${separator}",
seq => Success(seq.mkString(separator)),
string => ArraySeq.unsafeWrapArray(string.split(quotedSeparator))
)
Expand Down

0 comments on commit c600cc9

Please sign in to comment.