Skip to content

Commit

Permalink
fix: the unit test of type/set (OpenAtomFoundation#1617)
Browse files Browse the repository at this point in the history
* test: optimize the return results of srandmember to avoid approximate results

* fix: use last_seed for random engine
  • Loading branch information
machinly authored and lqxhub committed Jul 2, 2023
1 parent e480f24 commit 6072bc0
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions tests/unit/type/set.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,7 @@ start_server {
create_set myset $contents
unset -nocomplain myset
array set myset {}
for {set i 0} {$i < 500} {incr i} {
sleep 10
for {set i 0} {$i < 100} {incr i} {
set myset([r srandmember myset]) 1
}
assert_equal $contents [lsort [array names myset]]
Expand Down Expand Up @@ -359,15 +358,14 @@ start_server {
set iterations 1000
while {$iterations != 0} {
incr iterations -1
set res [r srandmember myset -20]
set res [r srandmember myset -10]
foreach ele $res {
set auxset($ele) 1
}
if {[lsort [array names myset]] eq
[lsort [array names auxset]]} {
break;
}
sleep 15
}
assert {$iterations != 0}

Expand Down Expand Up @@ -404,15 +402,14 @@ start_server {
set iterations 1000
while {$iterations != 0} {
incr iterations -1
set res [r srandmember myset -20]
set res [r srandmember myset -10]
foreach ele $res {
set auxset($ele) 1
}
if {[lsort [array names myset]] eq
[lsort [array names auxset]]} {
break;
}
sleep 15
}
assert {$iterations != 0}
}
Expand Down

0 comments on commit 6072bc0

Please sign in to comment.