1 19 20 package org.netbeans.modules.tasklist.usertasks.util; 21 22 import junit.framework.TestCase; 23 import junit.framework.*; 24 import java.text.MessageFormat ; 25 import java.text.ParseException ; 26 import java.util.regex.Matcher ; 27 import java.util.regex.Pattern ; 28 import org.netbeans.modules.tasklist.usertasks.model.Duration; 29 import org.openide.util.NbBundle; 30 31 36 public class DurationFormatTest extends TestCase { 37 public DurationFormatTest(String testName) { 38 super(testName); 39 } 40 41 45 public void testParse() throws ParseException { 46 DurationFormat instance = new DurationFormat(DurationFormat.Type.SHORT); 47 assertEquals("01:00", instance.format(instance.parse("1:00"))); 48 assertEquals("1d 01:03", instance.format(instance.parse("1d 1:03"))); 49 assertEquals("1w 2d 21:03", instance.format(instance.parse("1w 2d 21:03"))); 50 assertEquals("3w 20:03", instance.format(instance.parse("3w 20:03"))); 51 assertEquals("1w", instance.format(instance.parse("1w"))); 52 instance = new DurationFormat(DurationFormat.Type.LONG); 53 assertEquals("1 hour", instance.format(instance.parse("1 hour"))); 54 assertEquals("2 days", instance.format(instance.parse("2 days"))); 55 assertEquals("2 weeks 1 hour", instance.format(instance.parse("2 weeks 1 hour"))); 56 assertEquals("2 weeks 1 day 7 hours 4 minutes", instance.format(instance.parse("2 weeks 1 day 7 hours 4 minutes"))); 57 } 58 } 59 | Popular Tags |