Extra tests suggested by Clover

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137547 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2003-08-01 00:12:32 +00:00
parent 87b920c44b
commit 035055e826
4 changed files with 50 additions and 5 deletions

View File

@ -53,6 +53,8 @@
*/
package org.apache.commons.lang.time;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import java.util.Calendar;
import java.util.TimeZone;
@ -85,6 +87,17 @@ public DateFormatUtilsTest(String s) {
super(s);
}
//-----------------------------------------------------------------------
public void testConstructor() {
assertNotNull(new DateFormatUtils());
Constructor[] cons = DateFormatUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
assertEquals(true, Modifier.isPublic(DateFormatUtils.class.getModifiers()));
assertEquals(false, Modifier.isFinal(DateFormatUtils.class.getModifiers()));
}
//-----------------------------------------------------------------------
public void testDateTimeISO(){
TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
Calendar cal = Calendar.getInstance(timeZone);

View File

@ -53,6 +53,8 @@
*/
package org.apache.commons.lang.time;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@ -105,8 +107,16 @@ protected void tearDown() throws Exception {
}
//-----------------------------------------------------------------------
public void testConstructor() {
assertNotNull(new DateUtils());
Constructor[] cons = DateUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
assertEquals(true, Modifier.isPublic(DateUtils.class.getModifiers()));
assertEquals(false, Modifier.isFinal(DateUtils.class.getModifiers()));
}
//-----------------------------------------------------------------------
/**
* Tests various values with the round method
*/

View File

@ -53,6 +53,8 @@
*/
package org.apache.commons.lang.time;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import java.util.Calendar;
import java.util.TimeZone;
@ -86,6 +88,17 @@ public DurationFormatUtilsTest(String s) {
super(s);
}
//-----------------------------------------------------------------------
public void testConstructor() {
assertNotNull(new DurationFormatUtils());
Constructor[] cons = DurationFormatUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
assertEquals(false, Modifier.isPublic(DurationFormatUtils.class.getModifiers()));
assertEquals(false, Modifier.isFinal(DurationFormatUtils.class.getModifiers()));
}
//-----------------------------------------------------------------------
public void testFormatWords(){
String text = null;

View File

@ -62,7 +62,7 @@
* TestCase for StopWatch.
*
* @author Stephen Colebourne
* @version $Id: StopWatchTest.java,v 1.4 2003/06/24 21:13:55 scolebourne Exp $
* @version $Id: StopWatchTest.java,v 1.5 2003/08/01 00:12:32 scolebourne Exp $
*/
public class StopWatchTest extends TestCase {
@ -80,10 +80,9 @@ public StopWatchTest(String s) {
super(s);
}
//-----------------------------------------------------------------------
public void testStopWatchSimple(){
StopWatch watch = new StopWatch();
assertEquals(0, watch.getTime());
watch.start();
try {Thread.sleep(550);} catch (InterruptedException ex) {}
watch.stop();
@ -97,6 +96,16 @@ public void testStopWatchSimple(){
assertEquals(0, watch.getTime());
}
public void testStopWatchSimpleGet(){
StopWatch watch = new StopWatch();
assertEquals(0, watch.getTime());
assertEquals("0:00:00.000", watch.toString());
watch.start();
try {Thread.sleep(500);} catch (InterruptedException ex) {}
assertTrue(watch.getTime() < 2000);
}
public void testStopWatchSplit(){
StopWatch watch = new StopWatch();
watch.start();