mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
delete behavior test that depends on std.fmt
behavior tests should have minimal dependency on std
This commit is contained in:
parent
150169f1e0
commit
ec36e0609f
@ -1697,7 +1697,7 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize
|
||||
pub fn format(
|
||||
t: @This(),
|
||||
comptime fmt: []const u8,
|
||||
options: std.fmt.FormatOptions,
|
||||
options: std.fmt.Options,
|
||||
writer: *Writer,
|
||||
) !void {
|
||||
if (fmt.len != 0) std.fmt.invalidFmtError(fmt, t);
|
||||
|
||||
@ -100,7 +100,6 @@ test {
|
||||
_ = @import("behavior/undefined.zig");
|
||||
_ = @import("behavior/underscore.zig");
|
||||
_ = @import("behavior/union.zig");
|
||||
_ = @import("behavior/union_with_members.zig");
|
||||
_ = @import("behavior/var_args.zig");
|
||||
_ = @import("behavior/vector.zig");
|
||||
_ = @import("behavior/void.zig");
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
const builtin = @import("builtin");
|
||||
const std = @import("std");
|
||||
const expect = std.testing.expect;
|
||||
const mem = std.mem;
|
||||
const fmt = std.fmt;
|
||||
|
||||
const ET = union(enum) {
|
||||
SINT: i32,
|
||||
UINT: u32,
|
||||
|
||||
pub fn print(a: *const ET, buf: []u8) anyerror!usize {
|
||||
return switch (a.*) {
|
||||
ET.SINT => |x| fmt.printInt(buf, x, 10, .lower, fmt.FormatOptions{}),
|
||||
ET.UINT => |x| fmt.printInt(buf, x, 10, .lower, fmt.FormatOptions{}),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
test "enum with members" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||
|
||||
const a = ET{ .SINT = -42 };
|
||||
const b = ET{ .UINT = 42 };
|
||||
var buf: [20]u8 = undefined;
|
||||
|
||||
try expect((a.print(buf[0..]) catch unreachable) == 3);
|
||||
try expect(mem.eql(u8, buf[0..3], "-42"));
|
||||
|
||||
try expect((b.print(buf[0..]) catch unreachable) == 2);
|
||||
try expect(mem.eql(u8, buf[0..2], "42"));
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user