const std = @import("std"); const paste = @import("../../input/paste.zig"); pub fn is_safe(data: ?[*]const u8, len: usize) callconv(.c) bool { const slice: []const u8 = if (data) |v| v[0..len] else &.{}; return paste.isSafe(slice); } test "is_safe with safe data" { const testing = std.testing; const safe = "hello world"; try testing.expect(is_safe(safe.ptr, safe.len)); } test "is_safe with newline" { const testing = std.testing; const unsafe = "hello\nworld"; try testing.expect(!is_safe(unsafe.ptr, unsafe.len)); } test "is_safe with bracketed paste end" { const testing = std.testing; const unsafe = "hello\x1b[201~world"; try testing.expect(!is_safe(unsafe.ptr, unsafe.len)); } test "is_safe with empty data" { const testing = std.testing; const empty = ""; try testing.expect(is_safe(empty.ptr, 0)); } test "is_safe with null empty data" { const testing = std.testing; try testing.expect(is_safe(null, 0)); }