Example #1
0
def test_fitness_normalized(executor_mock, trace_mock, known_data_mock):
    ff = BranchDistanceSuiteFitnessFunction(executor_mock)
    known_data_mock.existing_predicates[0] = MagicMock(PredicateMetaData)
    trace_mock.executed_predicates[0] = 2
    trace_mock.false_distances[0] = 0
    trace_mock.true_distances[0] = 7.0
    assert ff._compute_fitness(trace_mock, known_data_mock) == 0.875
Example #2
0
def test_fitness_function_diff(executor_mock, trace_mock, known_data_mock):
    ff = BranchDistanceSuiteFitnessFunction(executor_mock)
    known_data_mock.existing_code_objects[0] = MagicMock(CodeObjectMetaData)
    known_data_mock.existing_code_objects[1] = MagicMock(CodeObjectMetaData)
    known_data_mock.existing_code_objects[2] = MagicMock(CodeObjectMetaData)
    trace_mock.executed_code_objects.add(0)
    assert ff._compute_fitness(trace_mock, known_data_mock) == 2.0
Example #3
0
def test_fitness_neither_covered(executor_mock, trace_mock, known_data_mock):
    ff = BranchDistanceSuiteFitnessFunction(executor_mock)
    known_data_mock.existing_predicates[0] = MagicMock(PredicateMetaData)
    assert ff._compute_fitness(trace_mock, known_data_mock) == 2.0
Example #4
0
def test_default_fitness(executor_mock, trace_mock, known_data_mock):
    ff = BranchDistanceSuiteFitnessFunction(executor_mock)
    assert ff._compute_fitness(trace_mock, known_data_mock) == 0