From 492c612f9d2b552cedca6cd7202c768b26585ed3 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 24 Dec 2016 00:25:15 +0300 Subject: [PATCH] tests/utimeq_stable: Test for partial stability of utimeq queuing. --- tests/extmod/utimeq_stable.py | 23 +++++++++++++++++++++++ tests/extmod/utimeq_stable.py.exp | 1 + 2 files changed, 24 insertions(+) create mode 100644 tests/extmod/utimeq_stable.py create mode 100644 tests/extmod/utimeq_stable.py.exp diff --git a/tests/extmod/utimeq_stable.py b/tests/extmod/utimeq_stable.py new file mode 100644 index 000000000..9f6ba76d4 --- /dev/null +++ b/tests/extmod/utimeq_stable.py @@ -0,0 +1,23 @@ +try: + from utimeq import utimeq +except ImportError: + print("SKIP") + import sys + sys.exit() + +h = utimeq(10) + +# Check that for 2 same-key items, the queue is stable (pops items +# in the same order they were pushed). Unfortunately, this no longer +# holds for more same-key values, as the underlying heap structure +# is not stable itself. +h.push(100, 20, 0) +h.push(100, 10, 0) + +res = [0, 0, 0] +h.pop(res) +assert res == [100, 20, 0] +h.pop(res) +assert res == [100, 10, 0] + +print("OK") diff --git a/tests/extmod/utimeq_stable.py.exp b/tests/extmod/utimeq_stable.py.exp new file mode 100644 index 000000000..d86bac9de --- /dev/null +++ b/tests/extmod/utimeq_stable.py.exp @@ -0,0 +1 @@ +OK