Skip to content

Commit b535f88

Browse files
test: add patch test
1 parent 78d823a commit b535f88

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

src/cli/test_patch.zig

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const STD = @import("std");
2+
const PATCH = @import("patch.zig");
3+
4+
const TEST_PATCHES_DIR = "tests/patches";
5+
6+
const ORIGINAL_FILES_DIR = TEST_PATCHES_DIR ++ "/" ++ "original";
7+
8+
const ORIGINAL_FILE_PATH = ORIGINAL_FILES_DIR ++ "/" ++ "original.txt";
9+
10+
const MODIFIED_FILES_DIR = TEST_PATCHES_DIR ++ "/" ++ "modified";
11+
12+
const MODIFIED_FILE_PATH = MODIFIED_FILES_DIR ++ "/" ++ "modified.txt";
13+
14+
fn initPatchTest() !void {
15+
STD.fs.cwd().access(ORIGINAL_FILES_DIR, .{}) catch {
16+
try STD.fs.cwd().makePath(ORIGINAL_FILES_DIR);
17+
};
18+
19+
STD.fs.cwd().access(MODIFIED_FILES_DIR, .{}) catch {
20+
try STD.fs.cwd().makePath(MODIFIED_FILES_DIR);
21+
};
22+
23+
STD.fs.cwd().access(ORIGINAL_FILE_PATH, .{}) catch {
24+
try STD.fs.cwd().writeFile(.{ .sub_path = ORIGINAL_FILE_PATH, .data = "hello", .flags = .{ .truncate = true } });
25+
};
26+
27+
STD.fs.cwd().access(MODIFIED_FILE_PATH, .{}) catch {
28+
try STD.fs.cwd().writeFile(.{ .sub_path = MODIFIED_FILE_PATH, .data = "hey", .flags = .{ .truncate = true } });
29+
};
30+
}
31+
32+
test "patch system" {
33+
var allocator: STD.mem.Allocator = STD.testing.allocator;
34+
35+
try PATCH.run(allocator);
36+
}
37+
38+
test "patch" {
39+
var allocator: STD.mem.Allocator = STD.testing.allocator;
40+
41+
_ = allocator;
42+
}

0 commit comments

Comments
 (0)