зеркало из https://github.com/mozilla/bugbug.git
72 строки
1.4 KiB
Python
72 строки
1.4 KiB
Python
|
# -*- coding: utf-8 -*-
|
||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||
|
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||
|
|
||
|
from bugbug import utils
|
||
|
|
||
|
|
||
|
def test_exp_queue():
|
||
|
q = utils.ExpQueue(0, 4, 0)
|
||
|
q[0] = 1
|
||
|
assert q[0] == 1
|
||
|
q[0] = 2
|
||
|
assert q[0] == 2
|
||
|
|
||
|
q = utils.ExpQueue(366, 91, 0)
|
||
|
assert q[366] == 0
|
||
|
assert q[276] == 0
|
||
|
q[366] += 1
|
||
|
assert q[367] == 1
|
||
|
assert q[277] == 0
|
||
|
|
||
|
q = utils.ExpQueue(0, 4, 0)
|
||
|
assert q[0] == 0
|
||
|
q[0] += 1
|
||
|
assert q[0] == 1
|
||
|
q[0] += 1
|
||
|
assert q[0] == 2
|
||
|
assert q[1] == 2
|
||
|
q[1] += 1
|
||
|
assert q[1] == 3
|
||
|
assert q[9] == 3
|
||
|
q[9] += 1
|
||
|
assert q[9] == 4
|
||
|
assert q[6] == 3
|
||
|
assert q[11] == 4
|
||
|
q[11] += 1
|
||
|
assert q[11] == 5
|
||
|
q[12] += 1
|
||
|
assert q[12] == 6
|
||
|
q[13] += 1
|
||
|
assert q[13] == 7
|
||
|
q[14] += 1
|
||
|
assert q[14] == 8
|
||
|
q[15] += 1
|
||
|
assert q[15] == 9
|
||
|
|
||
|
q = utils.ExpQueue(0, 4, 0)
|
||
|
assert q[0] == 0
|
||
|
q[0] += 1
|
||
|
assert q[0] == 1
|
||
|
assert q[1] == 1
|
||
|
assert q[9] == 1
|
||
|
q[9] += 1
|
||
|
assert q[9] == 2
|
||
|
assert q[10] == 2
|
||
|
assert q[8] == 1
|
||
|
assert q[7] == 1
|
||
|
assert q[6] == 1
|
||
|
|
||
|
q = utils.ExpQueue(9, 3, 0)
|
||
|
assert q[8] == 0
|
||
|
assert q[9] == 0
|
||
|
q[9] += 1
|
||
|
assert q[11] == 1
|
||
|
assert q[10] == 1
|
||
|
assert q[8] == 0
|
||
|
assert q[11] == 1
|
||
|
assert q[8] == 0
|
||
|
assert q[9] == 1
|
||
|
assert q[12] == 1
|