Skip to content

Can't validate function where literal can be changed between 0 and 1 #3

@espertus

Description

@espertus

This isn't urgent, because I can substitute another problem.

package edu.northeastern.examples.larger_non_negative;

import edu.illinois.cs.cs125.questioner.lib.Correct;
import edu.illinois.cs.cs125.questioner.lib.Wrap;

/*
 * Write a method `largerNonNegative` that returns the larger of 2 `int`
 * arguments, or 0 if both of the arguments are negative.
 */
@SuppressWarnings("ManualMinMaxCalculation")
@Correct(name = "Larger Non-Negative", author = "e.spertus@northeastern.edu", version = "2023.12.0")
@Wrap
public class Question {
  int largerNonNegative(int first, int second) {
    if (first < 0 && second < 0) { // mutate-disable-conditional-boundary
      return 0;
    } else if (first > second) { // mutate-disable-conditional-boundary
      return first;
    } else {
      return second;
    }
  }
}

This can't be validated becase changing the int literals in the first if-condition from 0 to 1 does not affect behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions