// This file is auto-generated by alef — DO NOT EDIT. // alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75 // To regenerate: alef generate // To verify freshness: alef verify --exit-code // Issues & docs: https://github.com/kreuzberg-dev/alef const std = @import("std"); const testing = std.testing; const kreuzberg = @import("kreuzberg"); // Suppress C++ global destructor aborts that break zig's --listen=- IPC extern "c" fn signal(sig: i32, handler: usize) usize; var _abort_handler_installed: bool = false; fn suppress_abort() void { if (!_abort_handler_installed) { // SIGABRT = 6 on POSIX; SIG_IGN = 1 _ = signal(6, 1); _abort_handler_installed = true; } } // E2e tests for category: detection test "detect_mime_bytes_html" { // Detect HTML MIME from bytes suppress_abort(); const content_bytes = try std.Io.Dir.cwd().readFileAlloc(std.testing.io, "html/html.html", std.heap.c_allocator, .unlimited); defer std.heap.c_allocator.free(content_bytes); _ = try kreuzberg.detect_mime_type_from_bytes(content_bytes); } test "detect_mime_bytes_pdf" { // Detect PDF MIME type from bytes suppress_abort(); const content_bytes = try std.Io.Dir.cwd().readFileAlloc(std.testing.io, "pdf/fake_memo.pdf", std.heap.c_allocator, .unlimited); defer std.heap.c_allocator.free(content_bytes); _ = try kreuzberg.detect_mime_type_from_bytes(content_bytes); } test "detect_mime_bytes_png" { // Detect PNG MIME type from bytes suppress_abort(); const content_bytes = try std.Io.Dir.cwd().readFileAlloc(std.testing.io, "images/test_hello_world.png", std.heap.c_allocator, .unlimited); defer std.heap.c_allocator.free(content_bytes); _ = try kreuzberg.detect_mime_type_from_bytes(content_bytes); } test "get_extensions_unknown_mime" { // get_extensions unknown MIME suppress_abort(); const result = kreuzberg.get_extensions_for_mime("application/x-totally-unknown") catch { try testing.expect(true); // Error occurred as expected return; }; _ = result; }