testWithinRange

public static void testWithinRange<T extends Comparable<T>>(T min, T max, T actual)(source)

Checks that the given actual value is in the range [min, max]. The range is inclusive. If the value is not in the range, an error message is printed to S_TEST_ERR.

This method is intended to be used in the context of a test case from the student.

Example:


          public static void main(String[] args) {
              testWithinRange(0, 10, 5);
              testWithinRange(0, 10, 0);
              testWithinRange(0, 10, 10);
              testWithinRange(0, 10, -1); // will print an error message
          }
    

Parameters

min

the minimum value of the range

max

the maximum value of the range

actual

the actual value


public static void testWithinRange(double min, double max, double actual)(source)

Checks that the given actual value is in the range [min, max]. The range is inclusive. If the value is not in the range, an error message is printed to S_TEST_ERR.

This method is intended to be used in the context of a test case from the student.

Example:


         public static void main(String[] args) {
             testWithinRange(0, 10, 5);
             testWithinRange(0, 10, 0);
             testWithinRange(0, 10, 10);
             testWithinRange(0, 10, -1); // will print an error message
         }
     

Parameters

min

the minimum value of the range

max

the maximum value of the range

actual

the actual value