public void hoursAndMinutesOk() throws ParseException
{
String[] timesWithPoint = new String[] {"1.2", "1.20", "01.2", "01.20", "1.2h", "1.20h", "01.2h", "01.20h"};
for (String time : timesWithPoint)
{
Duration duration = cut.parse(time);
assertEquals("Error parsing " + time, 1, duration.getHours());
assertEquals("Error parsing " + time, 12, duration.getMinutes());
}
String[] timesWithComma = new String[] {"1,2", "1,20", "01,2", "01,20", "1,2h", "1,20h", "01,2h", "01,20h"};
for (String time : timesWithComma)
{
Duration duration = cut.parse(time);
assertEquals("Error parsing " + time, 1, duration.getHours());
assertEquals("Error parsing " + time, 12, duration.getMinutes());
}
String[] timesWithColumn = new String[] {"1:2", "1:02", "1:2h", "1:02h", "1:2m", "1:02m"};
for (String time : timesWithColumn)
{
Duration duration = cut.parse(time);
assertEquals("Error parsing " + time, 1, duration.getHours());
assertEquals("Error parsing " + time, 2, duration.getMinutes());
}
timesWithColumn = new String[] {"1:20", "01:20", "1:20h", "01:20h", "1:20m", "01:20m"};
for (String time : timesWithColumn)
{
Duration duration = cut.parse(time);
assertEquals("Error parsing " + time, 1, duration.getHours());
assertEquals("Error parsing " + time, 20, duration.getMinutes());
}
}