Skip to content

Commit abfbaae

Browse files
committed
Add some basic tests
1 parent c626e5b commit abfbaae

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

src/root.zig

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const std = @import("std");
33

44
const paths = @import("paths.zig");
55

6-
pub const logger = std.log.scoped(.dll_proxy);
6+
const logger = std.log.scoped(.dll_proxy);
77

88
const dll_names: []const [:0]const u8 = &.{ "version", "winhttp" };
99

@@ -234,5 +234,36 @@ pub fn loadProxy(module: std.os.windows.HMODULE) !void {
234234
}
235235

236236
test {
237-
std.testing.refAllDecls(@This());
237+
if (builtin.os.tag == .windows) {
238+
std.testing.refAllDecls(@This());
239+
}
240+
}
241+
242+
test "dump" {
243+
// This test exists for manual verification that the symbol filtering is working correctly.
244+
// There is no need to run and dump every time.
245+
if (true) {
246+
return;
247+
}
248+
for (std.meta.tags(DllName)) |name| {
249+
const includes = getDllIncludes(name);
250+
std.debug.print("{s}:\n", .{@tagName(name)});
251+
inline for (comptime std.meta.fieldNames(ProxyFuncAddrs)) |field| {
252+
if (@field(includes, field)) {
253+
std.debug.print(" {s}\n", .{field});
254+
}
255+
}
256+
}
257+
}
258+
259+
test "findDllMatch" {
260+
const utf16Lit = std.unicode.utf8ToUtf16LeStringLiteral;
261+
262+
try std.testing.expectEqual(.version, findDllMatch(utf16Lit("VERSION.DLL")));
263+
try std.testing.expectEqual(.version, findDllMatch(utf16Lit("version.dll")));
264+
try std.testing.expectEqual(.version, findDllMatch(utf16Lit("versIon.dll")));
265+
266+
try std.testing.expectEqual(.winhttp, findDllMatch(utf16Lit("WINHTTP.DLL")));
267+
try std.testing.expectEqual(.winhttp, findDllMatch(utf16Lit("winhttp.dll")));
268+
try std.testing.expectEqual(.winhttp, findDllMatch(utf16Lit("WinhttP.DLL")));
238269
}

0 commit comments

Comments
 (0)