Skip to content

Commit

Permalink
Improve test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
chipkent committed Nov 6, 2023
1 parent 1363c94 commit b480afb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@

public class TestBusinessCalendarParser extends BaseArrayTestCase {

public void testLoad() throws URISyntaxException {
final String path = Paths
.get(Objects.requireNonNull(TestBusinessCalendarParser.class.getResource("/PARSER-TEST.calendar")).toURI())
.toString();
final File f = new File(path);
final BusinessCalendar cal = BusinessCalendarParser.loadBusinessCalendar(f);

public static void assertParserTestCal(final BusinessCalendar cal) {
assertEquals("PARSER-TEST-CAL", cal.name());
assertEquals("Test Calendar", cal.description());
assertEquals(DateTimeUtils.timeZone("Asia/Tokyo"), cal.timeZone());
Expand All @@ -37,4 +31,13 @@ public void testLoad() throws URISyntaxException {
assertEquals(DateTimeUtils.parseInstant("2015-04-06T14:15 Asia/Tokyo"), cal.businessSchedule("2015-04-06").businessStart());
assertEquals(DateTimeUtils.parseInstant("2015-04-06T16:46 Asia/Tokyo"), cal.businessSchedule("2015-04-06").businessEnd());
}

public void testLoad() throws URISyntaxException {
final String path = Paths
.get(Objects.requireNonNull(TestBusinessCalendarParser.class.getResource("/PARSER-TEST.calendar")).toURI())
.toString();
final File f = new File(path);
final BusinessCalendar cal = BusinessCalendarParser.loadBusinessCalendar(f);
assertParserTestCal(cal);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import io.deephaven.base.testing.BaseArrayTestCase;
import io.deephaven.configuration.Configuration;

import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.Objects;

public class TestCalendars extends BaseArrayTestCase {

public void testDefault() {
Expand Down Expand Up @@ -39,4 +43,19 @@ public void testCalendar() {
// pass
}
}

public void testAdd() throws URISyntaxException {

try{
final String path = Paths
.get(Objects.requireNonNull(TestBusinessCalendarParser.class.getResource("/PARSER-TEST.calendar")).toURI())
.toString();
Calendars.addCalendarFromFile(path);

final BusinessCalendar cal = Calendars.calendar("PARSER-TEST-CAL");
TestBusinessCalendarParser.assertParserTestCal(cal);
}finally {
Calendars.setDefaultCalendar(Configuration.getInstance().getProperty("Calendar.default"));
}
}
}

0 comments on commit b480afb

Please sign in to comment.