Skip to content

Commit 492c612

Browse files
committed
tests/utimeq_stable: Test for partial stability of utimeq queuing.
1 parent 7327966 commit 492c612

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

tests/extmod/utimeq_stable.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
try:
2+
from utimeq import utimeq
3+
except ImportError:
4+
print("SKIP")
5+
import sys
6+
sys.exit()
7+
8+
h = utimeq(10)
9+
10+
# Check that for 2 same-key items, the queue is stable (pops items
11+
# in the same order they were pushed). Unfortunately, this no longer
12+
# holds for more same-key values, as the underlying heap structure
13+
# is not stable itself.
14+
h.push(100, 20, 0)
15+
h.push(100, 10, 0)
16+
17+
res = [0, 0, 0]
18+
h.pop(res)
19+
assert res == [100, 20, 0]
20+
h.pop(res)
21+
assert res == [100, 10, 0]
22+
23+
print("OK")

tests/extmod/utimeq_stable.py.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
OK

0 commit comments

Comments
 (0)