Skip to content

Commit

Permalink
add obremmap test
Browse files Browse the repository at this point in the history
  • Loading branch information
rmgk committed Aug 27, 2024
1 parent 6c6e284 commit 7fa1520
Showing 1 changed file with 33 additions and 0 deletions.
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)
}
}

0 comments on commit 7fa1520

Please sign in to comment.