mirror of
https://github.com/ziglang/zig.git
synced 2025-12-29 09:33:18 +00:00
Now they use slices or array pointers with any element type instead of requiring byte pointers. This is a breaking enhancement to the language. The safety check for overlapping pointers will be implemented in a future commit. closes #14040
23 lines
691 B
Zig
23 lines
691 B
Zig
const std = @import("std");
|
|
const builtin = @import("builtin");
|
|
const mem = std.mem;
|
|
const expect = std.testing.expect;
|
|
const Keys = struct {
|
|
up: bool,
|
|
down: bool,
|
|
left: bool,
|
|
right: bool,
|
|
};
|
|
var keys: Keys = undefined;
|
|
test "zero keys with @memset" {
|
|
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
|
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
|
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
|
|
|
@memset(@ptrCast([*]u8, &keys)[0..@sizeOf(@TypeOf(keys))], 0);
|
|
try expect(!keys.up);
|
|
try expect(!keys.down);
|
|
try expect(!keys.left);
|
|
try expect(!keys.right);
|
|
}
|