diff options
Diffstat (limited to 'clap')
| -rw-r--r-- | clap/args.zig | 2 | ||||
| -rw-r--r-- | clap/comptime.zig | 8 | ||||
| -rw-r--r-- | clap/streaming.zig | 26 |
3 files changed, 18 insertions, 18 deletions
diff --git a/clap/args.zig b/clap/args.zig index b699438..071f756 100644 --- a/clap/args.zig +++ b/clap/args.zig | |||
| @@ -33,7 +33,7 @@ pub const SliceIterator = struct { | |||
| 33 | }; | 33 | }; |
| 34 | 34 | ||
| 35 | test "clap.args.SliceIterator" { | 35 | test "clap.args.SliceIterator" { |
| 36 | const args = [_][]const u8{ "A", "BB", "CCC" }; | 36 | const args = &[_][]const u8{ "A", "BB", "CCC" }; |
| 37 | var iter = SliceIterator{ .args = args }; | 37 | var iter = SliceIterator{ .args = args }; |
| 38 | 38 | ||
| 39 | for (args) |a| { | 39 | for (args) |a| { |
diff --git a/clap/comptime.zig b/clap/comptime.zig index f5c2762..c25659b 100644 --- a/clap/comptime.zig +++ b/clap/comptime.zig | |||
| @@ -9,7 +9,7 @@ const debug = std.debug; | |||
| 9 | pub fn ComptimeClap(comptime Id: type, comptime params: []const clap.Param(Id)) type { | 9 | pub fn ComptimeClap(comptime Id: type, comptime params: []const clap.Param(Id)) type { |
| 10 | var flags: usize = 0; | 10 | var flags: usize = 0; |
| 11 | var options: usize = 0; | 11 | var options: usize = 0; |
| 12 | var converted_params: []const clap.Param(usize) = [_]clap.Param(usize){}; | 12 | var converted_params: []const clap.Param(usize) = &[_]clap.Param(usize){}; |
| 13 | for (params) |param| { | 13 | for (params) |param| { |
| 14 | var index: usize = 0; | 14 | var index: usize = 0; |
| 15 | if (param.names.long != null or param.names.short != null) { | 15 | if (param.names.long != null or param.names.short != null) { |
| @@ -113,7 +113,7 @@ pub fn ComptimeClap(comptime Id: type, comptime params: []const clap.Param(Id)) | |||
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | test "clap.comptime.ComptimeClap" { | 115 | test "clap.comptime.ComptimeClap" { |
| 116 | const Clap = ComptimeClap(clap.Help, comptime [_]clap.Param(clap.Help){ | 116 | const Clap = ComptimeClap(clap.Help, comptime &[_]clap.Param(clap.Help){ |
| 117 | clap.parseParam("-a, --aa ") catch unreachable, | 117 | clap.parseParam("-a, --aa ") catch unreachable, |
| 118 | clap.parseParam("-b, --bb ") catch unreachable, | 118 | clap.parseParam("-b, --bb ") catch unreachable, |
| 119 | clap.parseParam("-c, --cc <V>") catch unreachable, | 119 | clap.parseParam("-c, --cc <V>") catch unreachable, |
| @@ -125,7 +125,7 @@ test "clap.comptime.ComptimeClap" { | |||
| 125 | var buf: [1024]u8 = undefined; | 125 | var buf: [1024]u8 = undefined; |
| 126 | var fb_allocator = heap.FixedBufferAllocator.init(buf[0..]); | 126 | var fb_allocator = heap.FixedBufferAllocator.init(buf[0..]); |
| 127 | var iter = clap.args.SliceIterator{ | 127 | var iter = clap.args.SliceIterator{ |
| 128 | .args = [_][]const u8{ | 128 | .args = &[_][]const u8{ |
| 129 | "-a", "-c", "0", "something", | 129 | "-a", "-c", "0", "something", |
| 130 | }, | 130 | }, |
| 131 | }; | 131 | }; |
| @@ -138,6 +138,6 @@ test "clap.comptime.ComptimeClap" { | |||
| 138 | testing.expect(!args.flag("--bb")); | 138 | testing.expect(!args.flag("--bb")); |
| 139 | testing.expectEqualSlices(u8, "0", args.option("-c").?); | 139 | testing.expectEqualSlices(u8, "0", args.option("-c").?); |
| 140 | testing.expectEqualSlices(u8, "0", args.option("--cc").?); | 140 | testing.expectEqualSlices(u8, "0", args.option("--cc").?); |
| 141 | testing.expectEqual(usize(1), args.positionals().len); | 141 | testing.expectEqual(@as(usize, 1), args.positionals().len); |
| 142 | testing.expectEqualSlices(u8, "something", args.positionals()[0]); | 142 | testing.expectEqualSlices(u8, "something", args.positionals()[0]); |
| 143 | } | 143 | } |
diff --git a/clap/streaming.zig b/clap/streaming.zig index fa7ce80..3678917 100644 --- a/clap/streaming.zig +++ b/clap/streaming.zig | |||
| @@ -170,7 +170,7 @@ fn testNoErr(params: []const clap.Param(u8), args_strings: []const []const u8, r | |||
| 170 | const arg = (c.next() catch unreachable) orelse unreachable; | 170 | const arg = (c.next() catch unreachable) orelse unreachable; |
| 171 | testing.expectEqual(res.param, arg.param); | 171 | testing.expectEqual(res.param, arg.param); |
| 172 | const expected_value = res.value orelse { | 172 | const expected_value = res.value orelse { |
| 173 | testing.expectEqual(@typeOf(arg.value)(null), arg.value); | 173 | testing.expectEqual(@as(@typeOf(arg.value), null), arg.value); |
| 174 | continue; | 174 | continue; |
| 175 | }; | 175 | }; |
| 176 | const actual_value = arg.value orelse unreachable; | 176 | const actual_value = arg.value orelse unreachable; |
| @@ -203,13 +203,13 @@ test "clap.streaming.StreamingClap: short params" { | |||
| 203 | const c = ¶ms[2]; | 203 | const c = ¶ms[2]; |
| 204 | 204 | ||
| 205 | testNoErr( | 205 | testNoErr( |
| 206 | params, | 206 | ¶ms, |
| 207 | [_][]const u8{ | 207 | &[_][]const u8{ |
| 208 | "-a", "-b", "-ab", "-ba", | 208 | "-a", "-b", "-ab", "-ba", |
| 209 | "-c", "0", "-c=0", "-ac", | 209 | "-c", "0", "-c=0", "-ac", |
| 210 | "0", "-ac=0", | 210 | "0", "-ac=0", |
| 211 | }, | 211 | }, |
| 212 | [_]Arg(u8){ | 212 | &[_]Arg(u8){ |
| 213 | Arg(u8){ .param = a }, | 213 | Arg(u8){ .param = a }, |
| 214 | Arg(u8){ .param = b }, | 214 | Arg(u8){ .param = b }, |
| 215 | Arg(u8){ .param = a }, | 215 | Arg(u8){ .param = a }, |
| @@ -248,13 +248,13 @@ test "clap.streaming.StreamingClap: long params" { | |||
| 248 | const cc = ¶ms[2]; | 248 | const cc = ¶ms[2]; |
| 249 | 249 | ||
| 250 | testNoErr( | 250 | testNoErr( |
| 251 | params, | 251 | ¶ms, |
| 252 | [_][]const u8{ | 252 | &[_][]const u8{ |
| 253 | "--aa", "--bb", | 253 | "--aa", "--bb", |
| 254 | "--cc", "0", | 254 | "--cc", "0", |
| 255 | "--cc=0", | 255 | "--cc=0", |
| 256 | }, | 256 | }, |
| 257 | [_]Arg(u8){ | 257 | &[_]Arg(u8){ |
| 258 | Arg(u8){ .param = aa }, | 258 | Arg(u8){ .param = aa }, |
| 259 | Arg(u8){ .param = bb }, | 259 | Arg(u8){ .param = bb }, |
| 260 | Arg(u8){ .param = cc, .value = "0" }, | 260 | Arg(u8){ .param = cc, .value = "0" }, |
| @@ -270,9 +270,9 @@ test "clap.streaming.StreamingClap: positional params" { | |||
| 270 | }}; | 270 | }}; |
| 271 | 271 | ||
| 272 | testNoErr( | 272 | testNoErr( |
| 273 | params, | 273 | ¶ms, |
| 274 | [_][]const u8{ "aa", "bb" }, | 274 | &[_][]const u8{ "aa", "bb" }, |
| 275 | [_]Arg(u8){ | 275 | &[_]Arg(u8){ |
| 276 | Arg(u8){ .param = ¶ms[0], .value = "aa" }, | 276 | Arg(u8){ .param = ¶ms[0], .value = "aa" }, |
| 277 | Arg(u8){ .param = ¶ms[0], .value = "bb" }, | 277 | Arg(u8){ .param = ¶ms[0], .value = "bb" }, |
| 278 | }, | 278 | }, |
| @@ -315,15 +315,15 @@ test "clap.streaming.StreamingClap: all params" { | |||
| 315 | const positional = ¶ms[3]; | 315 | const positional = ¶ms[3]; |
| 316 | 316 | ||
| 317 | testNoErr( | 317 | testNoErr( |
| 318 | params, | 318 | ¶ms, |
| 319 | [_][]const u8{ | 319 | &[_][]const u8{ |
| 320 | "-a", "-b", "-ab", "-ba", | 320 | "-a", "-b", "-ab", "-ba", |
| 321 | "-c", "0", "-c=0", "-ac", | 321 | "-c", "0", "-c=0", "-ac", |
| 322 | "0", "-ac=0", "--aa", "--bb", | 322 | "0", "-ac=0", "--aa", "--bb", |
| 323 | "--cc", "0", "--cc=0", "something", | 323 | "--cc", "0", "--cc=0", "something", |
| 324 | "--", "-", | 324 | "--", "-", |
| 325 | }, | 325 | }, |
| 326 | [_]Arg(u8){ | 326 | &[_]Arg(u8){ |
| 327 | Arg(u8){ .param = aa }, | 327 | Arg(u8){ .param = aa }, |
| 328 | Arg(u8){ .param = bb }, | 328 | Arg(u8){ .param = bb }, |
| 329 | Arg(u8){ .param = aa }, | 329 | Arg(u8){ .param = aa }, |