mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: implement os.truncate() + improve error handling (#9752)
This commit is contained in:
@@ -573,3 +573,16 @@ fn test_exists_in_system_path() {
|
||||
}
|
||||
assert os.exists_in_system_path('ls')
|
||||
}
|
||||
|
||||
fn test_truncate() {
|
||||
filename := './test_trunc.txt'
|
||||
hello := 'hello world!'
|
||||
mut f := os.create(filename) or { panic(err) }
|
||||
f.write_string(hello) or { panic(err) }
|
||||
f.close()
|
||||
assert hello.len == os.file_size(filename)
|
||||
newlen := u64(40000)
|
||||
os.truncate(filename, newlen) or { panic(err) }
|
||||
assert newlen == os.file_size(filename)
|
||||
os.rm(filename) or { panic(err) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user