mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
replace zig-async-io and std.http.Client with a custom HTTP client
This commit is contained in:
@@ -30,8 +30,8 @@ pub fn expectEqual(expected: anytype, actual: anytype) !void {
|
||||
return;
|
||||
},
|
||||
.optional => {
|
||||
if (actual == null) {
|
||||
return std.testing.expectEqual(null, expected);
|
||||
if (@typeInfo(@TypeOf(expected)) == .null) {
|
||||
return std.testing.expectEqual(null, actual);
|
||||
}
|
||||
return expectEqual(expected, actual.?);
|
||||
},
|
||||
@@ -141,3 +141,36 @@ pub fn print(comptime fmt: []const u8, args: anytype) void {
|
||||
pub fn app(_: anytype) *App {
|
||||
return App.init(allocator, .serve) catch unreachable;
|
||||
}
|
||||
|
||||
pub const Random = struct {
|
||||
var instance: ?std.Random.DefaultPrng = null;
|
||||
|
||||
pub fn fill(buf: []u8) void {
|
||||
var r = random();
|
||||
r.bytes(buf);
|
||||
}
|
||||
|
||||
pub fn fillAtLeast(buf: []u8, min: usize) []u8 {
|
||||
var r = random();
|
||||
const l = r.intRangeAtMost(usize, min, buf.len);
|
||||
r.bytes(buf[0..l]);
|
||||
return buf;
|
||||
}
|
||||
|
||||
pub fn intRange(comptime T: type, min: T, max: T) T {
|
||||
var r = random();
|
||||
return r.intRangeAtMost(T, min, max);
|
||||
}
|
||||
|
||||
pub fn random() std.Random {
|
||||
if (instance == null) {
|
||||
var seed: u64 = undefined;
|
||||
std.posix.getrandom(std.mem.asBytes(&seed)) catch unreachable;
|
||||
instance = std.Random.DefaultPrng.init(seed);
|
||||
// instance = std.Random.DefaultPrng.init(0);
|
||||
|
||||
}
|
||||
return instance.?.random();
|
||||
}
|
||||
};
|
||||
>>>>>>> eaccbd0 (replace zig-async-io and std.http.Client with a custom HTTP client)
|
||||
|
||||
Reference in New Issue
Block a user