File tree Expand file tree Collapse file tree
quicklens/src/test/scala/com/softwaremill/quicklens Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .softwaremill .quicklens
2+
3+ import org .scalatest .flatspec .AnyFlatSpec
4+ import org .scalatest .matchers .should .Matchers
5+
6+ class ModifySeqAtOrElseTest extends AnyFlatSpec with Matchers {
7+
8+ case class Item (name : String )
9+
10+ it should " modify an existing element using atOrElse" in {
11+ val items = List (Item (" a" ), Item (" b" ))
12+ modify(items)(_.atOrElse(1 , Item (" default" )).name).using(_.toUpperCase) should be(
13+ List (Item (" a" ), Item (" B" ))
14+ )
15+ }
16+
17+ it should " use the default for a missing index instead of throwing" in {
18+ val items = List (Item (" a" ), Item (" b" ))
19+ modify(items)(_.atOrElse(5 , Item (" default" )).name).using(_.toUpperCase) should be(
20+ List (Item (" a" ), Item (" b" ), Item (" DEFAULT" ))
21+ )
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments