Merge pull request #338 from wb9688/parse-duration-string-test
Add tests for parseDurationString()
This commit is contained in:
commit
92f6754f0f
|
@ -142,9 +142,10 @@ public class YoutubeParsingHelper {
|
||||||
default:
|
default:
|
||||||
throw new ParsingException("Error duration string with unknown format: " + input);
|
throw new ParsingException("Error duration string with unknown format: " + input);
|
||||||
}
|
}
|
||||||
return ((((Long.parseLong(Utils.removeNonDigitCharacters(days)) * 24)
|
|
||||||
+ Long.parseLong(Utils.removeNonDigitCharacters(hours)) * 60)
|
return ((Long.parseLong(Utils.removeNonDigitCharacters(days)) * 24
|
||||||
+ Long.parseLong(Utils.removeNonDigitCharacters(minutes))) * 60)
|
+ Long.parseLong(Utils.removeNonDigitCharacters(hours))) * 60
|
||||||
|
+ Long.parseLong(Utils.removeNonDigitCharacters(minutes))) * 60
|
||||||
+ Long.parseLong(Utils.removeNonDigitCharacters(seconds));
|
+ Long.parseLong(Utils.removeNonDigitCharacters(seconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,11 @@ import org.junit.Test;
|
||||||
import org.schabi.newpipe.DownloaderTestImpl;
|
import org.schabi.newpipe.DownloaderTestImpl;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class YoutubeParsingHelperTest {
|
public class YoutubeParsingHelperTest {
|
||||||
|
@ -27,4 +29,11 @@ public class YoutubeParsingHelperTest {
|
||||||
assertTrue("Hardcoded YouTube Music keys are not valid anymore",
|
assertTrue("Hardcoded YouTube Music keys are not valid anymore",
|
||||||
YoutubeParsingHelper.areHardcodedYoutubeMusicKeysValid());
|
YoutubeParsingHelper.areHardcodedYoutubeMusicKeysValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParseDurationString() throws ParsingException {
|
||||||
|
assertEquals(1162567, YoutubeParsingHelper.parseDurationString("12:34:56:07"));
|
||||||
|
assertEquals(4445767, YoutubeParsingHelper.parseDurationString("1,234:56:07"));
|
||||||
|
assertEquals(754, YoutubeParsingHelper.parseDurationString("12:34 "));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue