Lorem Ipsum for testing

#1

It would be cool if there were an LoremIpsum interface in scala. Of course it is easy to do the following, for testing various things with strings and lists of strings.

Of course it is trivial to create one myself.

  test("tree map reduce 3"){
    val loremBlock = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
    val loremWords = loremBlock.split(" ")

      assert(loremWords.map(_.length).foldLeft(0)(_+_) == Aux.treeMapReduce(loremWords)(0)(_.length,_+_))
  }
#2

You might want to look at ScalaCheck or the property-based testing support in ScalaTest. They provide a general mechanism for generating good random test data to test your code and help you find corner cases.

1 Like