╭ unistd.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1 const builtin = @import("builtin"); 2 const std = @import("std"); 3 4 const c = std.c; 5 const testing = std.testing; 6 7 test "swab" { 8 if (builtin.target.cpu.arch.isMIPS64() and @sizeOf(usize) == 4) return error.SkipZigTest; // TODO 9 if (builtin.target.cpu.arch == .x86_64 and @sizeOf(usize) == 4) return error.SkipZigTest; // TODO 10 if (builtin.target.os.tag == .netbsd) return error.SkipZigTest; // TODO 11 if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO 12 13 var a: [4]u8 = undefined; 14 @memset(a[0..], '\x00'); 15 c.swab("abcd", &a, 4); 16 try testing.expectEqualSlices(u8, "badc", &a); 17 18 // Partial copy 19 @memset(a[0..], '\x00'); 20 c.swab("abcd", &a, 2); 21 try testing.expectEqualSlices(u8, "ba\x00\x00", &a); 22 23 // n < 1 24 @memset(a[0..], '\x00'); 25 c.swab("abcd", &a, 0); 26 try testing.expectEqualSlices(u8, &.{ 0, 0, 0, 0 }, &a); 27 c.swab("abcd", &a, -1); 28 try testing.expectEqualSlices(u8, &.{ 0, 0, 0, 0 }, &a); 29 30 // Odd n 31 @memset(a[0..], '\x00'); 32 c.swab("abcd", &a, 1); 33 try testing.expectEqualSlices(u8, &.{ 0, 0, 0, 0 }, &a); 34 c.swab("abcd", &a, 3); 35 try testing.expectEqualSlices(u8, "ba\x00\x00", &a); 36 } 37