test: add missing tests
This commit is contained in:
parent
c892667094
commit
2f5da6c195
2 changed files with 22 additions and 3 deletions
|
|
@ -510,7 +510,17 @@ test toJSON {
|
|||
}
|
||||
|
||||
test toZonedDateTimeISO {
|
||||
if (true) return error.SkipZigTest;
|
||||
const inst = try Instant.fromEpochMilliseconds(1704067200000);
|
||||
defer inst.deinit();
|
||||
|
||||
const zdt = try inst.toZonedDateTimeISO(try TimeZone.init("UTC"));
|
||||
defer zdt.deinit();
|
||||
|
||||
try std.testing.expectEqual(@as(i32, 2024), zdt.year());
|
||||
try std.testing.expectEqual(@as(u8, 1), zdt.month());
|
||||
try std.testing.expectEqual(@as(u8, 1), zdt.day());
|
||||
try std.testing.expectEqual(@as(u8, 0), zdt.hour());
|
||||
try std.testing.expectEqual(@as(i128, 1_704_067_200_000_000_000), zdt.epochNanoseconds());
|
||||
}
|
||||
|
||||
test epochMilliseconds {
|
||||
|
|
|
|||
|
|
@ -662,7 +662,11 @@ test add {
|
|||
}
|
||||
|
||||
test getTimeZoneTransition {
|
||||
if (true) return error.SkipZigTest; // getTimeZoneTransition() not properly implemented in underlying library
|
||||
const zdt = try from("2021-01-01T12:00:00+00:00[UTC]", null, .compatible, .reject);
|
||||
defer zdt.deinit();
|
||||
|
||||
try std.testing.expectEqual(@as(?ZonedDateTime, null), try zdt.getTimeZoneTransition(.next));
|
||||
try std.testing.expectEqual(@as(?ZonedDateTime, null), try zdt.getTimeZoneTransition(.previous));
|
||||
}
|
||||
|
||||
test round {
|
||||
|
|
@ -914,7 +918,12 @@ test nanosecond {
|
|||
}
|
||||
|
||||
test offset {
|
||||
if (true) return error.SkipZigTest; // offset() throws RangeError with UTC timezone
|
||||
const zdt = try from("2021-01-01T12:00:00+00:00[UTC]", null, .compatible, .reject);
|
||||
defer zdt.deinit();
|
||||
|
||||
const off = try zdt.offset(std.testing.allocator);
|
||||
defer std.testing.allocator.free(off);
|
||||
try std.testing.expectEqualStrings("+00:00", off);
|
||||
}
|
||||
|
||||
test offsetNanoseconds {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue