test: add missing tests

This commit is contained in:
Nurul Huda (Apon) 2026-05-27 12:09:13 +06:00
parent c892667094
commit 2f5da6c195
No known key found for this signature in database
GPG key ID: 5D3F1DE2855A2F79
2 changed files with 22 additions and 3 deletions

View file

@ -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 {

View file

@ -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 {