// 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: batch

test "batch_bytes_invalid_mime" {
    // batch_extract_bytes_sync invalid MIME
    suppress_abort();
    _ = try kreuzberg.batch_extract_bytes_sync("[{\"content\":[72,101,108,108,111],\"mime_type\":\"application/x-nonexistent\"}]", "{}");
}

test "batch_extract_bytes_happy" {
    // batch_extract_bytes: happy path with mixed inputs
    suppress_abort();
    const result = try kreuzberg.batch_extract_bytes_sync("[{\"content\":[72,101,108,108,111,44,32,119,111,114,108,100,33],\"mime_type\":\"text/plain\"},{\"content\":[60,104,116,109,108,62,60,98,111,100,121,62,84,101,115,116,60,47,98,111,100,121,62,60,47,104,116,109,108,62],\"mime_type\":\"text/html\"}]", "{}");
    try testing.expect(result.len >= 1);
}

test "batch_extract_bytes_mixed_format" {
    // batch_extract_bytes: handles unsupported MIME gracefully
    suppress_abort();
    _ = try kreuzberg.batch_extract_bytes_sync("[{\"content\":[80,68,70,32,112,108,97,99,101,104,111,108,100,101,114],\"mime_type\":\"application/x-unknown\"}]", "{}");
}

test "batch_extract_bytes_sync_empty_list" {
    // batch_extract_bytes_sync: empty batch
    suppress_abort();
    const result = try kreuzberg.batch_extract_bytes_sync("[]", "{}");
    {
        var _cparse = try std.json.parseFromSlice(std.json.Value, std.heap.c_allocator, result, .{});
        defer _cparse.deinit();
        try testing.expectEqual(0, _cparse.value.array.items.len);
    }
}

test "batch_extract_bytes_sync_invalid_mime" {
    // batch_extract_bytes_sync: unsupported MIME
    suppress_abort();
    _ = try kreuzberg.batch_extract_bytes_sync("[{\"content\":[100,97,116,97],\"mime_type\":\"application/x-unknown\"}]", "{}");
}

test "batch_file_async_basic" {
    // Extract text from multiple files asynchronously
    suppress_abort();
    _ = try kreuzberg.batch_extract_files_sync("[{\"path\":\"pdf/fake_memo.pdf\"},{\"path\":\"text/fake_text.txt\"}]", "{}");
}

test "batch_file_async_not_found" {
    // batch_extract_file async nonexistent
    suppress_abort();
    _ = try kreuzberg.batch_extract_files_sync("[{\"path\":\"/nonexistent/a.pdf\"}]", "{}");
}

test "batch_file_not_found" {
    // batch_extract_file_sync nonexistent
    suppress_abort();
    _ = try kreuzberg.batch_extract_files_sync("[{\"path\":\"/nonexistent/a.pdf\"},{\"path\":\"/nonexistent/b.txt\"}]", "{}");
}

test "batch_file_partial" {
    // batch_extract_file_sync mixed
    suppress_abort();
    _ = try kreuzberg.batch_extract_files_sync("[{\"path\":\"text/plain.txt\"},{\"path\":\"/nonexistent/missing.pdf\"}]", "{}");
}

test "batch_file_sync_basic" {
    // Extract text from multiple files synchronously
    suppress_abort();
    _ = try kreuzberg.batch_extract_files_sync("[{\"path\":\"pdf/fake_memo.pdf\"},{\"path\":\"text/fake_text.txt\"}]", "{}");
}
