Counter counter = new Counter(1, 3);
counter.count(1);
if (getCounter() != 2) {
throw new IllegalStateException("Expected that counter was 2, but actually it was " + getCounter());
}
counter.count(1);
if (getCounter() != 3) {
throw new IllegalStateException("Expected that counter was 3, but actually it was " + getCounter());
}
counter.count(1);
if (getCounter() != 3) {
throw new IllegalStateException("Expected that counter was 3, but actually it was " + getCounter());
}
// test other path
counter = new Counter(1, 3);
counter.count(2);
if (getCounter() != 3) {
throw new IllegalStateException("Expected that counter was 3, but actually it was " + getCounter());
}
counter.count(2);
if (getCounter() != 3) {
throw new IllegalStateException("Expected that counter was 3, but actually it was " + getCounter());
}
// test yet another path
counter = new Counter(2, 3);
counter.count(2);
if (getCounter() != 3) {
throw new IllegalStateException("Expected that counter was 3, but actually it was " + getCounter());
} |