|
EasyMock example source code file (Range.java)
The EasyMock Range.java source code
/*
* Copyright (c) 2001-2007 OFFIS, Tammo Freese.
* This program is made available under the terms of the MIT License.
*/
package org.easymock.internal;
public class Range {
private int minimum;
private int maximum;
public Range(int count) {
this(count, count);
}
public Range(int minimum, int maximum) {
if (!(minimum <= maximum)) {
throw new RuntimeExceptionWrapper(new IllegalArgumentException(
"minimum must be <= maximum"));
}
if (!(minimum >= 0)) {
throw new RuntimeExceptionWrapper(new IllegalArgumentException(
"minimum must be >= 0"));
}
if (!(maximum >= 1)) {
throw new RuntimeExceptionWrapper(new IllegalArgumentException(
"maximum must be >= 1"));
}
this.minimum = minimum;
this.maximum = maximum;
}
public boolean hasFixedCount() {
return minimum == maximum;
}
public int getMaximum() {
return maximum;
}
public int getMinimum() {
return minimum;
}
public String toString() {
if (hasFixedCount()) {
return "" + minimum;
} else if (hasOpenCount()) {
return "at least " + minimum;
} else {
return "between " + minimum + " and " + maximum;
}
}
public String expectedAndActual(int count) {
return "expected: " + this.toString() + ", actual: " + count;
}
public boolean contains(int count) {
return minimum <= count && count <= maximum;
}
public boolean hasOpenCount() {
return maximum == Integer.MAX_VALUE;
}
}
Other EasyMock examples (source code examples)Here is a short list of links related to this EasyMock Range.java source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.