-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
Modules/RDTs/src/test/scala/test/rdts/bespoke/ObserveRemoveMapTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package test.rdts.bespoke | ||
|
||
import rdts.base.{Lattice, LocalUid} | ||
import rdts.datatypes.contextual.ObserveRemoveMap | ||
import rdts.dotted.Obrem | ||
import rdts.time.Dot | ||
|
||
class ObserveRemoveMapTest extends munit.FunSuite { | ||
|
||
given Lattice[Dot] = Lattice.assertEquals | ||
|
||
test("basic usage") { | ||
val obremmap = Obrem(ObserveRemoveMap.empty[String, Dot]) | ||
|
||
given replicaId: LocalUid = LocalUid.gen() | ||
|
||
val added = obremmap.mod{ ctx ?=> current => | ||
val nextDot = ctx.nextDot(replicaId.uid) | ||
current.update("Hi!", nextDot) | ||
} | ||
|
||
assert(added.data.contains("Hi!")) | ||
|
||
|
||
val remove = added.mod{ ctx ?=> current => | ||
current.remove("Hi!") | ||
} | ||
|
||
val merged = added `merge` remove | ||
|
||
assertEquals(merged.data.entries.toMap, Map.empty) | ||
} | ||
} |