Sha256: 6ed2a0e332990c98ed67127960f34f0cd85e577714c1b44be978237c9122b148
Contents?: true
Size: 2 KB
Versions: 74
Compression:
Stored size: 2 KB
Contents
import java.io.File import testgen.TestSuiteBuilder.{toString, _} import testgen._ object PalindromeProductsTestGenerator { def main(args: Array[String]): Unit = { val file = new File("src/main/resources/palindrome-products.json") def toStringFromMap(m: Map[String, Any]): String = s"Some((${m("value").toString}, " + s"Set(${m("factors").asInstanceOf[List[List[Int]]].map(xs => "(" + xs.map(_.toString).mkString(", ") + ")").mkString(", ")})))" def toString(expected: CanonicalDataParser.Expected): String = { expected match { case Left(_) => "None" case Right(m: Map[String, any]) => toStringFromMap(m) } } def fromLabeledTest(argNames: String*): ToTestCaseData = withLabeledTest { sut => labeledTest => val args = sutArgs(labeledTest.result, argNames: _*) val property = labeledTest.property val sutCall = s"""$sut($args).$property""" val expected = toString(labeledTest.expected) TestCaseData(labeledTest.description, sutCall, expected) } val code = TestSuiteBuilder.build(file, fromLabeledTest("input_min", "input_max"), Seq(), Seq("// PalindromeProducts largest call is expecting a return type of", "// Option[(Int, Set[(Int, Int)])] - None is expected for error cases.", "// Some is expected for valid cases. The first element of the tuple ", "// is the largest palindrome product value. The second element of the", "// tuple is the list of factors.", "// PalindromeProducts smallest call is expecting a return type of", "// Option[(Int, Set[(Int, Int)])] - None is expected for error cases.", "// Some is expected for valid cases. The first element of the tuple ", "// is the smallest palindrome product value. The second element of the", "// tuple is the list of factors.")) println(s"-------------") println(code) println(s"-------------") } }
Version data entries
74 entries across 74 versions & 1 rubygems