diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-19 22:48:04 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-19 22:48:04 +0000 |
| commit | 23065ddf6ed0b3762dda5f5059888eb52b5c2415 (patch) | |
| tree | aec187b8211203081e8dacb07a5ce325eb348cc4 /tests/std | |
| parent | 3af5dcf34d705cc52c1ffe5b85c2a90b5104e4c9 (diff) | |
Fixes related to memory safety. I will work more on this related to the stdlib.
Diffstat (limited to 'tests/std')
| -rw-r--r-- | tests/std/test_fs.zc | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/tests/std/test_fs.zc b/tests/std/test_fs.zc index 7f66589..fc6d069 100644 --- a/tests/std/test_fs.zc +++ b/tests/std/test_fs.zc @@ -13,19 +13,19 @@ test "test_std_fs_extended" { var p3 = Path::new("file.txt"); var ext = p3.extension(); assert(ext.is_some(), "Extension missed"); - assert(strcmp(ext.unwrap().c_str(), ".txt") == 0, "Wrong extension"); + assert(strcmp(ext.unwrap_ref().c_str(), ".txt") == 0, "Wrong extension"); var p4 = Path::new("/usr/bin/gcc"); var parent = p4.parent(); assert(parent.is_some(), "Parent missed"); - assert(strcmp(parent.unwrap().c_str(), "/usr/bin") == 0, "Wrong parent"); + assert(strcmp(parent.unwrap_ref().c_str(), "/usr/bin") == 0, "Wrong parent"); var fname = p4.file_name(); assert(fname.is_some(), "Filename missed"); - assert(strcmp(fname.unwrap().c_str(), "gcc") == 0, "Wrong filename"); + assert(strcmp(fname.unwrap_ref().c_str(), "gcc") == 0, "Wrong filename"); "Testing FS..."; - var test_dir = "test_fs_sandbox"; + var test_dir = "tests/test_fs_sandbox"; if (File::exists(test_dir)) { File::remove_dir(test_dir); @@ -63,9 +63,8 @@ test "test_std_fs_extended" { assert(list_res.is_ok(), "Read dir failed"); var entries = list_res.unwrap(); var found_idx = -1; - for (var i: usize = 0; i < entries.length(); i = i + 1) { - var entry: DirEntry = entries.get(i); - if (strcmp(entry.name.c_str(), "hello.txt") == 0) { + for entry in &entries { + if (strcmp((*entry).name.c_str(), "hello.txt") == 0) { found_idx = 1; break; } |
