File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package org .schabi .newpipe .extractor .localization ;
2+
3+ import org .junit .jupiter .api .BeforeAll ;
4+ import org .junit .jupiter .api .Test ;
5+ import org .schabi .newpipe .extractor .exceptions .ParsingException ;
6+
7+ import static org .junit .jupiter .api .Assertions .assertEquals ;
8+ import static org .junit .jupiter .api .Assertions .assertThrows ;
9+
10+ class TimeAgoParserTest {
11+ private static TimeAgoParser timeAgoParser ;
12+
13+ @ BeforeAll
14+ static void setUp () {
15+ timeAgoParser = TimeAgoPatternsManager .getTimeAgoParserFor (Localization .DEFAULT );
16+ }
17+
18+ @ Test
19+ void testGetDuration () throws ParsingException {
20+ assertEquals (1 , timeAgoParser .parseDuration ("one second" ));
21+ assertEquals (1 , timeAgoParser .parseDuration ("second" ));
22+ assertEquals (49 , timeAgoParser .parseDuration ("49 seconds" ));
23+ assertEquals (61 , timeAgoParser .parseDuration ("1 minute, 1 second" ));
24+ }
25+
26+ @ Test
27+ void testGetDurationError () {
28+ assertThrows (ParsingException .class , () -> timeAgoParser .parseDuration ("abcd" ));
29+ assertThrows (ParsingException .class , () -> timeAgoParser .parseDuration ("12 abcd" ));
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments