1const std = @import("std");
2const string = []const u8;
3const extras = @import("./lib.zig");
4const parse_int = extras.parse_int;
5
6pub fn parse_bool(s: ?string) bool {
7 return parse_int(u1, s, 10, 0) > 0;
8}
9
10test {
11 try std.testing.expect(parse_bool("1"));
12}
13test {
14 try std.testing.expect(!parse_bool("0"));
15}
16test {
17 try std.testing.expect(!parse_bool("Q"));
18}
19test {
20 try std.testing.expect(!parse_bool(""));
21}
22test {
23 try std.testing.expect(!parse_bool(null));
24}