From 58cb90681985f42323cca6c4f7f1451651c936ad Mon Sep 17 00:00:00 2001 From: Jimmi HC Date: Sun, 10 Feb 2019 14:47:04 +0100 Subject: Updated to newest testing API --- src/comptime.zig | 18 +++++++++--------- src/streaming.zig | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/comptime.zig b/src/comptime.zig index 808915d..5339da3 100644 --- a/src/comptime.zig +++ b/src/comptime.zig @@ -1,7 +1,7 @@ const clap = @import("index.zig"); const std = @import("std"); -const debug = std.debug; +const testing = std.testing; const heap = std.heap; const mem = std.mem; @@ -130,12 +130,12 @@ test "clap.comptime.ComptimeClap" { var args = try Clap.parse(&fb_allocator.allocator, clap.args.SliceIterator.Error, &arg_iter.iter); defer args.deinit(); - debug.assert(args.flag("-a")); - debug.assert(args.flag("--aa")); - debug.assert(!args.flag("-b")); - debug.assert(!args.flag("--bb")); - debug.assert(mem.eql(u8, args.option("-c").?, "0")); - debug.assert(mem.eql(u8, args.option("--cc").?, "0")); - debug.assert(args.positionals().len == 1); - debug.assert(mem.eql(u8, args.positionals()[0], "something")); + testing.expect(args.flag("-a")); + testing.expect(args.flag("--aa")); + testing.expect(!args.flag("-b")); + testing.expect(!args.flag("--bb")); + testing.expectEqualSlices(u8, "0", args.option("-c").?); + testing.expectEqualSlices(u8, "0", args.option("--cc").?); + testing.expectEqual(usize(1), args.positionals().len); + testing.expectEqualSlices(u8, "something", args.positionals()[0]); } diff --git a/src/streaming.zig b/src/streaming.zig index f33fd96..cc5da79 100644 --- a/src/streaming.zig +++ b/src/streaming.zig @@ -3,7 +3,7 @@ const clap = @import("index.zig"); const std = @import("std"); const args = clap.args; -const debug = std.debug; +const testing = std.testing; const heap = std.heap; const mem = std.mem; const os = std.os; @@ -194,17 +194,17 @@ fn testNoErr(params: []const clap.Param(u8), args_strings: []const []const u8, r for (results) |res| { const arg = (c.next() catch unreachable) orelse unreachable; - debug.assert(res.param == arg.param); + testing.expectEqual(res.param, arg.param); const expected_value = res.value orelse { - debug.assert(arg.value == null); + testing.expectEqual(@typeOf(arg.value)(null), arg.value); continue; }; const actual_value = arg.value orelse unreachable; - debug.assert(mem.eql(u8, expected_value, actual_value)); + testing.expectEqualSlices(u8, expected_value, actual_value); } - if (c.next() catch unreachable) |_| { - unreachable; + if (c.next() catch @panic("")) |_| { + @panic(""); } } -- cgit v1.2.3