mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-02 11:12:31 +00:00
os2: add read dir test
This commit is contained in:
26
tests/core/os/os2/dir.odin
Normal file
26
tests/core/os/os2/dir.odin
Normal file
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user