Utils { public static boolean containsValueInRange(int[] values, int min, int max) { for (int value : values) { if (min < value && value <= max) { return true; } } return false; } private  Utils(); static int getCurrentVersionCode(Context context); static SharedPreferences getDefaultSharedPreferences(Context context, String prefName); static List<Method> getAnnotatedMethods(Class<?> clazz, Class<? extends Annotation> ann); static boolean hasAnnotatedMethods(Class<?> clazz, Class<? extends Annotation> ann); static void dispatch(VersionModule module, Method method); static boolean containsValueInRange(int[] values, int min, int max); static boolean isNewInstall(int baseCode); static final String TAG; }
@Test public void containsValueInRange() throws Exception { assertTrue(Utils.containsValueInRange(new int[]{1}, 0, 1)); assertTrue(Utils.containsValueInRange(new int[]{0, 1}, 0, 1)); assertTrue(Utils.containsValueInRange(new int[]{0, 1, 2}, 0, 1)); assertTrue(Utils.containsValueInRange(new int[]{1, 2, 3}, 0, 1)); assertTrue(Utils.containsValueInRange(new int[]{1, 2, 3}, 1, 2)); assertTrue(Utils.containsValueInRange(new int[]{1, 2, 3}, 1, 3)); assertTrue(Utils.containsValueInRange(new int[]{1, 2, 3}, 1, 9)); assertFalse(Utils.containsValueInRange(new int[]{0}, 0, 1)); assertFalse(Utils.containsValueInRange(new int[]{0, 1}, 2, 9)); }