also looking at this
Port to latest zig-master
#2
53 files
+1149
-1017
| @@ -4,7 +4,7 @@ const common = @import("regex").common; | ||
| 4 | 4 | |
| 5 | 5 | test "case insensitive: simple literal" { |
| 6 | 6 | const allocator = std.testing.allocator; |
| 7 | var regex = try Regex.compileWithFlags(allocator, "hello", .{ .case_insensitive = true }); | |
| 7 | var regex = try Regex.compileWithFlags(allocator, std.testing.io, "hello", .{ .case_insensitive = true }); | |
| 8 | 8 | defer regex.deinit(); |
| 9 | 9 | |
| 10 | 10 | try std.testing.expect(try regex.isMatch("hello")); |
| @@ -16,7 +16,7 @@ test "case insensitive: simple literal" { | ||
| 16 | 16 | |
| 17 | 17 | test "case insensitive: with quantifiers" { |
| 18 | 18 | const allocator = std.testing.allocator; |
| 19 | var regex = try Regex.compileWithFlags(allocator, "a+b*", .{ .case_insensitive = true }); | |
| 19 | var regex = try Regex.compileWithFlags(allocator, std.testing.io, "a+b*", .{ .case_insensitive = true }); | |
| 20 | 20 | defer regex.deinit(); |
| 21 | 21 | |
| 22 | 22 | try std.testing.expect(try regex.isMatch("aaa")); |
| @@ -29,7 +29,7 @@ test "case insensitive: with quantifiers" { | ||
| 29 | 29 | |
| 30 | 30 | test "case insensitive: mixed with alternation" { |
| 31 | 31 | const allocator = std.testing.allocator; |
| 32 | var regex = try Regex.compileWithFlags(allocator, "cat|dog", .{ .case_insensitive = true }); | |
| 32 | var regex = try Regex.compileWithFlags(allocator, std.testing.io, "cat|dog", .{ .case_insensitive = true }); | |
| 33 | 33 | defer regex.deinit(); |
| 34 | 34 | |
| 35 | 35 | try std.testing.expect(try regex.isMatch("cat")); |
| @@ -42,7 +42,7 @@ test "case insensitive: mixed with alternation" { | ||
| 42 | 42 | |
| 43 | 43 | test "case insensitive: find in text" { |
| 44 | 44 | const allocator = std.testing.allocator; |
| 45 | var regex = try Regex.compileWithFlags(allocator, "hello", .{ .case_insensitive = true }); | |
| 45 | var regex = try Regex.compileWithFlags(allocator, std.testing.io, "hello", .{ .case_insensitive = true }); | |
| 46 | 46 | defer regex.deinit(); |
| 47 | 47 | |
| 48 | 48 | if (try regex.find("Say HELLO world")) |match| { |
| @@ -56,7 +56,7 @@ test "case insensitive: find in text" { | ||
| 56 | 56 | |
| 57 | 57 | test "case insensitive: with anchors" { |
| 58 | 58 | const allocator = std.testing.allocator; |
| 59 | var regex = try Regex.compileWithFlags(allocator, "^hello$", .{ .case_insensitive = true }); | |
| 59 | var regex = try Regex.compileWithFlags(allocator, std.testing.io, "^hello$", .{ .case_insensitive = true }); | |
| 60 | 60 | defer regex.deinit(); |
| 61 | 61 | |
| 62 | 62 | try std.testing.expect(try regex.isMatch("hello")); |
| @@ -68,7 +68,7 @@ test "case insensitive: with anchors" { | ||
| 68 | 68 | |
| 69 | 69 | test "case insensitive: replace" { |
| 70 | 70 | const allocator = std.testing.allocator; |
| 71 | var regex = try Regex.compileWithFlags(allocator, "hello", .{ .case_insensitive = true }); | |
| 71 | var regex = try Regex.compileWithFlags(allocator, std.testing.io, "hello", .{ .case_insensitive = true }); | |
| 72 | 72 | defer regex.deinit(); |
| 73 | 73 | |
| 74 | 74 | const result = try regex.replace(allocator, "Say HELLO world", "hi"); |
| @@ -79,7 +79,7 @@ test "case insensitive: replace" { | ||
| 79 | 79 | |
| 80 | 80 | test "case insensitive: replaceAll" { |
| 81 | 81 | const allocator = std.testing.allocator; |
| 82 | var regex = try Regex.compileWithFlags(allocator, "a", .{ .case_insensitive = true }); | |
| 82 | var regex = try Regex.compileWithFlags(allocator, std.testing.io, "a", .{ .case_insensitive = true }); | |
| 83 | 83 | defer regex.deinit(); |
| 84 | 84 | |
| 85 | 85 | const result = try regex.replaceAll(allocator, "AaAa", "X"); |
| @@ -90,7 +90,7 @@ test "case insensitive: replaceAll" { | ||
| 90 | 90 | |
| 91 | 91 | test "case insensitive: disabled by default" { |
| 92 | 92 | const allocator = std.testing.allocator; |
| 93 | var regex = try Regex.compile(allocator, "hello"); | |
| 93 | var regex = try Regex.compile(allocator, std.testing.io, "hello"); | |
| 94 | 94 | defer regex.deinit(); |
| 95 | 95 | |
| 96 | 96 | try std.testing.expect(try regex.isMatch("hello")); |
| @@ -100,7 +100,7 @@ test "case insensitive: disabled by default" { | ||
| 100 | 100 | |
| 101 | 101 | test "case insensitive: with numbers and special chars" { |
| 102 | 102 | const allocator = std.testing.allocator; |
| 103 | var regex = try Regex.compileWithFlags(allocator, "test123", .{ .case_insensitive = true }); | |
| 103 | var regex = try Regex.compileWithFlags(allocator, std.testing.io, "test123", .{ .case_insensitive = true }); | |
| 104 | 104 | defer regex.deinit(); |
| 105 | 105 | |
| 106 | 106 | try std.testing.expect(try regex.isMatch("test123")); |