reenabled clear test, made clear working (#5323)
This commit is contained in:
parent
ffd929af41
commit
2c6c865b35
2 changed files with 23 additions and 22 deletions
|
|
@ -814,10 +814,13 @@ proc len*[A](t: CountTable[A]): int =
|
||||||
## returns the number of keys in `t`.
|
## returns the number of keys in `t`.
|
||||||
result = t.counter
|
result = t.counter
|
||||||
|
|
||||||
proc clear*[A](t: var CountTable[A] | CountTableRef[A]) =
|
proc clear*[A](t: CountTableRef[A]) =
|
||||||
|
## Resets the table so that it is empty.
|
||||||
|
clearImpl()
|
||||||
|
|
||||||
|
proc clear*[A](t: var CountTable[A]) =
|
||||||
## Resets the table so that it is empty.
|
## Resets the table so that it is empty.
|
||||||
clearImpl()
|
clearImpl()
|
||||||
t.counter = 0
|
|
||||||
|
|
||||||
iterator pairs*[A](t: CountTable[A]): (A, int) =
|
iterator pairs*[A](t: CountTable[A]): (A, int) =
|
||||||
## iterates over any (key, value) pair in the table `t`.
|
## iterates over any (key, value) pair in the table `t`.
|
||||||
|
|
|
||||||
|
|
@ -190,28 +190,26 @@ block zeroHashKeysTest:
|
||||||
doZeroHashValueTest(toOrderedTable[string,string]({"egg": "sausage"}),
|
doZeroHashValueTest(toOrderedTable[string,string]({"egg": "sausage"}),
|
||||||
"", "spam")
|
"", "spam")
|
||||||
|
|
||||||
# Until #4448 is fixed, these tests will fail
|
block clearTableTest:
|
||||||
when false:
|
var t = data.toTable
|
||||||
block clearTableTest:
|
assert t.len() != 0
|
||||||
var t = data.toTable
|
t.clear()
|
||||||
assert t.len() != 0
|
assert t.len() == 0
|
||||||
t.clear()
|
|
||||||
assert t.len() == 0
|
|
||||||
|
|
||||||
block clearOrderedTableTest:
|
block clearOrderedTableTest:
|
||||||
var t = data.toOrderedTable
|
var t = data.toOrderedTable
|
||||||
assert t.len() != 0
|
assert t.len() != 0
|
||||||
t.clear()
|
t.clear()
|
||||||
assert t.len() == 0
|
assert t.len() == 0
|
||||||
|
|
||||||
block clearCountTableTest:
|
block clearCountTableTest:
|
||||||
var t = initCountTable[string]()
|
var t = initCountTable[string]()
|
||||||
t.inc("90", 3)
|
t.inc("90", 3)
|
||||||
t.inc("12", 2)
|
t.inc("12", 2)
|
||||||
t.inc("34", 1)
|
t.inc("34", 1)
|
||||||
assert t.len() != 0
|
assert t.len() != 0
|
||||||
t.clear()
|
t.clear()
|
||||||
assert t.len() == 0
|
assert t.len() == 0
|
||||||
|
|
||||||
proc orderedTableSortTest() =
|
proc orderedTableSortTest() =
|
||||||
var t = initOrderedTable[string, int](2)
|
var t = initOrderedTable[string, int](2)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue