From 20e012b78201366300d514163b746bb56dbabf30 Mon Sep 17 00:00:00 2001 From: boyska Date: Thu, 1 Oct 2020 19:53:19 +0200 Subject: [PATCH] super unit test --- tests/test_banana.py | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/tests/test_banana.py b/tests/test_banana.py index 1652ac2..3b27837 100644 --- a/tests/test_banana.py +++ b/tests/test_banana.py @@ -2,13 +2,41 @@ """Tests for `banana` package.""" -import pytest +from banana import banana2dec, dec2banana + +known_conversions = { + "ba": 0, + "baba": 0, + "be": 1, + "beba": 70, + "zu": 69, + "bezu": 139, + "nana": 2485, + "banana": 2485, +} -from banana import bananalib +def test_banana_to_dec_known(): + for word, value in known_conversions.items(): + assert banana2dec(word) == value + + +def test_banana2dec_prefix_ba(): + """un ba all'inizio non cambia nulla!""" + for word in known_conversions: + value = banana2dec(word) + for prefix in ("ba", "baba", "bababa"): + assert banana2dec(prefix + word) == value + + +def test_dec_to_banana_known(): + for word, value in known_conversions.items(): + if word.startswith("ba"): + continue + assert dec2banana(value) == word def test_answer_to_life_the_universe_and_everything(): - banana = bananalib.banana2dec("banana") + banana = banana2dec("banana") assert banana != 42 assert banana == 2485