tested some missing bad states

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@149477 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2005-02-02 03:52:50 +00:00
parent 1e9fbb7f10
commit ba92e4d253
1 changed files with 18 additions and 2 deletions

View File

@ -24,7 +24,7 @@ import junit.textui.TestRunner;
* TestCase for StopWatch. * TestCase for StopWatch.
* *
* @author Stephen Colebourne * @author Stephen Colebourne
* @version $Id: StopWatchTest.java,v 1.8 2004/09/05 19:55:29 bayard Exp $ * @version $Id$
*/ */
public class StopWatchTest extends TestCase { public class StopWatchTest extends TestCase {
@ -128,6 +128,13 @@ public class StopWatchTest extends TestCase {
// expected // expected
} }
try {
watch.split();
fail("Calling split on a non-running StopWatch should throw an exception. ");
} catch(IllegalStateException ise) {
// expected
}
try { try {
watch.unsplit(); watch.unsplit();
fail("Calling unsplit on an unsplit StopWatch should throw an exception. "); fail("Calling unsplit on an unsplit StopWatch should throw an exception. ");
@ -146,7 +153,7 @@ public class StopWatchTest extends TestCase {
try { try {
watch.start(); watch.start();
fail("Calling start on an started StopWatch should throw an exception. "); fail("Calling start on a started StopWatch should throw an exception. ");
} catch(IllegalStateException ise) { } catch(IllegalStateException ise) {
// expected // expected
} }
@ -172,6 +179,15 @@ public class StopWatchTest extends TestCase {
// expected // expected
} }
watch.stop();
try {
watch.start();
fail("Calling start on a stopped StopWatch should throw an exception as it needs to be reset. ");
} catch(IllegalStateException ise) {
// expected
}
} }
} }