Java Assert assertRange(String label, double value, double min, double max)

Here you can find the source of assertRange(String label, double value, double min, double max)

Description

assert Range

License

Apache License

Declaration

public static double assertRange(String label, double value, double min, double max) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static double assertRange(String label, double value, double min, double max) {
        if (value < min || value > max) {
            throw new IllegalArgumentException(
                    String.format("%s must be between %f and %f. Value was: %f", label, min, max, value));
        }//  www .  j  av a2 s .  c  om
        return value;
    }

    public static int assertRange(String label, int value, int min, int max) {
        if (value < min || value > max) {
            throw new IllegalArgumentException(
                    String.format("%s must be between %d and %d. Value was: %d", label, min, max, value));
        }
        return value;
    }
}

Related

  1. assertPositive(int num, String err)
  2. assertPositive(int val, String msg)
  3. assertPositive(int value)
  4. assertPrecondition(boolean b)
  5. assertQualifiedString(String str, String argName)
  6. assertRequiredArgs(Object[] methodArgs, int requiredArgs, String methodName)
  7. assertSame(Object expected, Object actual)
  8. assertSame(Object targetObject0, Object targetObject1)
  9. assertSameClazz(Object object, Object defaults)