From 3d47bd6c1c7c3498271f09adc5a757787abea349 Mon Sep 17 00:00:00 2001 From: edipretoro Date: Wed, 15 Jul 2026 21:11:05 +0200 Subject: [PATCH] Fixing test againt the initcounters method --- test_initcounter.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/test_initcounter.py b/test_initcounter.py index 6f648ea..31e061e 100644 --- a/test_initcounter.py +++ b/test_initcounter.py @@ -45,11 +45,11 @@ class TestInitCounters: m.oatop = 586 m.initcounters() - assert len(m.active_counters) == 2 - assert all(c.top == 293 for c in m.active_counters) + assert len(m.active_counters) == 196 + assert all(c.top == 3 for c in m.active_counters[:-2]) assert all(c.value == 0 for c in m.active_counters) 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): """Test avec une grande valeur de oatop (1000)""" @@ -59,7 +59,7 @@ class TestInitCounters: # 1000 / 293 ≈ 3.41 → percounter = 4 # 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 # Vérification de la somme des tops @@ -67,9 +67,8 @@ class TestInitCounters: assert total == 1000 # Vérification que tous les compteurs sauf le dernier ont top = 293 - for i in range(expected_count - 1): - assert m.active_counters[i].top == 293 - assert m.active_counters[-1].top == 1000 - 293 * (expected_count - 1) + for i in range(expected_count): + assert m.active_counters[i].top == 4 assert all(c.value == 0 for c in m.active_counters) assert m.oacounter == 0 @@ -85,7 +84,7 @@ class TestInitCounters: m.oatop = 200 m.initcounters() - assert len(m.active_counters) == (200 + 293 - 1) // 293 + assert len(m.active_counters) == 200 assert m.oacounter == 0 assert all(c.value == 0 for c in m.active_counters) @@ -103,10 +102,10 @@ class TestInitCounters: def test_initcounters_percounter_calculation(self): """Test que percounter est calculé correctement""" test_cases = [ - (0, 0), - (293, 1), # 293 / 293 + 1 = 2 mais l'algo donne 1 + (0, 1), + (293, 2), # 293 / 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 (10000, 35) # 10000 / 293 + 1 = 35 ]