They're not for std.debug.print().
+27
-10
Diff
round #0
+20
-4
src/datetime.zig
+20
-4
src/datetime.zig
···
227
227
allocator.free(buf);
228
228
return result;
229
229
}
230
+
230
231
test now {
231
-
const dt = now();
232
-
std.debug.print("{f}\n", .{dt});
232
+
const a1 = now(std.testing.io);
233
+
const e1 = Self{};
234
+
235
+
var abuf: [64]u8 = undefined;
236
+
var ebuf: [64]u8 = undefined;
237
+
const aslice = try std.fmt.bufPrint(&abuf, "{f}", .{a1});
238
+
const eslice = try std.fmt.bufPrint(&ebuf, "{f}", .{e1});
239
+
240
+
try std.testing.expect(std.mem.eql(u8, aslice, eslice) == false);
233
241
}
234
242
235
243
test parse {
236
-
const dt = try parse("1970-01-02T03:04:05");
237
-
std.debug.print("{f}\n", .{dt});
244
+
const a1 = try parse("1970-01-02T03:04:05");
245
+
const e1 = Self{
246
+
.day = 2,
247
+
.month = .jan,
248
+
.year = 1970,
249
+
.hour = 3,
250
+
.minute = 4,
251
+
.second = 5,
252
+
};
253
+
try std.testing.expectEqual(a1, e1);
238
254
}
239
255
240
256
test parseFormat {
+7
-6
src/zoneinfo.zig
+7
-6
src/zoneinfo.zig
···
44
44
}
45
45
46
46
test loadTz {
47
-
const epoch = std.time.timestamp();
48
-
std.debug.assert(epoch > 0);
49
-
const tz_ = try loadTz(std.testing.gpa, std.testing.io, null);
47
+
const NanoMultiplier: i128 = 1000000000;
48
+
const realTimestamp = std.Io.Timestamp.now(std.testing.io, .real);
49
+
const epoch: i64 = @intCast(@divFloor(realTimestamp.nanoseconds, NanoMultiplier));
50
+
try std.testing.expect(epoch > 0);
51
+
const tz_ = try loadTz(std.testing.allocator, std.testing.io, null);
50
52
var tz = tz_.tz;
51
53
defer tz.deinit();
52
54
if (tz.footer) |footer| {
53
-
std.debug.print("Footer: {s}\n", .{footer});
55
+
try std.testing.expect(footer.len > 0);
54
56
}
55
57
var index: usize = 0;
56
58
while ((index + 1) < tz.transitions.len and tz.transitions[index + 1].ts < epoch) {
57
59
index += 1;
58
60
}
59
-
std.debug.assert(index < tz.transitions.len);
60
-
std.debug.print("{d}: {any}\n", .{ index, tz.transitions[index] });
61
+
try std.testing.expect(index < tz.transitions.len);
61
62
}
History
1 round
0 comments
dryfish.tngl.sh
submitted
#0
1 commit
expand
collapse
update unittests
merge conflicts detected
expand
collapse
expand
collapse
- src/datetime.zig:227
- src/zoneinfo.zig:44