Пример #1
0
def test_level_0():
    """Test for level 0 with 128 stories and 1 egg."""
    num_stories = 128
    secret_level = 0
    experiment = Experiment(secret_level)
    assert algo(num_stories, 1, experiment) == secret_level
    assert experiment.num_attempts == 1
Пример #2
0
def test_algo_sanity_4_eggs():
    """Test sanity that the algo with always 4 eggs """
    for _ in range(100):
        num_stories = random.randint(128, 1024)
        num_eggs = 4
        secret_level = random.randint(0, num_stories - 1)
        experiment = Experiment(secret_level)
        assert algo(num_stories, num_eggs, experiment) == secret_level
Пример #3
0
def test_16_stories_4_eggs_l15():
    """Directed test for 16 stories, 4 eggs, level=15"""
    num_stories = 16
    num_eggs = 4
    secret_level = 15
    experiment = Experiment(secret_level)
    assert algo(num_stories, num_eggs, experiment) == secret_level
    assert experiment.num_attempts == 3
Пример #4
0
def test_algo_sanity():
    """Test sanity that the algo generates the correct result. """
    for _ in range(100):
        num_stories = random.randint(128, 1024)
        num_eggs = random.randint(1, num_stories)
        secret_level = random.randint(0, num_stories - 1)
        experiment = Experiment(secret_level)
        assert algo(num_stories, num_eggs, experiment) == secret_level
Пример #5
0
def test_16_stories_2_eggs():
    """Directed test for 10 stories with 2 eggs"""
    num_stories = 16
    num_eggs = 2
    secret_level = 7
    experiment = Experiment(secret_level)
    assert algo(num_stories, num_eggs, experiment) == secret_level
    assert experiment.num_attempts == 9