Comparing collection contents with ScalaTest

后端 未结 2 697
予麋鹿
予麋鹿 2020-12-24 10:59

I\'m trying to unit-test some Scala that is very collection-heavy. These collections are returned as Iterable[T], so I am interested in the contents of

2条回答
  •  無奈伤痛
    2020-12-24 11:40

    Meanwhile you can use

    Iterable(2, 1) should contain theSameElementsAs Iterable(1, 2)
    

    To test the ordered set you have to convert it to a sequence.

    Set(1, 2).toSeq should contain theSameElementsInOrderAs List(1, 2)
    

提交回复
热议问题