mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-03 14:13:09 +00:00
add generics test
This commit is contained in:
parent
ee02aa8322
commit
bcce5331bb
@ -10,13 +10,21 @@ include pkg/datastore/threads/sharedptr
|
||||
include pkg/datastore/threads/databuffer
|
||||
|
||||
|
||||
type TestObj = object
|
||||
val: ref int
|
||||
type
|
||||
TestObj = object
|
||||
val: ref int
|
||||
|
||||
TestObjGen[T] = object
|
||||
val: ref T
|
||||
|
||||
proc `=destroy`(obj: var TestObj) =
|
||||
echo "test obj destroy"
|
||||
obj.val[] = 0
|
||||
|
||||
proc `=destroy`[T: int](obj: var TestObjGen[T]) =
|
||||
echo "test obj destroy"
|
||||
obj.val[] = 0
|
||||
|
||||
proc destroyTest(intref: ref int) =
|
||||
let a: SharedPtr[TestObj] = newSharedPtr(unsafeIsolate TestObj(val: intref))
|
||||
echo "a[]: ", a[]
|
||||
@ -77,3 +85,15 @@ suite "Share buffer test":
|
||||
finally:
|
||||
a.release()
|
||||
check intref[] == 0
|
||||
|
||||
test "test destroy release generic no proc":
|
||||
echo "\nintref setup:\n"
|
||||
let intref: ref int = new(ref int)
|
||||
intref[] = 30
|
||||
var b: SharedPtr[TestObjGen[int]] = newSharedPtr(unsafeIsolate TestObjGen[int](val: intref))
|
||||
try:
|
||||
echo "a[]: ", b[]
|
||||
check b[].val[] == 30
|
||||
finally:
|
||||
b.release()
|
||||
check intref[] == 0
|
||||
Loading…
x
Reference in New Issue
Block a user