@Test public void should_throw_if_upper_bound_negative() throws Exception { expected.expect(IllegalArgumentException.class); expected.expectMessage("end cannot be more than upper bound."); mTimePattern.setRange(0, 200); }
public void setRange(int start, int end) { if (start < mLowerBound) { throw new IllegalArgumentException("start cannot be less than lower bound."); } if (end > mHigherBound) { throw new IllegalArgumentException("end cannot be more than upper bound."); } if (start > end) { throw new IllegalArgumentException("start must be lesser than end."); } mPattern.setLength(0); mPattern.append(String.valueOf(start)) .append("-") .append(String.valueOf(end)); }
TimePattern { public void setRange(int start, int end) { if (start < mLowerBound) { throw new IllegalArgumentException("start cannot be less than lower bound."); } if (end > mHigherBound) { throw new IllegalArgumentException("end cannot be more than upper bound."); } if (start > end) { throw new IllegalArgumentException("start must be lesser than end."); } mPattern.setLength(0); mPattern.append(String.valueOf(start)) .append("-") .append(String.valueOf(end)); } }
TimePattern { public void setRange(int start, int end) { if (start < mLowerBound) { throw new IllegalArgumentException("start cannot be less than lower bound."); } if (end > mHigherBound) { throw new IllegalArgumentException("end cannot be more than upper bound."); } if (start > end) { throw new IllegalArgumentException("start must be lesser than end."); } mPattern.setLength(0); mPattern.append(String.valueOf(start)) .append("-") .append(String.valueOf(end)); } TimePattern(int lowerBound, int higherBound); }
TimePattern { public void setRange(int start, int end) { if (start < mLowerBound) { throw new IllegalArgumentException("start cannot be less than lower bound."); } if (end > mHigherBound) { throw new IllegalArgumentException("end cannot be more than upper bound."); } if (start > end) { throw new IllegalArgumentException("start must be lesser than end."); } mPattern.setLength(0); mPattern.append(String.valueOf(start)) .append("-") .append(String.valueOf(end)); } TimePattern(int lowerBound, int higherBound); void setRange(int start, int end); @Override String toString(); void setValue(int value); void setIncrement(int interval, int from); void setRawValue(String rawValue); String parse(String rawValue); }
TimePattern { public void setRange(int start, int end) { if (start < mLowerBound) { throw new IllegalArgumentException("start cannot be less than lower bound."); } if (end > mHigherBound) { throw new IllegalArgumentException("end cannot be more than upper bound."); } if (start > end) { throw new IllegalArgumentException("start must be lesser than end."); } mPattern.setLength(0); mPattern.append(String.valueOf(start)) .append("-") .append(String.valueOf(end)); } TimePattern(int lowerBound, int higherBound); void setRange(int start, int end); @Override String toString(); void setValue(int value); void setIncrement(int interval, int from); void setRawValue(String rawValue); String parse(String rawValue);  }