diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-02-13 00:49:42 +0100 |
|---|---|---|
| committer | LemonBoy <thatlemon@gmail.com> | 2020-02-13 12:13:56 +0100 |
| commit | f93c219f30b4b4f3bb9280d39be7b585ddcd8447 (patch) | |
| tree | 446d89523be9dce80f0ea219d0e17e3f9cb446ad | |
| parent | c5260f7f867fd4ccb4eb3fd5b0ab91759cf94546 (diff) | |
| download | zig-f93c219f30b4b4f3bb9280d39be7b585ddcd8447.tar.gz zig-f93c219f30b4b4f3bb9280d39be7b585ddcd8447.zip | |
Minor changes for a test case
| -rw-r--r-- | lib/std/os/test.zig | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig index f33b5d5261..989653116c 100644 --- a/lib/std/os/test.zig +++ b/lib/std/os/test.zig @@ -276,8 +276,11 @@ test "mmap" { testing.expectEqual(@as(usize, 1234), data.len); // By definition the data returned by mmap is zero-filled - std.mem.set(u8, data[0 .. data.len - 1], 0x55); - testing.expect(mem.indexOfScalar(u8, data, 0).? == 1234 - 1); + testing.expect(mem.eql(u8, data, &[_]u8{0x00} ** 1234)); + + // Make sure the memory is writeable as requested + std.mem.set(u8, data, 0x55); + testing.expect(mem.eql(u8, data, &[_]u8{0x55} ** 1234)); } const test_out_file = "os_tmp_test"; @@ -300,10 +303,7 @@ test "mmap" { // Map the whole file { - const file = try fs.cwd().createFile(test_out_file, .{ - .read = true, - .truncate = false, - }); + const file = try fs.cwd().openFile(test_out_file, .{}); defer file.close(); const data = try os.mmap( @@ -327,15 +327,12 @@ test "mmap" { // Map the upper half of the file { - const file = try fs.cwd().createFile(test_out_file, .{ - .read = true, - .truncate = false, - }); + const file = try fs.cwd().openFile(test_out_file, .{}); defer file.close(); const data = try os.mmap( null, - alloc_size, + alloc_size / 2, os.PROT_READ, os.MAP_PRIVATE, file.handle, |
