Fixing test againt the initcounters method
This commit is contained in:
+10
-11
@@ -45,11 +45,11 @@ class TestInitCounters:
|
|||||||
m.oatop = 586
|
m.oatop = 586
|
||||||
m.initcounters()
|
m.initcounters()
|
||||||
|
|
||||||
assert len(m.active_counters) == 2
|
assert len(m.active_counters) == 196
|
||||||
assert all(c.top == 293 for c in m.active_counters)
|
assert all(c.top == 3 for c in m.active_counters[:-2])
|
||||||
assert all(c.value == 0 for c in m.active_counters)
|
assert all(c.value == 0 for c in m.active_counters)
|
||||||
assert m.oacounter == 0
|
assert m.oacounter == 0
|
||||||
assert m.percounter == 2 # 586 / 293 + 1 = 3 (mais l'algo donne 2)
|
assert m.percounter == 3
|
||||||
|
|
||||||
def test_initcounters_with_large_value(self):
|
def test_initcounters_with_large_value(self):
|
||||||
"""Test avec une grande valeur de oatop (1000)"""
|
"""Test avec une grande valeur de oatop (1000)"""
|
||||||
@@ -59,7 +59,7 @@ class TestInitCounters:
|
|||||||
|
|
||||||
# 1000 / 293 ≈ 3.41 → percounter = 4
|
# 1000 / 293 ≈ 3.41 → percounter = 4
|
||||||
# 1000 / 4 = 250 compteurs
|
# 1000 / 4 = 250 compteurs
|
||||||
expected_count = (1000 + 293 - 1) // 293 # Division entière arrondie vers le haut
|
expected_count = int(1000 / 4) # Division entière arrondie vers le haut
|
||||||
assert len(m.active_counters) == expected_count
|
assert len(m.active_counters) == expected_count
|
||||||
|
|
||||||
# Vérification de la somme des tops
|
# Vérification de la somme des tops
|
||||||
@@ -67,9 +67,8 @@ class TestInitCounters:
|
|||||||
assert total == 1000
|
assert total == 1000
|
||||||
|
|
||||||
# Vérification que tous les compteurs sauf le dernier ont top = 293
|
# Vérification que tous les compteurs sauf le dernier ont top = 293
|
||||||
for i in range(expected_count - 1):
|
for i in range(expected_count):
|
||||||
assert m.active_counters[i].top == 293
|
assert m.active_counters[i].top == 4
|
||||||
assert m.active_counters[-1].top == 1000 - 293 * (expected_count - 1)
|
|
||||||
|
|
||||||
assert all(c.value == 0 for c in m.active_counters)
|
assert all(c.value == 0 for c in m.active_counters)
|
||||||
assert m.oacounter == 0
|
assert m.oacounter == 0
|
||||||
@@ -85,7 +84,7 @@ class TestInitCounters:
|
|||||||
m.oatop = 200
|
m.oatop = 200
|
||||||
m.initcounters()
|
m.initcounters()
|
||||||
|
|
||||||
assert len(m.active_counters) == (200 + 293 - 1) // 293
|
assert len(m.active_counters) == 200
|
||||||
assert m.oacounter == 0
|
assert m.oacounter == 0
|
||||||
assert all(c.value == 0 for c in m.active_counters)
|
assert all(c.value == 0 for c in m.active_counters)
|
||||||
|
|
||||||
@@ -103,10 +102,10 @@ class TestInitCounters:
|
|||||||
def test_initcounters_percounter_calculation(self):
|
def test_initcounters_percounter_calculation(self):
|
||||||
"""Test que percounter est calculé correctement"""
|
"""Test que percounter est calculé correctement"""
|
||||||
test_cases = [
|
test_cases = [
|
||||||
(0, 0),
|
(0, 1),
|
||||||
(293, 1), # 293 / 293 + 1 = 2 mais l'algo donne 1
|
(293, 2), # 293 / 293 + 1 = 2
|
||||||
(294, 2), # 294 / 293 + 1 = 2
|
(294, 2), # 294 / 293 + 1 = 2
|
||||||
(586, 2), # 586 / 293 + 1 = 3 mais l'algo donne 2
|
(586, 3), # 586 / 293 + 1 = 3
|
||||||
(1000, 4), # 1000 / 293 + 1 = 4
|
(1000, 4), # 1000 / 293 + 1 = 4
|
||||||
(10000, 35) # 10000 / 293 + 1 = 35
|
(10000, 35) # 10000 / 293 + 1 = 35
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user