mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2024-12-12 09:30:52 +01:00
61-improve-unit-test-coverage
- Provided unit tests for g_map and 2p_map
This commit is contained in:
parent
67483c2a90
commit
0b91ba744a
@ -1,4 +1,4 @@
|
||||
// crdt is a golang implementation of a crdt
|
||||
// crdt provides go implementations for crdts
|
||||
package crdt
|
||||
|
||||
import (
|
||||
@ -65,10 +65,19 @@ func (g *GMap[K, D]) get(key uint64) Bucket[D] {
|
||||
}
|
||||
|
||||
func (g *GMap[K, D]) Get(key K) D {
|
||||
if !g.Contains(key) {
|
||||
var def D
|
||||
return def
|
||||
}
|
||||
|
||||
return g.get(g.clock.hashFunc(key)).Contents
|
||||
}
|
||||
|
||||
func (g *GMap[K, D]) Mark(key K) {
|
||||
if !g.Contains(key) {
|
||||
return
|
||||
}
|
||||
|
||||
g.lock.Lock()
|
||||
bucket := g.contents[g.clock.hashFunc(key)]
|
||||
bucket.Gravestone = true
|
||||
@ -89,7 +98,6 @@ func (g *GMap[K, D]) IsMarked(key K) bool {
|
||||
}
|
||||
|
||||
g.lock.RUnlock()
|
||||
|
||||
return marked
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user