mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2025-03-05 00:51:16 +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
|
package crdt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -65,10 +65,19 @@ func (g *GMap[K, D]) get(key uint64) Bucket[D] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *GMap[K, D]) Get(key K) 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
|
return g.get(g.clock.hashFunc(key)).Contents
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GMap[K, D]) Mark(key K) {
|
func (g *GMap[K, D]) Mark(key K) {
|
||||||
|
if !g.Contains(key) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
g.lock.Lock()
|
g.lock.Lock()
|
||||||
bucket := g.contents[g.clock.hashFunc(key)]
|
bucket := g.contents[g.clock.hashFunc(key)]
|
||||||
bucket.Gravestone = true
|
bucket.Gravestone = true
|
||||||
@ -89,7 +98,6 @@ func (g *GMap[K, D]) IsMarked(key K) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
g.lock.RUnlock()
|
g.lock.RUnlock()
|
||||||
|
|
||||||
return marked
|
return marked
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user