diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-11-15 20:47:51 +0100 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-11-15 20:47:51 +0100 |
| commit | 71020d764205bb3eb658eb04fe17beaab92c2af3 (patch) | |
| tree | 1cdb41e8ca539dc7c293699b2d1d7b9971282e5f /tests | |
| parent | b3c2f5cb123200767cbdffabf797764f3080ea1f (diff) | |
os2: add read dir test
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/core/os/os2/dir.odin | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/core/os/os2/dir.odin b/tests/core/os/os2/dir.odin new file mode 100644 index 000000000..e716b5a97 --- /dev/null +++ b/tests/core/os/os2/dir.odin @@ -0,0 +1,26 @@ +package tests_core_os_os2 + +import os "core:os/os2" +import "core:path/filepath" +import "core:slice" +import "core:testing" + +@(test) +test_read_dir :: proc(t: ^testing.T) { + path := filepath.join({#directory, "../dir"}) + defer delete(path) + + fis, err := os.read_all_directory_by_path(path, context.allocator) + defer os.file_info_slice_delete(fis, context.allocator) + + slice.sort_by_key(fis, proc(fi: os.File_Info) -> string { return fi.name }) + + testing.expect_value(t, err, nil) + testing.expect_value(t, len(fis), 2) + + testing.expect_value(t, fis[0].name, "b.txt") + testing.expect_value(t, fis[0].type, os.File_Type.Regular) + + testing.expect_value(t, fis[1].name, "sub") + testing.expect_value(t, fis[1].type, os.File_Type.Directory) +} |